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

learn more… | top users | synonyms

-2
votes
0answers
18 views

How do I install Let's Encrypt certificate in a shared hosting Godaddy server? [duplicate]

I'm following the tutorial https://fr.godaddy.com/help/install-a-lets-encrypt-ssl-apache-20245, but when I typed the command ./letsencrypt-auto --help I got the error: "sudo" is not available, ...
2
votes
1answer
5k 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
1answer
14 views

Change user in shell function?

I would like to change the user within a shell function. I guess its not possible to change the user in such a enclosed function, but is there another way to achieve something like that?: myFunction()...
2
votes
5answers
2k views

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

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 ...
0
votes
0answers
12 views

How do I avoid getting prompted for a password when I run this script?

I’m using Amazon Linux. If I login as my “otheruser” user, and create a script, test.sh, with this text sleep 5 ; sudo reboot now I can login and run the script like so … [davea@mydevbox ~]$ sudo ...
0
votes
0answers
20 views

What's the difference between su calls [duplicate]

I can open a shell for a system user by calling sudo su - systemuser -s /bin/bash or sudo su -s /bin/bash systemuser What's the difference between those commands? They look pretty identical to ...
0
votes
1answer
20 views

Can SU group be used on Suse as it is AIX?

I'm the admin of a large AIX environment. I utilize the SU Group attribute for users to determine who can access root, even if they know the password. If they are not in the root group then access is ...
0
votes
0answers
59 views

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 ...
1
vote
4answers
2k 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?
1
vote
2answers
507 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 -...
0
votes
1answer
31 views

PID of commands run as different user

While being a root, I want to start a service as a specific user and write its PID file. Minimal nonworking example: if [ $UID -eq 0 ]; then su myuser <<EOF sleep 30 & echo $! >...
1
vote
1answer
199 views

su - Automatically unlock ssh key

On Linux there exists a tool - I believe it is ssh-agent - that can automatically unlock one's ssh key, so that when using git to fetch from a remote repository it will automatically use ones unlocked ...
0
votes
1answer
83 views

Su doesn't work - Raspbian

I'm installing an OrangePi (more powerful than the Rasp one). After installing the system with the default root user only I would like to add a new user and connect from ssh adduser foobar I got ...
0
votes
1answer
51 views

execute su with additional commands

I want do something like this: sudo su -l <user> cd <somedir> But whenever I give su additional arguments after 'user', the command returns instead of giving me an interactive shell.
0
votes
1answer
252 views

ubuntu 12.04 su fails : cannot execute /bin/bash no such file or directory

After adding a user as sudoers as, su to this user fails with error message: Cannot execute /bin/bash : No such file or directory I googled and found a lot of similar issue, mostly due to /...
0
votes
1answer
385 views

bash: /home/user/.bashrc: Permission denied when try to change user from root to user

I'm on centos, when I login as root and use su x to change user to x, it shows this: bash: /home/x/.bashrc: Permission denied I try to source ~/.bashrc but nothing changes and I also tried following ...
1
vote
0answers
46 views

How do I disable su on Macbook Yosemite?

I'm taking my macbook into the shop for service. I want to create an account that has no access to anything but its own user directory. In Yosemite, when I create a new account without administrator ...
0
votes
1answer
113 views

Accidentally change sudo user to /bin/false

More Update In short, I have to execute a command (sudo nano /etc/passwd) using a Sudoer Account which I know the username and password but I have to login as a non-Sudoer Account trial #1 su - $...
1
vote
5answers
6k 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
138 views

Auto source a script after sudo su

I am working on a machine that has some user accounts that are dynamically generated, and therefore I can not user customize the .bashrc or .profile. I frequently need to use these accounts to change ...
0
votes
0answers
20 views

Switch to user2 and load user1's bashrc automatically?

I want to switch to user2 from user1 and then instantly load user1's bashrc. For example: sudo su user2 And then as user2 run this cmd: source /home/user1/.bashrc I'm aware that maybe I shouldn't ...
0
votes
1answer
130 views

Spawn command line prompt to a remote Windows machine

Is it possible in Win7, Win8.1, Server 2K8 and 2012 to "shadow" or rather spawn a console and 'impersonate' or 'masquerade' a user command line prompt ? I am domain admin and I would like to interact ...
10
votes
4answers
6k 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 ...
0
votes
1answer
514 views

how write in script bash: su - user, command, password, without ask me password? [duplicate]

i will create file sh (bash script) #!/bin/bash su - username -c XXXXXXXX xxxxxx= command where i put my password?( but NOT ask me password in terminal..how?)
1
vote
2answers
428 views

how to create a user with root privilege and fix this error?

I created an user with root access useradd -ou 0 -g 0 myuser -p [12345] when I try to su to new user, it's show me : : No such file or directory when I want to connect to that via ssh it's show ...
2
votes
1answer
50 views

What's the point to log in as root and do “su - user” instead of log in as user?

I have to redo a bash script (not originally written by me) and at some point there is an ssh connection with the user "root" and the first thing after that is : su - otheruser I don't really ...
1
vote
2answers
30 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 ...
1
vote
1answer
222 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
835 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 ...
4
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
112 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
142 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 ...
3
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
149 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
131 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
426 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
899 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 ...
4
votes
1answer
5k 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 ...
26
votes
3answers
82k 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
142 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
110 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
69 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
211 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
199 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
554 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
4k 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 ...
1
vote
2answers
3k 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 ...
8
votes
3answers
3k 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
4answers
3k 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 ...
1
vote
1answer
804 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 ...