Questions tagged [su]

su is a utility to run a shell or other command as another user (root by default).

su is a utility that runs a shell or a specified command as another user. By default, the other user is root, and su, with , is one of the two common ways of obtaining administrator privileges. Calling su usually requires typing the target user's password.

su originally stood for “super user” (it was only for running a root shell), and became later known as “substitute user” (or “switch user” or a number of similar backronyms) when it started accepting the target user name as an argument.

Further reading

537 questions
269
votes
8 answers

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 seems to be anyone (although you need the root…
Michael Mrozek
  • 91,316
  • 38
  • 238
  • 232
212
votes
4 answers

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
Dharmit
  • 4,220
  • 7
  • 28
  • 37
163
votes
4 answers

-bash: sudo: command not found

I am trying to deploy django app. When I print apt-get update I see W: Unable to read /etc/apt/apt.conf.d/ - DirectoryExists (13: Permission denied) W: Unable to read /etc/apt/sources.list.d/ - DirectoryExists (13: Permission denied) W: Unable to…
user2950593
  • 1,797
  • 2
  • 13
  • 9
139
votes
8 answers

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 About.com says: Gives a fake root environment. This…
gkt
  • 1,563
  • 2
  • 11
  • 7
133
votes
8 answers

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 than just using login on a text-mode console. There…
stribika
  • 5,374
  • 5
  • 30
  • 35
122
votes
3 answers

su vs sudo -s vs sudo -i vs sudo bash

What is the difference between the following commands: su sudo -s sudo -i 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 difference? I know there is a difference…
TJ Shah
  • 1,711
  • 3
  • 13
  • 13
115
votes
2 answers

su options - running command as another user

I was wondering how to run a command as another user from a script. I have the script's owner set as root. I also have the following command being run within the script to run the command as the hudson user: su -c command hudson Is this the correct…
myusuf3
  • 1,385
  • 3
  • 9
  • 9
91
votes
2 answers

Is there ever a good reason to run sudo su?

To launch a root shell on machines where the root account is disabled, you can run one of: sudo -i : run an interactive login shell (reads /root/.bashrc and /root/.profile) sudo -s : run a non-login interactive shell (reads /root/.bashrc) In the…
terdon
  • 234,489
  • 66
  • 447
  • 667
71
votes
6 answers

su does not change user but does not respond with an error either

While logged in as root I would like to su to a specific regular user. I run su username and immediately receive the prompt back, still as root. There is no error given. I'm aware of the old "the user you're trying to su to doesn't have permission…
Wesley
  • 13,963
  • 12
  • 35
  • 49
71
votes
9 answers

"su" with error "X11 connection rejected because of wrong authentication"

As root, I'm connecting to a remote host to execute a command. Only "standarduser" has the appropriate id-file and correct .ssh/config, so I'm switching the user first: su standarduser -c 'ssh -x remotehost ./remotecommand' The command works fine,…
Stefan M
  • 1,606
  • 1
  • 12
  • 20
53
votes
3 answers

.bash_profile not sourced when running su

I have a user, say user1, which has modifications to its .bash_profile, one of them changing the PATH, e.g.: export PATH=/some/place:$PATH. This change works fine if I log on as user1 or do a su - user1. But if I try to run a command via su as root,…
NullUser
  • 1,053
  • 4
  • 11
  • 19
53
votes
9 answers

Running GUI application as another (non-root) user

Let's say I have 2 user accounts user1 and user2. When I login as user1, and then switch to user2 using su, I can execute command-line programs, but GUI programs fail. Example: user1@laptop:~$ su - user2 user2@laptop:~$ leafpad ~/somefile.txt No…
sashoalm
  • 5,760
  • 11
  • 32
  • 47
50
votes
8 answers

How do I suppress dd output?

I have a bash script that creates some file using dd. The problem is dd throws a great amount of output that is going to mess with the output of my script. Searching around I've found a solution: dd if=boot1h of="/dev/r$temp1" >& /dev/null Is there…
dierre
  • 625
  • 1
  • 6
  • 9
49
votes
6 answers

how to pass environment variable to sudo su

I basically need to do this: DUMMY=dummy sudo su - ec2-user -c 'echo $DUMMY' This doesn't work. How can I pass the env variable $DUMMY to su? -p doesn't work with -l.
Umang
  • 593
  • 1
  • 4
  • 5
46
votes
6 answers

Why doesn't "sudo su" in a shell script run the rest of the script as root?

A sample script can be as below: #!/bin/bash sudo su ls /root When using ./test.sh as the normal user, instead run ls as super user and exit, it switches to root; and when I logout, it executes ls /root as the normal user. Can anybody tell me about…
Hongxu Chen
  • 5,828
  • 8
  • 27
  • 32
1
2 3
35 36