The "substitute user" Unix command that changes the current user

learn more… | top users | synonyms

23
votes
3answers
2k views

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 ...
22
votes
3answers
53k views

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 ...
18
votes
2answers
6k views

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 ...
9
votes
1answer
924 views

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 ...
8
votes
2answers
3k views

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 ...
6
votes
3answers
833 views

Is it possible for root to execute a command as non-root

I am root user and suppose i want to run any application as another user. is it possible, without switching to another user. Something like # google-chrome user=abc I am actually executing a cli ...
6
votes
3answers
2k views

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 ...
5
votes
1answer
90 views

`su` for the OS X GUI

With OS X I wan the ability to log in to the computer as admin but set myself to another user on the system so I'm working on their profile with their privs, see all their settings, files, and run ...
4
votes
4answers
190 views

Any differences between `su` vs. `su -` beside the pathing? [duplicate]

I see that su - makes the shell a login shell from su --help. I'm curious what the differences are between this and a normal su command. I know there seems to be a difference in the paths, any other ...
4
votes
1answer
90 views

Using su with commands

Ubuntu Server 12.04 On a remote server that I ssh into I have set up a special user with: sudo adduser --system --disabled-login --disabled-password --group suser to run some maintenance functions. ...
4
votes
1answer
49 views

Why does cifs asks for su rights to write any data into it?

I'm mounting a windows share as follows: sudo mount -t cifs //192.168.178.49/public -o users,username=name,dom=domain,password=pword /mnt/nas Then I'm trying to create a simple file with some basic ...
3
votes
6answers
2k views

a safer no password sudo?

Ok, here's my problem - Please don't yell at me for being insecure! :) This is on my host machine. I'm the only one using it so it's fairly safe, but I have a very complex password that is hard to ...
3
votes
2answers
530 views

SSH as Normal User --> SU --> SCP as Root

I'm on a Win7 box connecting to a linux server. From reading: http://winscp.net/eng/docs/faq_su it looks like I need to open my SCP connections as the particular user. When I connect via SSH, I can ...
3
votes
1answer
2k views

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

It is my understanding that they do the same: they ask for my password (if I am allowed in /etc/sudoers), and give me a login shell as root. Is there any difference between them? sudo su - sudo -i ...
3
votes
2answers
55 views

What makes the differences between `sudo CMD` and `sudo su` followed by `CMD`?

I have an SSH server with key only auth and I want to add a key for a new user. I log in with one user(kidmose), I try to append the key to a new user's(remote) authorized_keys and it fails: ...
3
votes
2answers
1k views

Supply SU password in a bash script, within the script?

The purpose is to restart the machine if it doesn't get an abort command from the user. The problem is that the way the terminals are set up, user must supply SU password for shutdown, init, reboot, ...
3
votes
1answer
789 views

Problems with bash path when using 'su'

In Ubuntu Lucid Lynx, I'm trying to do su -l user -c "foo.sh args" where foo.sh is an executable bash script on the PATH set in ~user/.bashrc. Unfortunately, this fails because it can't find ...
3
votes
1answer
284 views

solaris 8 init script asks for user password

I've got a script in the Solaris 8 initialization phase, under /etc/rc3.d, that contains a su - username -c "a command", but I see thru the boot messages that the su command is asking for the user ...
3
votes
1answer
2k views

Use su to switch to a local (mutually-trusted) user, without a password?

I'm curious if there is a way to enable one user to login (via su) into another user, without needing to know that users password. For instance, if I'm logged in as user1, I would like to give user2 ...
2
votes
4answers
2k views

Any latest linux distro which gives full root access ( NO SUDO )?

Is there Any latest linux distro which gives full root access ( NO SUDO ) ? I want to use it for programming in which I have to use / file system very frequently. What I need is any good linux ...
2
votes
3answers
3k 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: ...
2
votes
2answers
487 views

Is there a way to remove root requirements for a specific command in linux? If yes, how so?

I'm using Ubuntu 12.04 LTS, and I'm trying to make it so that the specific command dhclient doesn't require root privileges. I've done some research that leads me to believe I could unlock an "su" ...
2
votes
3answers
14k views

Automating the “sudo su - user” command

I want to automate sudo su - user from a script. It should then ask for a password.
2
votes
1answer
304 views

difference between root executing command as sudo vs not using sudo?

I have a Linux question regarding the sudo command and the root user. If I log into the root user using the su command, what is the difference between the following two commands? root> sudo ...
2
votes
3answers
1k views

How do I su to user login shell directly

I do the following many times a day I login to a server via ssh as user1, I then do su - to become root, then I do su --login user2 to become user2 Is there a way to tell su to go to user2 ...
2
votes
1answer
90 views

sudo su “username” vs. su “username”

Please explain me, what is the difference between: sudo su "username" vs. su "username" Which has higher privileges? If I log into root with sudo su "username", I am root for one command only? So it ...
2
votes
3answers
121 views

Using su - (user) to open privileged port not working

So I wanted to run a Node server on port 80 but I didn't want to run the entire process on root privileges, for security I thought this would be the best. So I thought a good solution would be to use ...
2
votes
2answers
2k views

sudo, runuser, su don't work as I expect when run as root with command as “echo $HOME”

When I run these commands it outputs as shown. /root $ sudo -u someuser -i "echo $HOME" /root $ runuser -l someuser -c "echo $HOME" /root $ su - someuser -c "echo $HOME" /root What i expected ...
2
votes
3answers
6k views

Trouble setting up PATH for Java on Debian

I am trying to get Oracle Java 7 update 3 working correctly on Debian 6. I have downloaded and set up the files in /usr/java/jre1.7.0_03. I have also set the following two lines at the end of ...
2
votes
4answers
2k views

Accessing an exit code outside of a su -m $USER -c “<cmd>”

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 ...
2
votes
2answers
167 views

gksu is a front end to su?

gksu manual page says that it is a front-end to su, however su doesn't need a command to be executed, while gksu does. Also, gksu doesn't seem to change the user ID of my shell, while su does. Is it ...
2
votes
1answer
33 views

Check if Logged In via ssh or su

Let's say I'm called to a workstation and I face a console and I want to know if the current user logged in via ssh or su. How can I check that?
2
votes
1answer
559 views

Debian disable su to root user

I am currently using Debian 7 (Wheezy) and I am trying to disable the su command only when the target user is root and not a privileged user. For example, let's suppose the following users exist: ...
2
votes
2answers
3k views

Changed the permissions on /usr/bin

I executed sudo chown -R USER /usr/bin Now, when I try to "sudo" anything, I get sudo: effective uid is not 0, is sudo installed setuid root? I tried pkexec chown root:root /usr/bin/sudo and ...
2
votes
1answer
237 views

Root authentication with another root user

I have a PC at work running Fedora 14. For some reason, the IT guys do not give out the password for the root user, but instead, if needed they create a specific suXXX user with root permissions. The ...
2
votes
1answer
495 views

“chmod -R 777 /” for a few seconds - now what?

On Centos 6.5 I accidentally typed chmod -R 777 / Ooops. I CTRL + C'ed out of it very quickly, but not before it'd started working away for a couple of seconds. Consequences? Well, already su ...
2
votes
1answer
1k views

SSH: remote switch user and execute command under this new user

I am able to connect to remote machine using public/private keys (without password) as user wakatana. On remote machine I am able to issue: sudo /usr/bin/rootsh -i -u root then I type root's password ...
2
votes
1answer
4k views

How can i block su access to some users only in linux

I want to configure pam in a way so that my some users can su to only some user. In RHEL4, I used /etc/pam.d/su auth required /lib/security/$ISA/pam_stack.so service=system-auth auth ...
2
votes
1answer
43 views

In bash 4.3.27 “su” ignores user variables when combining “-” with “-c command”?

Since forever we used to launch user scripts from a different user crontab like this: 00 12 * * 1 su - user2 -c "/home/user2/myscript.sh" By doing this, the script is launched after the interactive ...
2
votes
2answers
1k views

How can I automatically pass the password to 'su'?

I am working on an exploit for a security course. The object is to obtain a root shell in a linux virtual machine. So far, I can write to /etc/passwd and change root's password to an arbitrary string. ...
1
vote
3answers
3k views

How can I find out what password I need to use for 'su'?

I am using Mac OS X 10.5, and have my account set up so that I don't need to login. When I go to Network Preferences and click the lock icon on the lower left corner, I am prompted for my username and ...
1
vote
1answer
167 views

su - for some users

in a linux system with su - any user (with root password) can get root privileges. how I can restrict to some users ? // similar to AllowUsers in sshd_config
1
vote
2answers
163 views

How do i run su username -c “command ” in a sequence

am trying to write a script that runs commands in a sequence as a user but su keeps doing every command at the same time instead of running them one after another the script looks like su username ...
1
vote
2answers
3k views

What happens to the environment when you run “su -c”?

What happens to the environment when you run "su -c"? The reason I ask, is this mysterious behavior: bash$ which firefox /usr/local/bin/firefox bash$ su - user -c "echo $PATH" ...
1
vote
4answers
2k views

Alternative for sudo

I am aware that we can execute a command/script as a super/another user using sudo command. But Is there a possibility where the sudo utility itself is unavailable/removed by the user. If so, what ...
1
vote
2answers
88 views

Running Screen after switching users

After switching users (with su) I cannot run screen: % screen -L Cannot open your terminal '/dev/pts/5'. How can I run screen after switching users?
1
vote
2answers
42 views

How to see history of commands entered as superuser

Is there a way to see the commands that I entered in su mode? Similar to the ~/.bash_history? Where would this be located?
1
vote
1answer
521 views

Autologout after logging in

I have a Ubuntu 10.04 LTS server. I'm currently logged in as root, because I suddenly cannot log into my account anymore. When I execute su useraccount, nothing happens. The log file auth.log ...
1
vote
3answers
564 views

Use sudo command for script SSH server

I have to do following steps on several servers: log in with my username type in sudo su - type in amCLI -l 32/1 | grep Firmware So I would like to write this all in one script, my idea was: ...
1
vote
2answers
270 views

Best way to store root passwords

I have over ten web servers to manage and configure, with each server having its own root user and password. I have to maintain a database of all the root passwords on my development machine, but I ...