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

Comments

Comment viewing options

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

su

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 -

than

#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).

Thomas.

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 name...lol).

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)

NAME
su - run a shell with substitute user and group IDs

SYNOPSIS
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.

Cheers!

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!

another

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.

Huh.

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 an Associate Editor for Linux Journal. You might find him chatting on the IRC channel, or Twitter

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.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix