I've followed a couple of tutorials on my RPi and a lot of commands start with sudo
; what does it mean and what does it do?

- 15,530
- 14
- 67
- 113
-
Meta Question: http://meta.raspberrypi.stackexchange.com/questions/97/to-sudo-or-not-to-sudo – Alex Chamberlain Jun 14 '12 at 11:43
-
7This is a great question, I can imagine a lot of beginners wanting information on this. – berry120 Jun 14 '12 at 11:44
-
@berry120 yes but it would have been more suited to Unix/Linux SE because people run their Pi's on other OSes as well (I'm looking at you, RISC OS!) – evamvid Apr 06 '14 at 00:22
-
Whaaaat? Year-Old Question! make that 2 years! – evamvid Apr 06 '14 at 00:23
-
@evamvid This was one of the first example questions on RPi.SE... – Alex Chamberlain Apr 06 '14 at 10:13
-
@AlexChamberlain I didn't know that...Also I didn't notice that OP had tagged it Debian (in which case it's better suited). I guess there's a bit of an overlap... – evamvid Apr 06 '14 at 14:35
2 Answers
sudo
stands for Super User Do; it allows you to run as another user, usually the super user (root
), to carry out administrative tasks, such as update the software, change filesystems, and start daemons.
root
has the ultimate power and can run pretty much anything. It can, therefore, do a lot of damage to your system and in the worst case, you will have to start again.
You must always understand what a command is doing before you run it.
Why do we have sudo
?
For security reasons, normal users can't do everything. It prevents you doing anything too bad by accident and prevents malicious users damaging the system.
Why don't we sign in as root
when we want elevated permissions?
sudo
allows administrators to control what commands each user can run as root
. For example, your administrator may allow you to run apt-get
as root
, but nothing else. Furthermore, all commands run via sudo
are logged in /var/log/auth.log
.
Other Distributions
The default Debian image has sudo
installed in advance, but others may not. You can often install it using the distributions package manager, or investigate other ways of gaining root permissions.
Arch
You can install sudo
using pacman
: run pacman -S sudo
as root
. You should then add a new user and disable the root
account.
su
In Arch Linux (and other distributions that support it), you can use su
(substitute user) command to assume the identity of any other user (including root
). This means that all your future commands (in the current session) will have their permissions. However, you will require the their password and the commands you run won't, necessarily, be logged.
See also:

- 15,530
- 14
- 67
- 113
-
1Do you think information on
su
might be useful to really complete the answer? – Alex L Jun 14 '12 at 14:38 -
-
Further to this, I tend to write "sudo bash" as soon as I load my pi to avoid having to type sudo all the time. This lets you run everything with super user privileges. This is obviously a little dangerous, but with the rpi there is little majorly bad that you can do. – phalt Jun 14 '12 at 15:50
-
1
-
1
-
You can use
su
to switch to any user, not just root. Eg, if you are logged in as root, you can su to a less privileged user temporarily to do something risky. If you aren't root, however, you need the password of the user you want to su to. – goldilocks Apr 07 '13 at 14:38 -
You usually use it to execute a particular command as root, rather than your current user. For security reasons the norm in the Linux world is for your main user to have limited privileges, and for you to switch to root whenever you need to do something you don't have privileges for (such as installing packages.)
Root is a bit like administrator in the Windows world - it's your ultimate "can-do-anything" user.