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

539 questions
15
votes
3 answers

How to run command as different user

Is it possible to run a command with parameters first of which starts with - (dash) e.g. /usr/bin/echo -n foo as different user and group, for example apache:apache using command su when login shell is set to /sbin/nologin ? I tried: su -s…
czerny
  • 1,657
12
votes
2 answers

Can't switch to a specific system account with su

I can't switch to user jenkins on an OpenVZ container. There is still a jenkins process running, which was started by this user. I tried # su jenkins; it does not switch to the jenkins user. There is no error message. /etc/groups shows there is a…
6
votes
2 answers

Is it possible to su without being prompted for a password?

I suspect su doesn't have any way to allow passing the password from the shell instead of being prompted for one, for security reasons (couldn't find anything in the MAN). Is this true?
ripper234
  • 31,763
6
votes
2 answers

Why doesn't su change the user ID of the shell from which it was run?

Instead, it starts a new shell process with the new user ID. The original shell is blocked until the new shell completes and su exits. Why does it work like this?
Bruce
  • 143
6
votes
3 answers

Find out if a session is running under `su`

I'm trying to check whether the current shell session is running within a su login session. What's the best way to test this condition?
Andrew Vit
  • 228
  • 2
  • 6
2
votes
3 answers

How to list users that have su'ed to different accounts

I'm trying to figure out a quick & easy way to see a list of everyone's effective user id... I would have thought 'w' or 'who' would be able to display if someone had switched user accounts... but it's only showing the real user ID they logged in…
Bodisha
  • 171
2
votes
3 answers

using here script I/O redirection with su command

here is my script. I want to login with another user and do ls -lih: #!/bin/bash su - testuser <<- _EOF_ 123456 #password _EOF_ ls -lih here is the output when i ran script: ./script.sh -bash: line 1: 123456: command not found total 127M …
Majid Azimi
  • 3,098
2
votes
1 answer

Differences between `su` and `su-to-root`?

There are other questions on this forums about the usage of su, su -, su root... etc. But I have found none about the su-to-root command, and I would like to understand the basics of its usage. I hope this example could be useful: on Kali Linux…
2
votes
1 answer

Impossible to execute a command by using su for another (system) user

I've created my user like this: sudo adduser --disabled-password --system --home /var/lib/deluge --gecos "Deluge server" --group deluge The content of /etc/passwd: deluge:x:110:114:Deluge server,,,:/var/lib/deluge:/bin/false The directory I'm in : …
Pontek
  • 23
1
vote
1 answer

su command with -p or -m flags

What is the difference between the following su commands? su -m su -p I know that both flags are used to preserve the current environment but I don’t know the differences if there are any.
Vombat
  • 12,884
1
vote
1 answer

Make su ask for the password multiple times

I'm using Debian 8 and when I enter su the password prompt appears only once. If I enter the wrong password I expect retry and immediately start typing again but then parts of the password are visible on the shell. How can I configure su to…
1
vote
1 answer

when to use "su -l loginname -c somecommand"?

I tend to use su - loginname -c somecommand. Any different having argument -l? That is su -l loginname -c somecommand?
0
votes
1 answer

I want to create a script so that I don't have to type su and password every time

I want to create a script so that I don't have to type su and the password for logging into root every time.
0
votes
2 answers

How can I return to my user's home directory after becoming root?

How can I switch from user to root? In my terminal I typed in su - and it took me to the root directory, so I need to go back to the user directory.
YINMII
  • 3
0
votes
0 answers

Ubuntu always change user

I have no idea what is the topic of my problem. I have to change the user using su user when accessing the server with ssh user@server The initial terminal shows just > without a user name (i.e., user@server >) before the change user (i.e., su…
wazz
  • 31
1
2