Sunday, 17 April 2016

What are sudo and su commands ?


sudo
  • stands for "superuser do"
  • 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 sothere is a record of who used it for what, and when.
  • Syntax
    $ sudo command

    Replace command with the command for which you want to use sudo.

su
  • stands for "switch user", and allows you to become another user.
  • Syntax
    $ 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,
    $ su user

    Replace user with the name of the account which you'd like to run the commands as.
  • 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 do so, press Ctrl+d or type exit at the command prompt.
  • Using su creates security hazards, is potentially dangerous, and requires more administrative maintenance.
    It's not good practice to have numerous people knowing and using the root password because when logged in as root, you can do anything to the system.

su vs. sudo
  • su command switches to the super user (root user) or any other user account.
  • sudo runs a single command with root privileges.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.