Log in

entries friends calendar profile The Pædantic Programmer Previous Previous Next Next
Installing sudo - The Pædantic Programmer's LiveJournal
Installing sudo
To install sudo on a debian or ubuntu system with a bash shell (this is likely you if you're reading this), change to the root user thus:

$ su -

Now that you have a "#" shell, all commands you run will be privileged. You don't want this. Trust me. Instead, you want to run most commands as your usual user and only use privileged commands when you have no other choice. To do this, I recommend installing sudo.

# apt-get install sudo

When this program finishes installing, and you are again presented with a "#" shell, do the last thing you will ever do from that shell. In the following example, "<your username>" represents the username of your non-privileged user.

# echo '<your username>  ALL=(ALL) ALL' >> /etc/sudoers
# visudo

Go to the bottom of the file and enter the following:
<your username>  ALL=(ALL) ALL

Save and quit.

If you substituted <your username> correctly, you will now be able to take advantage of sudo.

Log out of your root shell. Anything that you would normally run a root shell to execute, now execute by appending it to "sudo ".

Any questions?

Tags: , , ,
Current Music: Kim

5 comments or Leave a comment
ydna From: ydna Date: July 27th, 2005 03:43 am (UTC) (Link)
And note that when you are prompted for a password, it's <your username>'s password that is being requested to run commands with sudo.

Another benefit of using sudo is that you get a nice detailed log of what sysadmin things you've done.

sudo grep sudo /var/log/auth.log
From: (Anonymous) Date: August 10th, 2005 04:27 am (UTC) (Link)

The only way to edit the sudoers file is by using 'visudo'

> # echo ' ALL=(ALL) ALL' >> /etc/sudoers
> If you substituted correctly, you will now be able
> to take advantage of sudo.

There is a reason that the top of the sudoers file says "This file MUST by edited with the 'visudo' comamnd as root" ! To quote the sudoers man page:

"The sudoers file should always be edited by the visudo command which locks the file and does grammatical checking. It is imperative that sudoers be free of syntax errors since sudo will not run with a syntactically incorrect sudoers file."

If you substituted INcorrectly then you've completely stopped sudo from working, system wide. This will be avoided by actually using the tools as they're intended.
cjcollier From: cjcollier Date: August 10th, 2005 04:50 am (UTC) (Link)

Re: The only way to edit the sudoers file is by using 'visudo'

Good point. Thank you.
From: (Anonymous) Date: December 22nd, 2005 11:33 pm (UTC) (Link)

sudo su

or like on any mac: sudo su
cjcollier From: cjcollier Date: November 4th, 2008 06:36 pm (UTC) (Link)

Re: sudo su

FTLOG, no.

Don't use root shells. they're bad. run elevated commands with sudo
5 comments or Leave a comment