Video:How to Use the 'Sudo' Command on Linuxwith Zoya Popova
The 'sudo' command in Linux allows you to perform tasks a 'superuser'. This About.com video will show you exactly how to go about using the 'sudo' command in Linux.See Transcript
Transcript:How to Use the 'Sudo' Command on Linux
Hi, I'm Zoya Popova for About.com, and today I'm going to show you how to use the 'sudo' command in Linux.
Meaning of 'Sudo' Command
'Sudo' basically stands for 'do something as superuser.' The superuser is the user who has the priviliges to perform administrative tasks. For example, if I wanted to create another user, named daphnee, I'd type the command: adduser daphnee.
In the output, I would get the message "Only root may add a user or group to the system." As zoya, I don't have the priviliges to add a new user to the system. In order to execute this command, I would have to sign is as the superuser, or root, using the command: su.
However, this command requires the root password. Since I do know it, I'll enter it at the prompt, and now you see me logged in as root: root@linux-box: /home/zoya#.
'Sudo' Command Works if You Don't Know Password
In this capacity, I would be able to add my new user or perform any other restricted tasks. The problem is, many users do not know the root password. Let me switch back to my regular zoya user by typing: su zoya.
And let's pretend I don't know my root password. This is where the 'sudo' command will come to my rescue. 'Sudo' in the front of the command line will allow me to perform restricted tasks without asking me for the root password. It will only ask me for my own user password--the one I enter every time I launch my Linux system: sudo adduser daphnee.
At the prompt, I type in my zoya password, enter all the information for the new user daphnee, and I have successfully created a new user without knowing the superuser password.
Accessing Files in Linux Using 'Sudo' Command
Here's another example. In any file system, there are files that can only be accessed by the superuser. Let's see our graphic interface for an example of such file. Here in the boot directory, you can see a series of files that are marked with 'x,' which means they have restricted access. If I try to open one of these files in a text editor:
'gedit' will try to access the file, but will come back with a message, "Could not open file."
Now, let's try the same thing under 'sudo': sudo gedit boot/vmcoreinfo-3.0.0-12-generic. The file immediately opens. In this instance, 'sudo' doesn't even ask me for a password, simply because I just recently entered it in our previous example.
To get more information about the 'sudo' command, you can always refer to its manual by entering: man sudo.
And this is it for us for today. Thank you for watching, and for more information please visit us at About.com.