Questions tagged [su]

GENERAL SU SUPPORT IS OFF-TOPIC. Support questions may be asked on https://superuser.com. su is a utility to run a shell or other command as another user (root by default).

su is a Unix/Linux utility that runs a shell or a specified command as another user. By default, the other user is root, and su, with , is one of the two common ways of obtaining administrator privileges. Calling su usually requires typing the target user's password.

su originally stood for “super user” (it was only for running a root shell), and became later known as “substitute user” (or “switch user” or a number of similar backronyms) when it started accepting the target user name as an argument.

For system administration questions, see the su tag on Super User (for non-professionals), Server Fault (for professionals), or Unix & Linux.

460 questions
3
votes
1 answer

How to use shell variables in su command string?

In Shell script i am trying to pass an array to a Sudo SU command as shown below VAR=(1,2,3) sudo su $USER -c "for p in ${VAR[@]} ; do echo $p ; done;" Issue is $p value is not getting printed. I have tried all the below possible way but not able…
Dinesh
  • 177
  • 1
  • 11
3
votes
1 answer

Gitlab-ci, image debian:jessie. Can't change user with su command

I'm using Gitlab-ci for my job with Debian jessie image. Firstly, I need install some packages. Everything is ok. Then, I want to change user from root to a non-root user, but su command doesn't work. Below is a test about changing user. My…
Batman
  • 124
  • 11
3
votes
2 answers

Why am I getting a permission denied when su'ing to a user?

If I su user from my home directory I am getting a permission denied for bash-completion, but if I su user from another directory there is no error. Can't locate strict.pm: lib/strict.pm: Permission denied at /usr/bin/vendor_perl/bash-complete…
harleypig
  • 1,264
  • 8
  • 25
3
votes
1 answer

Node ssh2 to ssh and sudo su as a user and run commands

Using node ssh2 module, this is what I need to do 1. ssh to a server as a local user 2. sudo as oracle : sudo su oracle 3. run commands I am unable to sudo su oracle and hence cant run any commands. The local user has the privilege to become oracle…
user3439399
  • 195
  • 1
  • 3
  • 13
3
votes
3 answers

Send Control-C to a process running trough Runtime.getRuntime().exec("su");

I'm developping an app which needs to run a command as root user so I use: process = Runtime.getRuntime().exec("su"); Then I launch te process with: os = new DataOutputStream(process.getOutputStream()); os.writeBytes("tcpdump\n"); When I need the…
Jimix
  • 1,539
  • 3
  • 15
  • 20
3
votes
1 answer

Getting "must be run from a terminal" when switching to root user using Paramiko module in Python

I am trying to automate a task through a Python script. The idea is to login as a regular user and then send a su command and switch to the root account. The reason I can't directly login as root is that SSHD doesn't allow root logins. Here's what…
user2500239
  • 43
  • 1
  • 7
3
votes
2 answers

Linux shell script - How to switch user and run a script?

I'm currently writing a .sh script to deploy different applications on 4 different machines. Right now I'm having trouble with running a script as another user. I need to log in with myUser with my credentials and then sudo su to user2 to run a…
3
votes
1 answer

Switching users in remote ssh command execution

I'm wondering why executing su in an ssh command does not appear to be having the desired effect of switching users before executing the subsequent commands, as illustrated below: The following command: bob@server1:~$ sudo ssh -n root@server2 "su…
Jonathan Ellithorpe
  • 564
  • 1
  • 4
  • 17
3
votes
2 answers

su does not change everything to other user (cgroups)

If I run this command: su -l otheruser -c 'strace /usr/lib/systemd/systemd --user 2> /tmp/su.err' It fails: Failed to create root cgroup hierarchy: Permission denied Failed to allocate manager object: Permission denied I see in the strace output…
guettli
  • 25,042
  • 81
  • 346
  • 663
3
votes
0 answers

Giving SU Permissions to Android App via ADB

I'm currently writing scripts for android that can grant SU permissions to certain test apps. I was wondering if anyone knows how to grant SU permissions to an app via the ADB command line? Thanks! EDIT: I see that this question is getting a lot of…
thisbytes
  • 797
  • 1
  • 5
  • 14
3
votes
2 answers

How to sudo su over PuTTY's psftp.exe

With (PuTTY) PSFTP.exe it is possible to open open a shell script to perform certain actions on Linux. In this example I am using psftp.exe to open get30.txt file. %%PROJECT/ROOT_DIRECTORY%%\PuTTY\psftp.exe user@domain.nl -pw password -b…
Rico Strydom
  • 537
  • 1
  • 6
  • 26
3
votes
1 answer

Passing su password in shell script

How can password be passed in a shell script using su(without sudo and except)?. I have tried echo "password" | su root -c .But it didnt work.
3
votes
1 answer

Trouble logging in user using su and expect script

I am working on making a website for a class that you log into with a username and password, and then it takes you to a page that shows your grades in the class. The website is being run with a bash script, and will be hosted on a machine where the…
user3791260
  • 65
  • 1
  • 3
3
votes
2 answers

How do I send a C program's string to an su password prompt?

I have changed ubuntu's default root password by : sudo passwd Now, I am designing a C program to brute-force this password. I am using system() to call su But su prompts for a password directly in the terminal... I want to automate this procedure…
user3287808
  • 39
  • 1
  • 3
3
votes
1 answer

GDB problems inside docker

With docker version Docker version 1.1.0, build 79812e3 on Ubuntu 13.04, and using the docker container created by: # docker build -t gdb_problem_testing - < THIS_FILE FROM ubuntu RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe"…
d0c_s4vage
  • 3,947
  • 6
  • 23
  • 32