What sudo does
Using /etc/sudoers file to confirm what privileges are available to you, sudo command effectively elevates your access rights, thus allowing you to run commands and access files which would otherwise be not available to you. sudo runs these commands as root by default.
The meaning of sudo command is:
- su (switch user)
- do action (run the specified command under specified user)
Default user in sudo
Unless specified, user is assumed to be root. So when you're running some sommand using sudo, your specified command is executed as root.
Using one of the most basics examples: id command shows your current username, its user id (UID), group id (GID) and group membership:
[email protected]:~ $ id uid=1000(greys) gid=1000(greys) groups=1000(greys),989(libvirt)
[email protected]:~ $ sudo id uid=0(root) gid=0(root) groups=0(root)
As you can see from the output, we get all the root information returned: UID =0, GID=0.