Ubuntu – Sudo command and its source

source codesudo

The sudo command is at /usr/bin/sudo on my Xubuntu 16.04

I'm interested to know if anyone can advise which program I could use to open this sudo file and see what the sudo command is made up of?

I tried using a regular text editor but the file isn't correctly encoded so I can't see anything useful.

Best Answer

sudo is a command and it is an executable program.

You can find out more about how to use it using these commands in the terminal (in order of least -> most detailed):

sudo --help   
man sudo
info sudo

To understand more about how it works, you can visit the sudo website where you can browse the source code. You can also download the source code:

First edit /etc/apt/sources.list

sudo nano /etc/apt/sources.list

you will see these lines near the beginning:

deb http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted
# deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted

You have to uncomment the deb-src line (remove the #) so it says:

deb http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted
deb-src http://gb.archive.ubuntu.com/ubuntu/ xenial main restricted

Save the file and exit. Now run sudo apt update and then, to dowload the source code package to the current working directory

apt source sudo

Super short summary: sudo is short for 'superuser do' meaning 'execute the following command as the superuser'. Thus, it grants the humble user root privileges for one command and any commands triggered by that command.