Commandline 101: su and sudo

FAIL (the browser should render some flash content, not this).

How to change your root password and use the su command in Ubuntu.

Download in .ogv format


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


dalesmcd's picture

su doesn't mean super user. su means switch user or substitute user. Since most people use su only for root and since sudo means super user do, it's assumed su mean super user. But you can use su to run as any user, like $ su - bob. If you don't specify a user it assumes root.

What's the use of setting root password ?

Manson Thomas's picture

Ok, it's shorter to type

#su -


#sudo -s

but it's only 3 characters more, in both case you type a password.

And by setting root a password, you need to remember one more (what's the use to set the same password of your current user?).
Which (root password) can be break while before I don't think it could be.

Maybe the best way to get root access is (I type sudo -s.... I can use a keyboard ;)) :

alias s="sudo -s"

type s (yahooo... you save one character lazy boy ;)) and type your current user password.

To my mind, setting a password to root is breaking a security concept of Ubuntu system (as you'd be able to break root password).


Not to be nit-picky, but....

Anonymous's picture

I love Shawn's tech tips. Much better than the droll ones from "the other guy" (I forget his

However, one correction...Shawn said su means "Super User". It actually means Substitute User. Allowing you substitute the current uid and gid with that of "USER":

SU(1) User Commands SU(1)

su - run a shell with substitute user and group IDs

su [OPTION]... [-] [USER [ARG]...]

With no parameters, it defaults to root, but I use it quite often to substitute as a user if I need to do some things on behalf of the user. Of course, the most common use is to become root.


Other Ways

waparmley's picture

A couple of other ways to quickly get "superpowers." (Hey, wouldn't THAT be a cool nickname for Shawn Powers???"

The Ubuntu menu system includes "Root Terminal," although you need to enable it with Edit Menus, if I recall correctly.

In my installations I always create a launcher in the menus for "Root Nautilus" by using the command "gksudo nautilus". I very seldom resort to using this in the interest of system safety, but sometimes it's the quickest way to get something done.

My preferences for Nautilus include single click to select and small (67%) icons, so I leave root Nautilus set to double click and 100% size icons just to serve as a reminder that I'm operating as root and that I need to be extra careful!


susos's picture

sudo -s ?

An easier way....

Anonymous's picture

Use sudo -i for an interactive root shell.

two other commands that

groggyboy's picture

two other commands that accomplish the same thing are sudo su and sudo bash.

i added an alias to my bashrc file so that typing su actually executes one of those commands.


Shawn Powers's picture

Well look at that. I guess you can call me "LongForm McGee", since I apparently like to do things the long way.

Actually, maybe don't call me that. It'd be a weird nickname. :)

(Thanks for the tip though!)

Shawn Powers is a Linux Journal Associate Editor. You might find him on IRC, Twitter, or training IT pros at CBT Nuggets.

Nice video this

Salvadesswaran Srinivasan's picture

Well Shawn I like your columns in LJ and the best thing I've done this month so far apart from recompiling my kernel and downloading Ubuntu 9.04 (for testing and tweaking, what else!) is adding LJ on twitter. Keep on the good work.