The following is being executed from an account with sudo privileges:
I have a user tomcat created with the following command
sudo useradd -g tomcat -d /usr/local/tomcat -m -s /bin/false tomcatI also have a user test created with the following command
sudo adduser testI have a folder temp and perms 777 are set on this folder
chmod 777 tempFollowing are my observations:
## This works and I can see temp/a.txt being created
sudo -u tomcat touch temp/a.txt
## Does not work.
sudo su -c "touch temp/b.txt" tomcat
## works
sudo -u test touch temp/c.txt
## works
sudo su -c "touch temp/d.txt" testSo my question is what exactly is wrong with tomcat user?
1 Answer
The tomcat's shell is /bin/false, you can run with su - as
sudo su -s /bin/bash -c "touch temp/b.txt" tomcat 0