Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'With login you do not need the root password' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
With login you do not need the root password
Authored by: mzs on May 29, '04 07:41:24PM
This is what I do:

/usr/bin/login -p username

This is almost always works the way I want.

Using the explicit path uses the login command instead of the the login shell builtin. This is better because the shell forks and execs the login command. This way you are able to hit ^D (CTRL+D) to logout of the user you were using temporarily back to where you were before.

The -p option tells the login command to not throw away the environment of the previous user when becoming the temporary user. This can cause some programs to behave oddly in the temporary user but usually I login to an account that has not done much customization in the login files. So in effect I get my configuration for commands in the temporary user, which I like. Also this works around the fact that there is no /etc/termcap by default. (This is a good thing, terminfo is much better.) It just keeps the terminal I had previously. The other environment variables like HOME that matter are still tweaked appropriately by login though.

[ Reply to This | # ]