The "substitute user" Unix command that changes the current user
Questions tagged [su]
188 questions
140
votes
2 answers
What's the difference between "su" with and without hyphen?
I'm quite new to Linux terminal and I'm not quite sure what the difference between su with a hyphen and su without a hyphen is, for example: su - username vs. su username.
I looked into the documentation but in there, this was not mentioned. Could…
user574183
- 1,519
67
votes
3 answers
Command: sudo su -
I understand what su - does
logs you into root with the root environment
(as opposed to su which logs you into root with your environment)
And I understand what sudo does
you are root for one command
But I am unsure what this does: sudo su…
sixtyfootersdude
- 8,449
54
votes
2 answers
Where did the term "superuser" originate?
Where did the term "superuser" originate? Is it a shortening of "supervisory user", or is it just an indicator of the level of power one such user holds in a system?
VortixDev
- 1,214
24
votes
6 answers
Can't write to file /sys/class/backlight/acpi_video0/brightness (ubuntu)
I am trying to change the brightness by overwriting the value on this file:
sudo echo 5 > /sys/class/backlight/acpi_video0/brightness
-bash: /sys/class/backlight/acpi_video0/brightness: Permission denied
It doesn't work even when using sudo.…
Kei Nivky
23
votes
3 answers
Sudo su vs su linux
If I enter in the password to su when prompted, it doesnt work while sudo su does. Also, when a command is executed using sudo (command), does sudo automatically execute it by root by default (since the man page says sudo, sudoedit - execute a…
agz
- 8,438
19
votes
1 answer
How to create symbolic links in /usr/bin on a Mac?
Environment: OSX Sierra, Darwin Kernel Version 16.3.0
Root Problem: I want to use a bunch of shell scripts in a central repository, which have a #!/usr/bin/zsh. On my Mac, the zsh is in /bin/zsh.
Attempted solution: I want to create a symbolic…
user1934428
- 980
14
votes
2 answers
Difference between su -c and runuser -l -c
I need to run some command lines as particular user in a shell script.
I've found (at least) two way:
su user -c 'command'
runuser -l user -c 'command'
Is there a significant difference between this two commands?
Getz
- 343
- 3
- 4
- 15
11
votes
4 answers
Is it possible for root to execute a command as non-root?
I am a root user, and suppose I want to run any application as another user. Is this possible, without switching to another user?
Something like
# google-chrome user=abc
I am actually executing a CLI program as a non-root user. I have set the…
adnan kamili
- 481
10
votes
1 answer
script to su with password in script without root
I have scripted a process that involves updating symbolic links on files located on 3 different machines. On those machines exists 4 users each, who each need to have these links updated.
Using su, is there a way to pass the password argument to the…
Triplell89
- 235
10
votes
2 answers
Switch user in Windows command line
Is there a similar Linux su command in Windows command line?
If not, what about:
in Powershell?;
a workaround with a *.vbs script?;
a workaround with some of the sysinternals tools like "psexec.exe"?
Note: I am using a netcat remote shell…
f4d0
- 233
9
votes
4 answers
Accessing an exit code outside of a su -m $USER -c ""
The below command prints "0" or "1" correctly depending on failure or not because i put $? inside the "su" command.
sudo su -m $USER -c "./shutdown.sh &> /dev/null; echo \$?"
However, if i do this:
sudo su -m $USER -c "$BASE/bin/shutdown.sh &>…
Nick
- 535
8
votes
1 answer
Debian - allow user to be root only for specific commands
We have several Linux boxes running Samba that are used 'locally', eg each branch gets their own Samba box to store and share files.
The office managers need to be able to add and remove users for their branch and need to be root for this action…
Jake
- 416
- 5
- 13
8
votes
3 answers
use gnu screen when ssh'ed as a user, but su as another
Below is what happens when trying to use gnu screen. Essentially, it all works fine until I su as another user. then I get a Cannot open your terminal '/dev/pts/7' - please check. error
l413:~$ ssh sbird@example.com
sbird@example.com password:…
Alexander Bird
- 1,887
8
votes
6 answers
Allowing automatic command execution as root on Linux using SSH
What is a good setup that allows automatic execution of a command or a script on a remote server with root privileges using SSH?
I'm aware (only vaguely for some the options) of the following options:
Allowing a direct login by root…
Martin Prikryl
- 24,007
7
votes
5 answers
Automating the "sudo su - user" command
I want to automate
sudo su - user
from a script. It should then ask for a password.
sam
- 101