Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I understand that the second command sets all the environmental variables to the defaults for aUserID, while the first will not. What is the implications of doing so?
Its more of a security/convenience. As a admin, when you are attending regular user's grievances, you want to stay in their environment, PATH and the directory in question. The only edge you want is to run as root, which regular users cant.
You don't want to 'su -', where it throws you to /root directory, puts root user's environment and root's PATH, which to be frankly wont let you see the problem from user's perspective.
Didn't mean no difference in "su" and "su -", but no difference with the outcome.
The reason there is no difference with outcome is, unlike all other distro, Redhat includes /sbin directory in PATH of regular users. I don't know why they do it.
Also, while we are in switching users, you also need to know the difference between 'whoami' and 'who am i'. its helps a lot. The following should be self explanatory.
Code:
[madhu@server ~]$ whoami
madhu
[madhu@server ~]$ who am i
madhu pts/1 2014-03-31 00:43 (192.168.122.1)
[madhu@server ~]$ su - tom
Password:
[tom@server ~]$ whoami
tom
[tom@server ~]$ who am i
madhu pts/1 2014-03-31 00:43 (192.168.122.1)
[tom@server ~]$ su - dummy
Password:
[dummy@server ~]$ whoami
dummy
[dummy@server ~]$ who am i
madhu pts/1 2014-03-31 00:43 (192.168.122.1)
Quote:
Originally Posted by NotionCommotion
So, if I set up my server to prevent ssh'ing as root, and I want to do general configuration as the root user, then I should always use "su - root"?
Correct, its the recommended way of doing it. But just 'su -' is enough. You should not allow root to ssh. I hope you are aware of 'PermitRootLogin no' in sshd_config.
Last edited by Madhu Desai; 03-30-2014 at 02:36 PM.
Yes, I am using Centos (i.e. Redhat). Good to know about how they are unique in including /sbin directory in PATH of regular users. Hopefully, I will remember when I try another distro Better yet, I will just get in the habit of using su - right now!
Turns out "who am i" is the same thing as "who". Am I missing anything? So, "who" displays the originally logged on user, and "whoami" displays the current. Again, good to know.
And yes, I am aware of 'PermitRootLogin no' in sshd_config, but thank you for ensuring.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.