Questions related to the sudo command that allows users to run programs with the privileges of a different user (normally the root user).

learn more… | top users | synonyms (1)

276
votes
5answers
778k views

How can I add a new user as sudoer using the command line?

After I add a user using adduser, I can't see it via System->Administration->Users and Groups unless I logout and then login again. Is that normal? Also, can I set a newly added user as a ...
89
votes
10answers
107k views

Error message when I run sudo: unable to resolve host (none)

I have this issue on AWS on some servers. Whenever I run sudo the terminal is stuck doing seemingly nothing, until it finally spits out this error message. My terminal looks like this: ...
79
votes
12answers
100k views

How to modify a invalid /etc/sudoers file? It throws out an error and not allowing me to edit again

How do I edit an invalid visudo file? Here is what happens: $ sudo visudo >>> /etc/sudoers: syntax error near line 28 <<< sudo: parse error in /etc/sudoers near line 28 sudo: no ...
72
votes
5answers
135k views

How do I add a user to the “sudo” group?

In /etc/sudoers I see this: # Allow members of group sudo to execute any command after they have # provided their password # (Note that later entries override this, so you might need to move # it ...
70
votes
8answers
26k views

How to avoid using sudo when working in /var/www?

I want to stop having to use sudo everytime I work in /var/www. How can I do that? I simply want to put all of my sites into this directory and work with them without too much pain.
69
votes
9answers
6k views

Run same command again but as root

Sometimes when I run a command I don't notice that I needed to run it as super user to have enough permission. Is there a way to run the same command again but as a super user?
68
votes
4answers
82k views

How do I sudo a command in a script without being asked for a password?

I want to turn my system on automatically every day. So I use the below code in my Python script, but sudo asks me for a password every time: os.system('sudo sh -c "echo date \'+%s\' -d \'+ \ ...
58
votes
1answer
65k views

How do I run specific sudo commands without a password?

On one particular machine I often need to run sudo commands every now n then. I am fine with entering password on sudo in most of the cases. However there are three sudo commands I want to run ...
54
votes
7answers
3k views

Can sudo be reinstalled after being removed?

This seems to be a chicken-egg problem. The most common task using sudo is installing and removing software. sudo apt-get purge <appname> But sudo itself can be removed. sudo apt-get purge ...
54
votes
8answers
25k views

What is the difference between “gksudo nautilus” and “sudo nautilus”?

I've been using gksudo nautilus and sudo nautilus through Alt+F2. What's the difference? They look very similar!
49
votes
4answers
328k views

How do I start/stop mysql server?

I try find in internet some article where describe how correct start -stop mysql server. I find this article: How to start/stop MySql server on Ubuntu 8.04 | Abhi's Blogging World I run this ...
48
votes
6answers
3k views

What does `!!` mean in `sudo !!`?

I am a user of Ubuntu with not much experience and I have been using sudo. What does sudo !! do and how?
48
votes
3answers
89k views

How to run sudo command with no password?

How does the ubuntu user on the AWS images for Ubuntu Server 12.04 have passwordless sudo for all commands when there is no configuration for it in /etc/sudoers? I'm using Ubuntu server 12.04 on ...
46
votes
4answers
73k views

Execute sudo without Password?

Inspired by this question.... I am the sole person using my system with 12.04. Every time I issue a sudo command; the system asks for the user password (which is good in its own way). However I was ...
44
votes
3answers
9k views

When to use pkexec vs. gksu/gksudo?

There are two general ways to run applications graphically as root (or, more generally, as another user). Programs like gksu, gksudo, and kdesudo are graphical frontends for sudo. In contrast, pkexec ...
43
votes
5answers
11k views

When using sudo with redirection, I get 'permission denied'

When using sudo to allow edits to files, I regularly get 'permission denied'. For example, my mouse is jittery and sluggish, so I want to disable polling: sudo echo "options drm_kms_helper ...
43
votes
3answers
16k views

What is the difference between the 'sudo' and 'admin' group?

I noticed that two groups are granted similar-looking permissions in /etc/sudoers: # Members of the admin group may gain root privileges %admin ALL=(ALL) ALL # Allow members of group sudo to execute ...
40
votes
0answers
10k views

How can I determine whether a shellscript runs as root or not? [duplicate]

Possible Duplicate: How can a script check if it’s being run as root? This is something I've been curious about. I make a lot of small bash scripts (.sh files) to do tasks that I routinely ...
38
votes
4answers
7k views

Why do we need to be root in terminal for shutdown and restart?

When we install/remove/update packages or make any changes which require administrative privileges we are prompted for the password of admin user who has the sudo privileges - this happens both via ...
38
votes
2answers
4k views

Why user should never use normal sudo to start graphical application?

I've read the comunity "RootSudo" documentation and am interested in this line: You should never use normal sudo to start graphical applications as Root. Why? What is the difference? Please ...
36
votes
3answers
5k views

What are the differences between sudo, su, visudo, chroot, and gksu?

What are the differences between sudo, su, visudo, chroot, and gksu ?
35
votes
2answers
9k views

Aliases not available when using sudo

I was playing around with aliases today and I noticed that aliases don't seem to be available whilst using sudo: danny@kaon:~$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' ...
34
votes
5answers
68k views

Difference between “su”, “sudo -s”, “sudo -i”

I already read it from manual but I can't see difference.. su - change user ID or become superuser sudo -s [command] The -s (shell) option runs the shell specified by the SHELL environment ...
33
votes
1answer
41k views

'sudo su -' vs 'sudo -i' vs 'sudo /bin/bash' - when does it matter which is used, or does it matter at all?

When I'm doing something that requires root be typed in dozens of times in a row, I prefer to switch my session to a root session. In the various tutorials and instructions I have used on the ...
29
votes
4answers
152k views

How do I grant sudo privileges to an existing user? [duplicate]

I want to grant a newly created user sudo privileges in Ubuntu. I tried sudo adduser hduser admin but it says no admin group exists. How can I do it?
27
votes
5answers
7k views

How to NOT become a root user? Are administrators root?

I installed Ubuntu on my PC. To log in, I use the username and password I created during installation. Does this mean I am a root user? If yes, then how do I become non-root? It looks like non-root ...
27
votes
2answers
19k views

after upgrade gdb won't attach to process

I just recently upgraded from 10.04 to 11.04 and gdb won't allow me to attach to processes anymore I get the error Attaching to process 10144 Could not attach to process. If your uid matches ...
25
votes
4answers
9k views

How to get out of “sudo -s” command in Terminal?

I entered sudo -s command in terminal, and the it changed from shameek@shameek-K55VD:~$ to root@shameek-K55VD:~#. Now when I click on the close terminal window icon it says, "There is still ...
25
votes
5answers
5k views

What's wrong with using sudo?

In a comment here I've been told that unnecessarily using sudo should be avoided. While it wasn't needed in that particular case, I don't see any harm in using it. I think that when executing trivial ...
25
votes
3answers
13k views

Why doesn't `sudo cd /var/named` work?

I want to cd into /var/named but it gives me a permission denied error, and when I want to use sudo to do this I am not permitted. What is the technical reason for this, and is it possible to do this ...
25
votes
3answers
16k views

How do I add myself back as a sudo user?

I clean-installed Ubuntu 11.10 today, and then installed VirtualBox. This required me to add myself to the vboxusers group, and since 11.10 seems to no longer have a graphical app to add users to a ...
25
votes
3answers
37k views

How do I sudo without having to enter my password?

I'm trying to setup sudo without no password but still I get prompted for password, I'm using ubuntu, here is the relevant line from the sudoers configuration file : gandalf ALL=(ALL:ALL) NOPASSWD: ...
23
votes
8answers
6k views

Why it is sudo?

Why we use sudo to perform a terminal command as an administrative, why it isn't admin or something else, is there a reason for sudo?
23
votes
1answer
34k views

Why is sudoers NOPASSWD option not working?

I have a NOPASSWD line in /etc/sudoers (edited with visudo) gatoatigrado ALL=(ALL) NOPASSWD: /bin/set-slow-cpufreq However, the output is, gatoatigrado@coral:~> sudo -n /bin/set-slow-cpufreq ...
23
votes
6answers
33k views

sudo error, is mode 0777, should be 0440

I am getting sudo errors, how do I fix this error? sudo: /etc/sudoers is mode 0777, should be 0440 sudo: no valid sudoers sources found, quitting
23
votes
3answers
6k views

Redirect the output using `sudo` [duplicate]

I have a small question regarding using sudo with output redirect >. To enable IP forwrding, someone can use the command: echo 1 > /proc/sys/net/ipv4/ip_forward Executing this command will ...
23
votes
5answers
48k views

How to launch application as root from Unity Launcher?

Mainly I am looking for a way to pin an application to the Unity launch bar, and run it as root. Currently, even if I start the application with sudo, and pin it after it starts, it will start as ...
19
votes
6answers
34k views

How to run an application using sudo without a password?

... but still be required for applications that need admin privilegies? In order to allow the following: $ apache2ctl restart httpd not running, trying to start (13)Permission denied: make_sock: ...
18
votes
3answers
20k views

Shutdown from terminal without entering password?

I have desktop edition of Ubuntu. I like the Terminal so that that I prefer to shutdown my computer with the shutdown command. However when I type shutdown now it prompts me to enter my password.Is ...
17
votes
2answers
10k views

Why don't I have a password for “su”? Problems with “sudo”

I have installed Ubuntu using the GUI, giving myself a password and everything. I do not intricately remember the process. However, what worries me is that I don't know the following password: $ su ...
17
votes
2answers
112k views

I want to copy a directory from one place to another via the command line

I want to copy a directory from one place to another folder. sudo cp is the command, but after that what should I type? The destination or source first?
17
votes
4answers
7k views

Is the difference between sudo and gksu the same as the difference between sudo -i and sudo -s?

Is the difference between sudo cmd and gksu cmd, the same as the difference between starting a shell with sudo -i and sudo -s? ... or put another way, Is sudo cmd the same as sudo -i cmd and gksu ...
16
votes
7answers
5k views

Nothing shows up in the terminal when I type my password

When I'm about to install a program in the terminal it wants the password: [sudo] password for xxx: But when I want to type my password it happens nothing. What should I do?
16
votes
1answer
1k views

What does su > echo “<username>” mean?

When I was entering the command su > echo "sachin" it was asking for a password. When I gave my password, some strange things happened as you can see: One more thing: there is another user, ...
15
votes
2answers
8k views

warning message at command line `sudo`

Everytime I try to sudo something at the terminal, I get a warning message: alexandre@XPS-15Z $ sudo mount file.iso /mnt/ -o loop [sudo] password for alexandre: no talloc stackframe at ...
15
votes
1answer
31k views

Run a shell script as another user that has no password

I would like to run a script from the main ubuntu shell as a different user that has no password. I have full sudo priviledges, so I tried this: sudo su -c "Your command right here" -s /bin/sh ...
15
votes
9answers
17k views

How to run an Application as another user?

I use krusader for file management stuff. the problem is that apache's DocumentRoot should be under chown www-data:www-data /path/to/www. so using krusader (which is run under my account) I've not ...
15
votes
5answers
10k views

su command + authentication failure

I am having problems with the su command. I know my password and I am typing it correctly but su indicates authentication failure. So I checked on the internet and then went into recovery mode and ...
15
votes
1answer
10k views

“sudo cd …” one-liner?

Occasionally I want to cd into a directory where my user does not have permission, so I resort to sudo. The obvious command sudo cd somedir doesn't work: $ sudo mkdir test $ sudo chmod go-rxw test $ ...
15
votes
3answers
48k views

My main username is not in the sudoers file

I was trying to install some software/edit files with my main username(not root) But I got this error [X] is not in the sudoers file. This incident will be reported. I tried to edit the /etc/sudoers ...