Possible to ignore the users shell in "su" command?

If you don't put the - after su then it won't load that user's environment, but the commands will still be run as that user.


It appears that I misunderstood your actual problem. As other have said -s is the option you probably actually want.


You can use:

su -s /bin/sh -c 'mkdir bin' user1

The -s option to su specifies the shell to use, overriding whatever is in /etc/passwd.

I dropped the - from your command because, in addition to loading the profile, it will probably change the working directory to the home directory of the user for the command, so you'd be creating 'bin' in user1's home directory, not your current directory.


I believe the -s/--shell option to su lets you pick the shell to use while keeping the other parts of users environment, /bin/sh is specified by posix so should be available everywhere.