Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 "/bin/false" as its shell (which is fine for cron). I've been manually changing the shell to "/bin/bash" to do my testing and then changing it back again, but I wonder if there's an easier way.

share|improve this question

2 Answers 2

up vote 11 down vote accepted

I use su - targetuser -s /bin/bash from a root shell.

share|improve this answer
    
That works, thanks! How did I miss the -s option? –  EMP May 28 '11 at 3:54
    
you can also tack on a -c "your_command_here" option to pass the command you'd like to run versus waiting for the shell and then typing it at a new prompt. –  dmourati May 28 '11 at 6:16

Use sudo. This will work even if the user doesn't have a real shell.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.