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

learn more… | top users | synonyms

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

Running su noninteractively?

So, I got locked out of a server (sshd seems to have stopped responding). I got a reverse shell (added a jenkins job that gives me a reverse shell), but I've hit a snag - su wants a terminal, and ...
0
votes
1answer
38 views

The logic of Disabling Root Login

Ubuntu 14.04 VPS user here. My VPS was hacked twice. And the third version is up. Fingers crossed. The mistake I made in the first two was that I had root + password login enabled. I've learned ...
0
votes
1answer
176 views

Require bash script to be run with sudo (not as root user)?

I want to require a bash script to be run as the current user with sudo, but prevent it from being run if it was executed as the root user directly. This is because I'm doing some setup actions for ...
3
votes
3answers
2k 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, ...
0
votes
1answer
32 views

How to switch user with pre-configured credentials in SSH Terminal after logging in as standard user

I am talking about authentication without needing user intervention like specifying password and username in the command file so that user don't need to input anything to switch user. For example: ...
1
vote
1answer
52 views

Can't run /bin/bash… sometimes?

I’m on a Google Compute Engine which is running Debian Wheezy 7.4. I’ve been noticing strange things recently. For example, I can do sudo bash. But then, from root, I can’t do sudo -u anotherUser ...
0
votes
0answers
17 views

PAM authentication problems with su - $username

When I try to su - postgres as the root user, I immediately get su: Authentication failure This is my pam.d/su file # Begin /etc/pam.d/su # always allow root auth sufficient pam_rootok.so ...
0
votes
0answers
18 views

Possible to su and run both .bash_profile's?

I currently log into the boxes at work, then: su - <adm_user> My question is, is it possible to pass through to the su'd user, my bash profile and source the adm_user's bash profile?
0
votes
0answers
16 views

Mounted Share from TerraStation file server - can't change file or directory permissions

I am trying to delete files from the TerraStation share in a subdirectory. These are marked by TS as having permissions issues. Through a terminal window (Mac, OS 10.10, CentOS) I su then cd to ...
0
votes
0answers
14 views

Cannot remove a file

I used Cryptonite to encrypt a file then my device was shutdowned suddenly. Well, I cannot decrypt the file anymore. This's what I catched in the logcat when I try to encrypt the file once again: ...
2
votes
3answers
2k 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 ...
0
votes
0answers
43 views

Windows equivalent of su

During start up, Group Policy can be used to run scripts before user log in. These scripts run as the local system account, which I understand to be effectively like root. I'd like to run a script as ...
2
votes
1answer
68 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 ...
0
votes
1answer
105 views

Difference between su and su -c (environment variables?) when running db2?

When I type this: su <user> -c "/home/<user>/sqllib/bin/db2 catalog tcpip node <dbName> remote <ip> server <port>" I get this error message: SQL10007N Message "-1390" ...
1
vote
2answers
244 views

How to drop privileges in a script inside a non-interactive shell?

I'm using Docker to create images that I can run as containers. I'm configuring my image all as the root user, including setting up volumes and other things. But once I've got all that configured I'd ...
2
votes
1answer
761 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 ...
25
votes
3answers
61k 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 ...
3
votes
2answers
84 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: ...
0
votes
1answer
84 views

Replacement for “su user_with_sudo; sudo -s” for user without sudo-rights?

Let's say I have two user accounts: user (without any sudo permissions) user_with_sudo (with all sudo permissions) Now, I'm logged in as user but want to do something as root, e.g. switch to a ...
2
votes
1answer
44 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
3answers
162 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 ...
0
votes
1answer
120 views

Difference between su vs root SSH login for mounting?

I have a bash script luks that I use in Android for mounting/umounting encrypted devices, that can be called in a terminal emulator with su -c "luks ..." The script works ok for the first part, ...
1
vote
2answers
207 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?
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 ...
0
votes
0answers
33 views

Trying to rsync and use sudo on other end

Scenario: Mac OS X Machine - old computer - user: john.doe Mac OS X Machine - new computer - user: john.doe Goal: Copy /Users/john.doe/Desktop and /Users/john.doe/Documents via rsync Problem: ...
1
vote
2answers
1k views

Permission denied when attempting to mv (sudo su userName)

I am currently working on a backup script to log into my production server and pull the latest SQL dumps to my staging server. I have no issue pulling the SQL dumps but I do have an issue with moving ...
7
votes
3answers
1k 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 ...
3
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 ...
0
votes
1answer
463 views

Run startup script with another user

I have two users user1 and user2. And tomcat has owenership of user1 and started with user1 only. I need to make a rule for user2 such that user2 can starts/stop tomcat but tomcat should always be ...
2
votes
1answer
1k 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 ...
0
votes
0answers
36 views

ec2 enable su for user ubuntu

I am trying to enable rstudio-server login with ubuntu on ec2, but it fails. I think it uses the same auth mechanism as su. So I did sudo passwd su someotheruser su ubuntu But even though I know ...
0
votes
0answers
1k views

SU : Permission denied /bin/sh

I added a new user in system: $ useradd new_user When I try to switch from root to new_user, I get this error: $ su new_user permission denied /bin/sh $grep new_user /etc/passwd ...
0
votes
1answer
1k views

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, ...
1
vote
2answers
242 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
4answers
3k 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 ...
2
votes
1answer
729 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: ...
1
vote
0answers
1k views

What is the different between “sudo su” and “sudo bash”?

In Ubuntu 13.10, for the default setting, the following command in Terminal user@host:~/path$ sudo su results in entering an prompt root@host:/home/user/path# And this command ...
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 ...
2
votes
3answers
5k 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
1answer
478 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 ...
7
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 ...
1
vote
3answers
893 views

How to exit the super user from middle of shell script?

I have a shell script in which most of the commands need to be run under sesu user and then I need to run some commands as current user. Can you please help me in this?
3
votes
2answers
595 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 ...
0
votes
1answer
47 views

Cannot access su in fedora 17

I am using Fedora 17. by mistaken, I have given full permission as root, for all the files in /usr/bin My command was chmod 777 * and also I gave full permission for a file(I can't ...
9
votes
1answer
1k 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 ...
1
vote
2answers
1k views

su & sudo on Mac OS X 10.9/Server 3.0

I am trying to use su and sudo on my iMac that I did a fresh clean install of Mac OS X 10.9 and Server 3.0. I explicitly set the password for root with passwd root but when I try to use su or sudo ...
1
vote
2answers
44 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?
4
votes
1answer
52 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 ...
2
votes
1answer
2k 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 ...