/ factorpad.com / tech / linux-essentials / sudo-command.html
An ad-free and cookie-free website.
Beginner
Learn to run a command as a superuser at the Linux command line.
Videos can also be accessed from the Linux Essentials Playlist on YouTube.
Linux sudo Command Summary with Examples (3:41)
Our seventy-ninth word, or command to memorize is
sudo
from our category
Users.
sudo
allows you to run a command as
superuser.
-options | description |
---|---|
-h ,
--help |
Print help screen |
-e ,
--edit |
Edit a file as superuser |
-l ,
--list |
Shows user privileges as sudo, or path to program |
Recall from the previous video (tutorial) on
su
we logged in as another user.
Now we'll take a superuser role temporarily to run commands as an
administrator, also known as a superuser.
Before we start, it helps to think of commands as mini programs and
most follow this structure:
command -option(s) argument(s)
.
The sudo
command has
25 options, and the argument is the command to execute
or a file to open.
Like most commands, help is available with double-dash
--help
. For files, the
-e
command goes right in to a default
editor, and -l
lists what you can do,
assuming you are a superuser.
So why is sudo
an important command?
Well, we need to limit access to adminstrative duties like installing
software, viewing logs and configuration files.
And now you know how to do that.
Okay, the best way to embed this in your memory is by typing in your own terminal window.
Find this on your Mac using a program called Terminal. On Linux use Terminal or Konsole, and currently Microsoft is adding this functionality to Windows.
Here we go. Let's say I have a backup script called
video79.script
that Jennifer wants
to run periodically, so I'll make her a copy.
First, do a
cp video79.script /home/jennifer
.
And notice, an error. I can't access others' directories unless I'm
superuser, so add sudo
on the front.
And there we go.
Then, let's do an ls -og
for
permissions, or mode, from video (tutorial) #75.
And she can't execute this right? So let's do a
sudo chmod 500
, from the octals in
video (tutorial) #75, with 5 for read and execute, applying to the
owner only, and 0 0 for the others.
And then last, let's give her ownership with a
sudo chown jennifer
the owner,
:jennifer
the group, then the file
name and there we go. Then let's do an
ls -l
to verify we have done
everything correctly here.
Very good.
Okay now you know how to use sudo
.
And you know the syntax for commands, options and arguments.
One last tip about the sudo
command. So please make some time to practice these commands it does
take a little bit of work, and next, we'll learn about passwords.
Okay, thanks for visiting today. I hope this was a helpful
introduction to the sudo
command.
For an overview of the 100 videos, the 8 quizzes, a cheat sheet, the categories and a Q&A section, visit:
If you'd like to be notified of new content, subscribe, join and follow. Simple as that.
su
command,
hit Back.passwd
command, click Next./ factorpad.com / tech / linux-essentials / sudo-command.html
A newly-updated free resource. Connect and refer a friend today.