Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Console Foundations Users and Permissions Creating Users

Sahil Katrekar
Sahil Katrekar
1,480 Points

Confused on this idea

I understood in general that the home directory is /home/username, so it makes sense that when we were logged in as the treehouse user, the home directory is /home/treehouse. When we created the mike user and switched to the mike user using the command 'su mike' and typed the command pwd, the result was still /home/treehouse. Shouldn't it be /home/mike because we are now logged in to the mike user and are now in mike's home directory? I feel like I am missing an important concept here.

Thanks for clarifying!

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You know in Windows when you switch user and then log over to them, the desktop and the file structure and whatnot gets displayed for that user? Well, this doesn't work exactly like that. The command "su" stands for substitute user. It's also referred to switch user. What you're actually doing is not logging out. You're just switching the user of that log in session. But now you will have rights and permissions of that user. Here's some further info about the su command.

http://www.linfo.org/su.html

Note: if you were to log out and then log back into mike then you would see that it loads up /home/mike as the home directory. Likewise, if you "substitute user" to treehouse it doesn't jump around in the directory automatically. It just changes the owner of the login session to treehouse. Hope this helps! :smiley:

Steven Parker
Steven Parker
231,236 Points

By default, the su command only changes the user's identity but does not change the current directory.

The --login (or -l) option can be used to re-create the login environment of the new user (su -l mike).

ywang04
ywang04
6,762 Points

You can use su - mike to change both home directory and user's identity.