In a script, how do you access your regular username when you're executing as root?
In antiX Linux as root, entering "logname" gives me my regular username.
in LMDE as root, entering "logname" gives me "logname: no login name". How do I correct this?
The logname command
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
The logname command
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
- Pilosopong Tasyo
- Level 6
- Posts: 1432
- Joined: Mon Jun 22, 2009 3:26 am
- Location: Philippines
Re: The logname command
Did you mean perform a command as another user? If this is the case you can use sudo -u.swiftlinuxcreator wrote:...access your regular username when you're executing as root?
o Give a man a fish and he will eat for a day. Teach him how to fish and he will eat for a lifetime!
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
o If an issue has been fixed, please edit your first post and add the word [SOLVED].
Re: The logname command
He/she meant that while being su-ed to root you can execute the command "logname" to display the username of the user you're su-ing withPilosopong Tasyo wrote:Did you mean perform a command as another user? If this is the case you can use sudo -u.
@swift, it might be a distro-issue? It works fine on my RHEL6-laptop, not my Mint-netbook.
This topic might explain it fairly well I think? http://forums.gentoo.org/viewtopic-t-28 ... art-0.html
Basically Debian/Ubuntu/Mint logs sessions (usernames) in a different location than where logname is looking. The solution posted there is no longer valid though, my Linux Mint 11 doesn't even have an inittab anymore... :S
However, in directory /etc/init, I do see tty[1-6].conf, which hold relating data.
Cheers!