Linux Advanced Commands (VIII): Get administrator privileges associated command, switch to the administrator to know the user's command

Obtain administrator privileges related commands


learning target

  • To know the command to switch to the administrator user

Use 1. sudo command

command Explanation
sudo -s Switch to the root user, obtain administrator privileges
sudo Execute a command needs to obtain administrator privileges can add the sudo command executed on the front

sudo -s renderings:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-ykWsE6rG-1583934906311) (imgs / sudo-1.png)]

FIG sudo command Effect:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-0Q2UtSkR-1583934906312) (imgs / sudo-2.png)]

Description:

  • If only a particular action requires administrator privileges is recommended to use sudo, that is to say the use of temporary manager privileges.
  • If a large number of operations require administrator privileges sudo -s, but the operation need to be cautious.

Use 2. whoami command

command Explanation
whoami View the current user limit

whoami command renderings:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-MmSLtbzg-1583934906312) (imgs / whoami.png)]

Use 3. exit command

command Explanation
exit Log Users

FIG exit command effects:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-9Lxwqtth-1583934906313) (imgs / exit.png)]

Description:

  • If the user is landing after switching on the exit returns a login account.
  • If a terminal interface to exit the current terminal.

4. who use the command

command Explanation
who See all logged-on user

FIG effect who command:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-IVpIipEU-1583934906313) (imgs / who.png)]

5. passwd command using

command Explanation
passwd Change the user password, the user does not specify a default password to modify the currently logged on user

FIG effect passwd command:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-V4LeGowt-1583934906314) (imgs / passwd.png)]

6. which use the command

command Explanation
which View command position

FIG effect which command:

[Image dump the chain fails, the source station may have security chain mechanism, it is recommended to save the picture down uploaded directly (img-9guwZV6M-1583934906314) (imgs / which.png)]

7. Use shutdown and restart commands

command Explanation
shutdown –h now Immediately shut down
reboot Restart

8. Summary

  • sudo get a temporary administrator rights
  • sudo -s is to switch to the administrator user has administrator privileges, you need to exercise caution.
  • exit is to exit the current user
  • passwd change the current default user password
Published 698 original articles · won praise 929 · views 120 000 +

Guess you like

Origin blog.csdn.net/qq_35456045/article/details/104806930
Recommended