Questions tagged [su]

Substitute User command

Run a command with substitute user and group id, allow one user to temporarily become another user. It runs a command (often an interactive shell) with the real and effective user id, group id, and supplemental groups of a given user.

man page

126 questions
111
votes
8 answers

How to run command as user who has /usr/sbin/nologin as Shell?

All I need to do is to run a specific script as a particular user who does have the nologin/false shell indicated in /etc/passwd. I would run the script as root and this should run as another user. Running: ~# su -c "/bin/touch /tmp/test"…
Tommaso
  • 1,131
  • 2
  • 8
  • 4
99
votes
11 answers

How to prevent a user from login in, but allow "su - user" in Linux?

How do you allow a user to log in using "su - user" but prevent the user from login in using SSH? I tried to set the shell to /bin/false but the when I try to su it doesn't work. Are there several ways to only allow logins by su? Is SSH's AllowUser…
NoozNooz42
  • 1,155
  • 1
  • 8
  • 9
61
votes
2 answers

Executing a command as a nologin user

I've recently set up my server so that my suPHP 'virtual' users can't be logged into by using this article My issue now is that before when I ran a rake command for my Ruby on Rails application running on the server, I used su to go into www-data…
user82250
51
votes
1 answer

What's the difference between sudo su - postgres and sudo -u postgres?

PostgreSQL users peer authentication on unix sockets by default, where the unix user must be the same as the PostgreSQL user. So people frequently use su or sudo to become the postgres superuser. I often see people using constructs like: sudo su -…
Craig Ringer
  • 10,553
  • 9
  • 38
  • 59
40
votes
2 answers

Why does redirecting 'script' to /dev/null/ allow 'screen' to work while su'ed as another user?

I was su'ed into a user to run a particular long running script. I wanted to use screen but I got the error message "Cannot open your terminal '/dev/pts/4' - please check." So I Googled around and came across a forum post that instructed to run $…
Ichorus
  • 485
  • 1
  • 6
  • 12
38
votes
4 answers

BASH Scripting, su to www-data for single command

I am working on automating the creation of subversion repositories and associated websites as described in this blog post I wrote. I am running into issues right around the part where I su to the www-data user to run the following command: svnadmin…
Brendon Dugan
  • 493
  • 1
  • 4
  • 6
38
votes
2 answers

Run command as Linux "system" user (shell = /bin/false)

I created a "system" user in Ubuntu 11.04 (adduser --system) for running certain cron jobs, but sometimes I want to test things out by manually running commands as that user. What's the easiest way to do this? su doesn't work, because the user has…
EMP
  • 5,122
  • 10
  • 36
  • 32
19
votes
8 answers

Linux - use "su -" but keep the current directory

When I do su - to get to root, my current directory is set to root's home. Is there anyway to keep the current directory that I was in, much like sudo -s. Or is the answer to use sudo?
Amandasaurus
  • 30,211
  • 62
  • 184
  • 246
16
votes
2 answers

"Cannot set terminal process group" during su to another user as login shell

Note: Please read the updated information starting with "EDIT" near the halfway point of this post - the environment and background of this problem has changed I've got a bog standard Debian 6.0 install here that I decided to sidegrade to the Debian…
Mikey T.K.
  • 1,367
  • 2
  • 15
  • 29
15
votes
2 answers

sudo rejects password that is correct

sudo (Which I have configured to ask for a password) is rejecting my password (as if I mis-typed it) I am absolutely not typing it incorrectly. I have changed the password temporarily to alphabetic characters only, and it looks fine in plaintext,…
Ryan
  • 321
  • 1
  • 2
  • 6
13
votes
3 answers

Is "sudo su -" considered a bad practice?

Background I know the difference between su -, sudo su -, and sudo : su - - switches user to root, requires the root password sudo su - - switches user to root, requires only the current user's password sudo - grants root access…
Kingand
  • 253
  • 1
  • 2
  • 6
13
votes
4 answers

Save file after forgetting to open as root / sudo vi

Possible Duplicate: vim re-edit as root I could have sworn I saw this question asked. But after looking though every search result for "vi" I'm stumped/lazy. I've opened a file, made an edit and now I realize it's read only and I've opened it as…
MathewC
  • 6,877
  • 9
  • 38
  • 53
12
votes
2 answers

execute su -c over ssh

I am trying to check the BIOS version of a server over SSH, a command that requires root privileges: ssh remote-server su -c dmidecode but this of course fails with the error: standard in must be a tty How do I make this work? I cannot use sudo,…
aaron
  • 741
  • 3
  • 10
  • 19
12
votes
8 answers

using su inside of a shell script

I'm automating a deploy process and I want to be able to just call one .sh file on my machine, have it do my build and upload the .zip to the server and then do a bunch of stuff on the server. One of the things I need to do requires me to be root.…
cmcculloh
  • 979
  • 2
  • 8
  • 14
11
votes
1 answer

su: /bin/bash: Resource temporarily unavailable

Unable to switch user to postgres. Ulimit settings for postgres user is set with reasonable limits. We are not hitting max. No errors in /var/log/messages. Error: BETA -bash-4.2# sudo su - postgres su: /bin/bash: Resource temporarily…
Chucks
  • 501
  • 1
  • 7
  • 13
1
2 3
8 9