sudo - Execute a command with superuser privileges.

learn more… | top users | synonyms

44
votes
5answers
4k views

Redirecting stdout to a file you don't have write permission on

When you attempt to modify a file without having write permissions on it, you get an error: > touch /tmp/foo && sudo chown root /tmp/foo > echo test > /tmp/foo zsh: permission ...
38
votes
4answers
22k views

How do I run a command as the system administrator (root)

I need to run a command with administrative privileges. Someone said I should run a command as root. How do I do this?
32
votes
7answers
45k views

How to run a specific program as root without a password prompt?

I need to run something as sudo without a password, so I used visudo and added this to my sudoers file: MYUSERNAME ALL = NOPASSWD: /path/to/my/program Then I tried it out: $ sudo ...
86
votes
7answers
12k views

Which is the safest way to get root privileges: sudo, su or login?

I would like to have the root account in safety even if my unprivileged user is compromised. On Ubuntu you can only use sudo for "security reasons" by default. However I am not sure it is any safer ...
50
votes
3answers
3k views

How do the internals of sudo work?

How does sudo work internally? How is it possible that it can become root without having the root password, unlike su? What syscalls, etc. are involved in the process? Is it not a gaping security hole ...
17
votes
2answers
9k views

su vs sudo -s vs sudo bash

What is the difference between the following commands: su sudo -s sudo bash I know for su I need to know the root password, and for sudo I have to be in the sudoers file, but once executed what is ...
9
votes
2answers
3k views

When do su and sudo use different passwords?

I am able to run anything using sudo; my password is accepted. But whenever I try to do su from a shell, it fails with: su: incorrect password What can the problem be?
82
votes
6answers
25k views

Where did the “wheel” group get its name?

The wheel group on *nix computers typically refers to the group with some sort of root-like access. I've heard that on some *nixes it's the group of users with the right to run su, but on Linux that ...
7
votes
3answers
3k views

Copying protected files between servers in one line?

I'd like to copy squid.conf from one server to another. The servers don't talk to each other. I'd like to go through my workstation. Both servers have the file, so it will be overwritten on the ...
6
votes
5answers
519 views

Set sudo password differently from login one

As a privileged user I am trying to set the sudo password to another then the one used at login. I have done some research but have not found an answer. Does sudo support that kind of configuration? ...
60
votes
19answers
9k views

Root access that can't change root password?

We are having a little problem on a server. We want that some users should be able to do e.g. sudo and become root, but with the restriction that the user can't change root password. That is, a ...
37
votes
5answers
3k views

Becoming root from inside Vim

Sometimes I start editing configuration files in /etc using Vim, but forget to use sudo to start Vim. The inevitable result then is that after finishing my edits I encounter the dreaded notice that I ...
23
votes
4answers
47k views

How to make Fedora user a sudoer?

I want to give a Fedora user sudo privileges. How do I do that?
10
votes
1answer
23k views

How to add a user to sudoers file?

I have an account named as Chankey (local user). I had to use some commands like viewing the shadow file etc. I tried it using sudo command sudo vim /etc/shadow It said: Chankey is not in ...
18
votes
2answers
2k views

How can I `alias sudo !!`?

I'm trying to set an alias for sudo !! in Bash. I tried alias sbb='sudo !!', but it interprets that as a literal !! and prints sudo: !!: command not found If I use double quotes, it substitutes ...
8
votes
2answers
328 views

How do I edit a file as root?

Are there any special considerations to editing a file as root? What is the safest way to do this?
14
votes
1answer
1k views

What's the difference between sudo su - and sudo su --

When I am working on our RHEL machines, I use sudo su - to switch to being root. One day, a typo meant I typed sudo su -- instead - it seems to me that everything was the same as with a single hyphen, ...
9
votes
3answers
2k views

Execute a line of commands with one sudo

For example if I want to create a file and enter text in one line I can redirect the output into a file with the use of the > operator: echo "something" > /path/foobar but if I don't have ...
7
votes
4answers
2k views

sudo permission denied but su grants permission

this is the first occurrence where su was required for me. I read an article about changing the value in /sys/devices/virtual/backlight/acpi_video0/brightness to alter my laptop's screen brightness. ...
2
votes
3answers
640 views

What mechanism prevents any user from accessing any other user's files via root?

On a multi-user system, what protects against any user accessing any other users files via root? As context, the question is based on my understanding as follows: There are two commands related to ...
33
votes
3answers
24k views

Why do I need a tty to run sudo if I can sudo without a password?

I have configured sudo to run without a password, but when I try to ssh 'sudo Foo", I still get sudo: sorry, you must have a tty to run sudo. Why does this happen and how can I work around it?
19
votes
3answers
7k views

How is sudo intended to be used?

I've tried configuring sudo before, but I haven't had too much luck with it. How is it different from su -l -c "x"? It seems that via the configuration file, one can make it so a user can only have ...
13
votes
2answers
6k views

What is the proper sudoers syntax to add a user?

According to the comments in /etc/sudoers (Fedora 13): ## Syntax: ## ## user MACHINE=COMMANDS ## ## The COMMANDS section may have other options added to it. My two related questions: What ...
7
votes
3answers
12k views

How to get back sudo on Ubuntu?

I have done this: sudo chown -R myname /usr/ and now I can't use the sudo command because of this error: sudo: must be setuid root And as I read this means that the owner of this file ...
6
votes
3answers
13k views

How to restrict to run commands in specific directory through SUDOERS?

I can configure sudo (via the sudoers file) to allow a user to run the chown and chmod commands on any file or directory in the system. However, I only want to grant a user permission to run these ...
4
votes
1answer
171 views

Keeping sudo authentication with gnome-terminal

Can sudo sessions be shared across tabs of gnome-terminal, so that once I use sudo in one tab, I won't have to re-enter my password every time I open another tab and use sudo?
14
votes
4answers
450 views

What specific vulnerabilities am I creating by disabling the sudo password?

Here are some instructions on how to disable your sudo password. These carry the following warning If you disable the sudo password for your account, you will seriously compromise the security of ...
7
votes
1answer
97 views

How does the Linux desktop perform system actions?

The Linux desktop can perform several actions which is otherwise not available to the user when logged in from a terminal. Actions such as system shutdown, and changing system time are accessible only ...
6
votes
4answers
2k views

Why can't we execute a list of commands as different user without sudo?

This question has been asked in a different way in other forums. But there has not been a decent explanation why you can't do the below in bash. #!/bin/bash command1 SWITCH_USER_TO rag command2 ...
5
votes
1answer
5k views

Allowing a user to use sudo without a password

On a sandbox VM environment, I have a setup of Ubuntu Linux which is firewalled and cannot be accessed from outside the local system. Therefore, on that VM, I'd like to give the administrative user ...
4
votes
2answers
907 views

System Crontab or Root Crontab

System crontab: /etc/crontab Root crontab: sudo crontab -u root -e Which way is preferred? As they all run tasks within administration privilege.
3
votes
1answer
511 views

Copy a local file to a remote server, non-root privileges over sudo?

I'd like to do something like: scp local_file remote_server:/some_directory But in order to gain privileges to /some_directory, we need to call sudo. I know that a similar question had already been ...
2
votes
5answers
9k views

How to start a program in the background

The program Boblight does not run in background. There is no noticeable difference between executing sudo boblightd and sudo boblightd& How can I solve this problem that the console will ...
8
votes
3answers
2k views

How do you process an entire command as sudo that involves redirecting or piping?

I am trying to follow what I assume is best practises of using sudo instead of root account. I am running a simple concat file operation such as: sudo echo 'clock_hctosys="YES"' >> ...
8
votes
2answers
9k views

using sudo on GUI applications

When I was using kubuntu, I could always open X applications with sudo, sudo kate for example. Now that I've switched to arch that doesn't work. I know I've always been told to use kdesu, but what ...
6
votes
1answer
3k views

Why can't sudo redirect stdout to /etc/file, but sudo 'nano' or 'cp' can?

Why does redirection, using sudo give me an error for the following commands? $ sudo printf "foo" >/etc/file bash: /etc/file: Permission denied $ sudo printf "foo" ~/file; cat ~file ...
3
votes
1answer
290 views

How to use SCSUDO to run scripts with positional parameters?

I am trying to use scsudo to run a number of defined commands to stop and start processes on a UNIX host. The issue I am experiencing is that scsudo does not seem to like the use of positional ...
1
vote
2answers
3k views

How can I scp a file that my user can't read but I can sudo?

Can I use scp to copy a file from a remote server which my login user can't read, but where I have permission to sudo to root (without password even)? How?
0
votes
4answers
10k views

Is there a difference between sudo su - root and sudo -u root -H /bin/bash?

Like title says, is there a difference between these two commands : sudo su - root sudo -u root -H /bin/bash I'm using GNU/Linux, if that makes a difference.
28
votes
6answers
18k views

What is the need for `fakeroot` command in linux

Why do we need fakeroot command at all? Can't we simply use the sudo or su commands? The man page says: fakeroot - run a command in an environment faking root privileges for file manipulation ...
43
votes
2answers
4k views

Why do we need to use visudo instead of directly modifying the sudoers file?

I understand that if you want to modify who can use sudo and what they can do with it that you should use visudo. I know I'm not supposed to directly modify the /etc/sudoers file myself. What is it ...
12
votes
2answers
2k views

How to safely pass variables to root-enabled scripts?

This question is totally general and not only applicable to my situation, but... I have a small busybox appliance where I want a non-root user to be able to execute a particular script with root ...
12
votes
2answers
2k views

zsh wants to correct vim to .vim

I'm using zsh on Gentoo x64, and when I type sudo vim /path/to/file from my home folder, zsh asks: zsh: correct 'vim' to '.vim' [nyae]? I want to run vim not my .vim folder. How do I fix this? ...
15
votes
2answers
1k views

Is sudo not installed by default in Debian?

I was reading a guide to install some software and came reading until this shocking statement: sudo is not installed on Debian by default. Make sure your system is up-to-date and install it. As ...
9
votes
1answer
13k views

Is it okay to disable requiretty?

I'm trying to set up a deploy script using Capistrano At a step cap deploy:setup script is connecting to my server and trying to run commands that create directories. Then I see an error: msudo: ...
3
votes
4answers
1k views

Detach a daemon using sudo?

I noticed that sudo continues to run after executing any of the following lines. Is there any way to detach the daemon completely so sudo does not continue running? sudo -u user daemon & sudo -u ...
12
votes
3answers
11k views

Does mount always require root privileges?

I was under the impression that any sort of call to mount requires root privileges. But recently I was told "You should instead create appropriate entries in /etc/fstab so that the filesystems can be ...
6
votes
3answers
5k views

How to make `sudo` preserve $PATH?

I need to run a program installed on /opt/godi/sbin (a custom directory). If I add that directory to my PATH, by adding the following line to my .bashrc file export ...
5
votes
10answers
12k views

How to log commands within a “sudo su -”?

If I: [user@notebook ~] sudo echo 123456uu 123456uu [user@notebook ~] Then I can see that in the logs: [root@notebook /var/log] grep 123456uu * auth.log:Jan 9 17:01:51 notebook sudo: user : ...
18
votes
4answers
1k views

How universal is sudo?

I was writing some instructions on how to install something (TeX-related - if you don't ask, I won't ruin your day by supplying more details) and used sudo to install system-wide. Someone commented ...