Linux – Running Commands as the Superuser

su

you can run the su command and enter the root password to start a root shell. This practice works, but it has certain disadvantages:

  • You have no record of system-altering commands.
  • You have no record of the users who performed system-altering commands.
  • You don’t have access to your normal shell environment.
  • You have to enter the root password.

sudo

Most larger distributions use a package called  sudo  to allow administrators to run commands as root when they  are  logged  in  as  themselves

$ sudo apt-get update

/etc/sudoers

Of  course,  the  system  doesn’t  let  just  any  user  run  commands  as  the  superuser;  you  must  configure  the privileged users in your  /etc/sudoers  file.

For example, this file gives user1 and user2 the power to run any command as root without having to enter a password:

User_Alias ADMINS = user1, user2

ADMINS ALL = NOPASSWD: ALL

root ALL=(ALL) ALL

Reference: How Linux Works: What Every Superuser Should Know by Brian Ward


Discover more from Embedded for All

Subscribe to get the latest posts sent to your email.

Leave a comment

Discover more from Embedded for All

Subscribe now to keep reading and get access to the full archive.

Continue reading

Design a site like this with WordPress.com
Get started