why a non root user can't change the permissions of /tmp ?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
/tmp needs to be accessable by all the users, that is why it needs to be owned by root (both user and group) and should have a 1777 mask (drwxrwxrwt).
This mode (1777/drwxrwxrwt) makes sure that any user can write to the /tmp (and /var/tmp) directories, but cannot remove another user's files from them. The latter is prohibited by the so-called “sticky bit,” the highest bit (1) in the 1777 bit mask.
Why would you want to change the permissions for /tmp anyway?
Hi I m trying to learn linux and on the infant stage. Actually I was applying chmod command. Got a query that if root can change the permissions why cant a non root user?
You can't change the permissions of a directory that you don't own. /tmp is a system directory owned by root. Only root should be changing the permissions of /tmp. The permissions you want (1777) are the permissions that /tmp should have.
It is the ownership on the target that prevent this and not the execute permissions of /bin/chmod. The denial comes from the kernel.
In other words, the chmod command tries to run the system command to change the permissions, and the kernel refuses and returns an error to the chmod command which in turn returns with an error when it exits.
It is the kernel which performs these types of operations. It checks the permissions and ownerships. It also checks extended permissions (see man getfacl) and extended attributes (see man lsattr) as well.
Also, bear in mind that the filesystem contains the ownership and permissions of files. A foreign filesystem such as fat32 doesn't use unix inodes, do you can't use chmod and chown.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.