LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 11-08-2008, 04:58 PM   #1
raj_hcl1986@rediffma
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Rep: Reputation: 15
why a non root user can't change the permissions of /tmp ?


HI

I have a doubt, a non root user 'raj' has file permissions of /bin/chmod as 755, then why cant he change the permissions of /tmp (1777) with chmod ?

What he needs to change the same.
 
Old 11-08-2008, 05:06 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

/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?

Hope this helps.
 
Old 11-08-2008, 05:15 PM   #3
raj_hcl1986@rediffma
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Original Poster
Rep: Reputation: 15
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?
 
Old 11-08-2008, 05:15 PM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
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.

Last edited by jschiwal; 11-08-2008 at 05:20 PM.
 
Old 11-09-2008, 03:58 AM   #5
raj_hcl1986@rediffma
LQ Newbie
 
Registered: Oct 2008
Posts: 21

Original Poster
Rep: Reputation: 15
Got it. Thanks for the kind support.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cant access external HD as user, cant change permissions as root? Kramer Linux - Software 3 01-12-2006 02:56 PM
Cannot change permissions as root??? Kramer Linux - General 2 08-24-2005 07:31 AM
Root cannot change file permissions. aje Slackware 3 08-12-2005 02:27 AM
Change my user to root permissions metalaid Linux - Newbie 5 01-19-2004 08:17 PM
Cannot change dir permissions from root sstudley Linux - General 4 02-25-2003 06:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration