Published Apr 05, 2020 - Author: Guoxiang (Shawn) Zhou
To check all the sudo users in current system, you need to run
# This command will print all the users listed in the sudo group in /etc/group # sudo27:guzhou means that user guzhou belongs to sudo group. guzhou@guzhou-ThinkPad-P53:~$ getent group sudo sudo27:guzhou # Only list sudo users in your system. guzhou@guzhou-ThinkPad-P53:~$ getent group sudo | cut -d: -f4 guzhou # Check the sudo group. guzhou@guzhou-ThinkPad-P53:~$ cat /etc/group root0: daemon1: bin2: sys3: adm4:syslog,guzhou tty5: disk6: lp7: mail8: news9: uucp10: man12: proxy13: kmem15: dialout20: fax21: voice22: cdrom24:guzhou floppy25: tape26: sudo27:guzhou audio29:pulse dip30:guzhou www-data33: backup34: operator37: list38: irc39: src40: gnats41: shadow42: utmp43: video44: sasl45: plugdev46:guzhou staff50: games60: users100: nogroup65534: systemd-journal101: systemd-network102: systemd-resolve103: input104: crontab105: syslog106: messagebus107: netdev108: mlocate109: ssl-cert110: uuidd111: avahi-autoipd112: bluetooth113: rtkit114: ssh115: lpadmin116:guzhou whoopsie117: scanner118:saned saned119: pulse120: pulse-access121: avahi122: colord123: geoclue124: gdm125: guzhou1000: sambashare126:guzhou nvidia-persistenced127: nm-openvpn128: rdma129: docker130:guzhou _chrony131: vboxusers132:
su is the Linux command to substitute (change) user. In Ubuntu, we cannot change to root account using su command since there is no password set for root account. In a word, the root account is blocked. However, we can use "sudo su" to switch to root.
guzhou@guzhou-ThinkPad-P53:~$ sudo su [sudo] password for guzhou: # Now you are in root account as you can see "#". # Switch from root to user guzhou. root@guzhou-ThinkPad-P53:/home/guzhou# su - guzhou guzhou@guzhou-ThinkPad-P53:~$ sudo su # You can also switch back using "exit" root@guzhou-ThinkPad-P53:/home/guzhou# exit exit guzhou@guzhou-ThinkPad-P53:~$