Difference between sudo -u and su -c
5,309
The tomcat's shell is /bin/false, you can run with su - as
sudo su -s /bin/bash -c "touch temp/b.txt" tomcat
Related videos on Youtube
Author by
iwekesi
Updated on September 18, 2022Comments
-
iwekesi over 1 year
The following is being executed from an account with sudo privileges:
I have a user
tomcat
created with the following commandsudo useradd -g tomcat -d /usr/local/tomcat -m -s /bin/false tomcat
I also have a user
test
created with the following commandsudo adduser test
I have a folder
temp
and perms777
are set on this folderchmod 777 temp
Following 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" test
So my question is what exactly is wrong with tomcat user?