Switching users and Running Commands as others Flashcards
To change user ID or become super user use this command:
su [username]
this su option is used to provide an environment similar to what the user would expect had the user logged in directly.
a hypen “ - “
this su option specifies a command to be executed
-c command
to find out what user is that you’re working as type:
whoami
To execute a command as another user, typically the super user, used to install, start, stop, and execute. It is different from the “su” command where you don’t need to know the other user’s password, it will prompt you for yours.
sudo
this sudo command lists all available commands:
sudo -l
this sudo command runs a command as root
sudo command
this sudo command also runs a command as root
sudo -u root command
this sudo command runs a command as user
sudo -u user command
this sudo command switches to the superuser account
sudo su
this sudo command switches to the superuser account with root’s environment
sudo su -
this sudo command switches to the username account
sudo su - username
this sudo command starts a shell prompt
sudo -s
this sudo command also starts a shell prompt
sudo -u root -s
this sudo command starts a shell as user
sudo -u user -s