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

learn more… | top users | synonyms

1
vote
0answers
38 views

What command should I use to explicitly set list of groups and execute a command?

To execute a command as other uid, one uses su. The list of supplementary groups is not specified on command line, but instead read from configuration files (/etc/passwd, /etc/group), etc. Which tool ...
0
votes
2answers
149 views

Fedora 23 password only showing 5 characters. Issues using su command

Today I installed Fedora 23, and once I finished I had no problems the SU command. I rebooted my VM and logged in, and it wont let me use the SU command. When I enter it, it asks for my password. So I ...
1
vote
1answer
170 views

want to su without password inside shell script

I have written a script which will run a script for a backup before: # cat backup-before-shutdown #Scritp to take backup before shutdown #Author Ashish Karpe echo "Taking backup to s3" su ubuntu /...
2
votes
3answers
2k views

How can I sudo su and change directory just after?

I would like to create an alias that does something like this: alias userYYY='sudo su userYYY; cd /a/path/that/only/userYYY/has/access' So then from my command line, I am logged in with a sudoer ...
1
vote
0answers
136 views

Slow script execution

I have a strange problem... My script: #!/bin/bash SECONDS=0 lock_file=/tmp/$0.lock [ -e $lock_file ] && exit touch $lock_file echo "<<<db2_hadr_check>>>" instances=( ...
1
vote
3answers
245 views

Fedora: How can I add myself back to sudoers file?

I've accidentally removed myself from sudoers file by doing usermod -G user group without -a, and now I am not in the sudoers group. I've tried doing su - and entering root's password but it says su: ...
1
vote
0answers
58 views

Linux/CentOS - can't su after changing ownership

I mistakenly changed ownership of all files on a CentOS system from root to my login account. I can login but if I su I get: su: cannot set groups: Operation not permitted I don't need the system ...
1
vote
2answers
5k views

Problem executing command as a different user with sudo -u

I have the following problem: When I'm trying to execute ls as user abc with the following command I get an error: xyz@host:~/temp$ sudo -u abc ls [sudo] password for xyz: Sorry, user xyz is not ...
41
votes
2answers
19k views

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 ...
1
vote
2answers
146 views

How do I fix my /etc/sudoers file to recognise me?

Currently, I am receiving the following terminal error: sudo: parse error in /etc/sudoers near line 10 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin I have ...
14
votes
7answers
11k views

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 ...
0
votes
1answer
82 views

Set root password AMI linux

I need to set a password for root on EC2 AMI Linux. I have tried with passwd root but if I log in with ec2-user and run sudo su, I get a root bash without asking for a password.
1
vote
1answer
149 views

Bash script with (X)dialog asking for root password (kdesu substitute)

I'm using (X)dialog for a script that a normal runs, but it needs root privileges for some commands. The script runs from a .desktop file, thus the user sees no terminal. For example here #!/bin/bash ...
-1
votes
2answers
323 views

When in debian 8.1 why is the super user run with su not sudo? [closed]

I am curious why the super user command su is run and not super user do (sudo).
0
votes
1answer
210 views

Valid root/user passwords not working on EC2

There is an authentication failure when I'm trying to enter password for any of my accounts after an update using yum. My authentication got broken, while everything else works. The updates were ...
0
votes
0answers
63 views

Why use use su -c to start background processes?

After reading Link im under the impression that using su -c with & would be redundant. My reasoning is that any process started with su -c will be started in a new shell but it will not be killed ...
1
vote
1answer
101 views

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. ...
1
vote
1answer
37 views

Make superuser act like some other user in certain directory tree

I have the following problem: My home directory lies on the network and is mounted locally on home/<my username>. I can access it with my normal user account <my username>, but as root, I ...
8
votes
2answers
29k views

How can I run as another user?

This is the bash code that should be runned. So first it substitutes the user to openproject and than runs all the code su openproject -c "bash -l" cd ~/openproject git checkout Gemfile.lock git ...
0
votes
1answer
106 views

What's wrong with exit command on my terminal?

I'm using Linux Mint 17.2 Cinnamon, and I'm a beginner, just switched over from Win10. Somehow, the exit command isn't working, could somebody help me out?
0
votes
2answers
1k views

`su` command: Permission denied

When I type into bash the following command su -s /bin/bash as root, then no error occurs. When I type su -s /bin/bash -m [MyUserName], then I get the error: Permission denied. As far as I could ...
0
votes
1answer
92 views

Is it possible to execute a command as another user without sudo su'ing to that user?

I do a lot of administration in CentOS6 for several teams. One of the more frequent things I do is sync down and package code as the team account, before deploying it out under my own account. Is ...
1
vote
4answers
147 views

What's the difference between sudo su vs just su?

I see a lot of posts out there that say you type in sudo su to get an interactive prompt with root privileges, and I see equally many posts debating the pros and cons over sudo -i vs sudo su. Here I'...
2
votes
0answers
35 views

Slackware su man pages does not mention /etc/suauth, what reason?

I've been reading the man pages before I start restricting su access to certain users (I'd like to not rely on sudo if possible). There is no /etc/suauth file so I was going to create my own and ...
0
votes
1answer
172 views

ssh master - execute su remotely

I have a server S that I need to connect to. I'm connecting to S as user asdf with control master and after that I perform some stuff: ssh -N -f -M -o ControlPath=$SSHSOCKET ${USER}@${IP} -p ${PORT} ...
2
votes
0answers
315 views

Difference between 'xhost + ' and 'xhost +SI:localuser:AnotherUser'

If I do xhost + >access control disabled, clients can connect from any host su AnotherUser -c xterm an xterm popups, but if I do xhost +SI:localuser:AnotherUser >localuser:AnotherUser being ...
1
vote
2answers
384 views

run command with sudo su in script and redirect stdin and stdout

I need to run command as another user and write to its stdin and read from its stdout. I can run command as another user only via opening new shell: sudo su anotheruser but with new opened shell i ...
3
votes
2answers
138 views

Why does man page completion fail after su?

I have a default Debian 8.1 installation. I do su man apt<TAB> but get nothing. I do see the manual when I write man apt-get in both modes: as user mas and as root. However, tab ...
95
votes
2answers
24k views

Why do we use su - and not just su?

I don't understand why su - is preferred over su to login as root.
16
votes
1answer
2k 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, ...
3
votes
1answer
614 views

Possible to pipe command using su via ssh

I'm trying to write a python script to remotely update the login passwords for a set of account I administer - I can already successfully use python to pipe remote commands via the stdin of an ssh ...
1
vote
1answer
36 views

Disabling su - <user1> alone

In my Team , we have a server which few people know the root password I can see they log into root and then use su - user1 to use from user1 login., I cannot change root password for some reasons , ...
1
vote
2answers
519 views

sudo / su to user in a specific group

I am looking to setup a generic user that has the ability to su/sudo to any user in a specific group. Either that or to any user that has a specific naming scheme. Is this possible on linux? I ...
0
votes
3answers
184 views

switch to sudo user with AND command doesnt work

I am trying to copy the ssh private key from one user to another user in single shot. sudo su && cp /home/sk/keys/master.pem /home/sg-user/keys/ This command works well, when i run them one ...
2
votes
2answers
631 views

How to source correct startup scripts on interactive, non-login shell

I'm trying to set up a sane/usable environment in a barebones OpenSolaris-derivative (OmniOS, a distribution of Illumos/OpenIndiana). I have all the plumbing code I need in .profile, .inputrc, and ....
0
votes
0answers
17 views

su - with -s option and environment - why symbolic link doesn't work? [duplicate]

here's the trick: [root@aaa ~]# su - -s /bin/sh gerrit -c 'env' HOSTNAME=aaa JAVA_HOMEC=/opt/jdk/ SHELL=/bin/sh TERM=xterm-256color HISTSIZE=1000 JRE_HOME=/opt/jdk/jre/ USER=gerrit MAIL=/var/spool/...
101
votes
8answers
18k 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 ...
0
votes
0answers
51 views

Use sudo as login

I've picked up the habit of using sudo and disallowing root logins. In cases, sudo is integrated with GUI configuration tools that require it. Are there any serious efforts to replace login and ...
2
votes
0answers
37 views

Bind a directory as me

Analogous for a regular user running a thin FTP server (where others can access the file system with his/her permissions), can a regular user (through fuse maybe) "mount" a directory for others to use ...
4
votes
4answers
31k views

How to login as root from Bash and do stuff

This is my simple bash: cat test.sh #!/bin/bash echo "hello" su - root -c /path/to/script.sh <<EOF password EOF whoami echo "good bye" But I get this error: ./...
4
votes
1answer
184 views

limits.conf modification doesn't work

On a SLES 9 machine I added the line: vi /etc/security/limits.conf USERNAME hard cpu 70 but when I check it with "ulimit -a": SERVER:~ # su USERNAME USERNAME@SERVER:/root> ...
1
vote
2answers
351 views

Differences between sudo and su in inheriting environment

Why can the command run by sudo inherit the environment from the parent shell process, while the shell process after sudo su to the root user doesn't? t@ocean:/tmp$ export ME=tim t@ocean:/tmp$ sudo ...
2
votes
0answers
361 views

Decrypting with GPG after a “su - different user”

I have cron job running a script in the cron of "USER A" that encrypts many files in a loop using the gpg command below: gpg --batch --cipher-algo AES256 --passphrase "PASSWORDISHERE" -c FILENAME "...
1
vote
3answers
4k views

Pass arguments to a command run by another user

I have a bash script that is supposed to take some arguments and then run in a different user: test.sh #!/bin/bash sudo su user2 <<'EOF' echo $1 EOF However it prints blank: $ ./test.sh ...
7
votes
1answer
741 views

When running 'su - username', pam_group doesn't add additional groups from /etc/security/group.conf but sshd login does?

I am having trouble determining why su doesn't behave as the PAM configuration would imply. In short, using su to become another user should load secondary groups according to PAM configuration, but ...
0
votes
2answers
454 views

executing command as su

I am executing this command as su. I have made the connection with SSH (using sshNet), and then when I try to set the command su -, I get no response. I have the password and the command I would like ...
1
vote
1answer
188 views

Running some parts of a script as an unprivileged user with shell environment

I am creating an instance configuration script that sets up a machine. I am running the script via sudo i.e. sudo run.sh. Most of the steps require root access but some of the script's steps do no ...
5
votes
2answers
2k views

Sudo Su automated login

I want to automate the login process with sudo su. I have seen lot of questions on these, but none of them are working for me. Automate login with sudo and su Here's my what I tried so far echo "...
3
votes
3answers
2k views

Why root does not source .bash_profile?

Everytime I try to login as root using su (not su -), it doesn't source .bash_profile in user1's home directory. Basically my /var/root directory doesn't have .bash_profile, so I put a copy of ....
1
vote
2answers
991 views

Script to su -c into a screen is not working as intended

I'm working on a script that will allow me to load up a screen from a user via sudo and su -c. However, when I use it, it will just show the shell of the user: sudo su -c "script /dev/null; screen -r ...