Thursday 8 March 2012

What is difference between su and sudo? su be used instead of sudo for root privilege?


What is difference between su and sudo? How can su be used instead of sudo for getting access
to root privilege?

Ans:

su is used for logging in as any other user, including root user. After entering user password, you can
enter commands as that user unless u enter exit. In order to log in as root, just enter su and in order to
enter as a different user enter suusername. su can be used for single command as:
su user_name –c command
sudo is used for gaining root privilege for a specific command. Adding sudo at the start of a command
implies that root privilege is used for that command. In order to use sudo, the current user has to be
added in sudoers file. sudo–i can be used for starting a shell as root user, but in that case password for
the current user is required, not that of root.
Thus, su can be used to log in as any other user while sudo is used to log in as root user. Moreover, sudo
will always ask for current user password and su will prompt for the password of the user you want to
log in as.

0 comments:

Post a Comment

 
Free Host | lasik surgery new york