Run commans as no login shell user

Hi All,

I have problem running a command with another user who has no login shell

the os is solaris 10

i am root and doing the following:

su user -s /bin/bash "ls"

no output .. no error messages

if su - user i got No directory

You can't su to something with no login shell -- that's the entire point of that.

You can sudo to it, however, if your sysadmin has configured sudo to allow that for your user and the command in question. This just does a setuid without an actual login.

sudo -u user ls

The error messages states that your user has no home directory, not no login shell.

In any case, even if the user has no home directory and assuming you have root's privileges, you need to avoid the "-" option which is meaningless in that case and you can simply run

su user ls

If the user really has no shell, i.e. the last field of its passwd entry is empty, the OS is defaulting to the bourne shell (/usr/bin/sh). However, if the user has a specific shell specified, this shell will be run to execute the command, and will fail if it is not functional, e.g. /bin/false.