Subject: The su command
Author: Unix
In response to: sudo vs su commands under Linux / UNIX / BSD / AIX / HP-UX
Posted on: 10/06/2011 03:19:02 PM
The su command stands for "switch user", and allows you to become another user. To use the su command on a per-command basis, enter:
su user -c command
Replace user with the name of the account which you'd like to run the command as, and command with the command you need to run as another user. To switch users before running many commands, enter:
su user
The user feature is optional; if you don't provide a user, the su command defaults to the root account, which in Unix is the system administrator account. In either case, you'll be prompted for the password associated with the account for which you're trying to run the command. If you supply a user, you will be logged in as that account until you exit it.
To exit, press Ctrl-d or type exit at the command prompt.
>
> On 10/06/2011 03:10:59 PM
Unix wrote:
The Unix commands sudo and su allow access to other commands as a different user.
The sudo command
The sudo command stands for "superuser do". It is often used when certain rights are not granted to the current user. For example,
$ mkdir /usr/local/java
mkdir: cannot create directory `/usr/local/java': Permission denied
The command prompts you for your personal password and confirms your request to execute a command by checking a file, called sudoers, which the system administrator configures. Using the sudoers file, system administrators can give certain users or groups access to some or all commands without those users having to know the root password. It also logs all commands and arguments so there is a record of who used it for what, and when.
To use the sudo command, at the command prompt, enter:
sudo command
Replace command with the command for which you want to use sudo. For example
$ sudo mkdir /usr/local/java
References: