How to use sudo

  • To give sudo permissions to a user, say joe, add the user to the sudo group:
$ sudo adduser joe sudo
  • To run a command as superuser:
$ sudo some_command

The superuser privileges last at this shell session for about 15 minutes. Any other superuser commands you execute within this time at this shell session will not require you to enter the password.

  • To run a command as another user, say joe:
$ sudo -u joe some_command
  • If you want to execute many commands or need a shell with superuser:
$ sudo -s
  • To have all your environment variables when you execute sudo:
$ sudo -E some_command
  • To list of commands allowed for you:
$ sudo -l
  • To list the commands allowed for another user, say joe:
$ sudo -l -U joe

Tried with: Ubuntu 18.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.