Linux Classes
Share This With a Friend  

How Can I Change Linux File Permissions?

Using Chmod to Change a File's Permissions

Fine; you can decipher the permissions for a file or directory, but what if you want to change them? Maybe you've decided that the pig_info file is a little too sensitive for just anybody to view, or that you should allow all users to execute the zippity program. The chmod (change mode) command can take care of that. The general form of the chmod command is

chmod <permission flags> <file or directory name(s)>

To tell chmod the new permissions for a file, you can use any combination of these permission flag characters:

(pick one or more) (pick one) (pick one or more)
u For the owner + Grant access r For read access
g For the group - Deny access w For write access
o For all others x For execute access

Here are some examples:

chmod o-r pig_info Remove read access from all others.

chmod g+rw pig_info Grant read and write access to group.

chmod ugo+x zippity Grant execute access to everybody.

In effect, you're saying "change the mode for these people by adding/removing their access to read/write/execute the file named whatever." Just pick the proper combination of flags in each of the three columns, depending on what type of access you want for the file.

Note: If you give chmod a directory name instead of a file name, the permissions have slightly different meanings. For a directory, read access means that you can list the files with the ls command; write access allows you to create or delete files; and execute access gives you the ability to change to that directory with the cd command.

Transferring Ownership of a File Using Chown

If you are logged in as root, you can transfer ownership of a file or directory (if you move it into another user's directory) using the chown command.

To tell chown what to do, just give it the new owner and the file name, like this:

chown sigmund zippity

This will make sigmund the owner of zippity. Once you've transferred ownership, sigmund will be able to set the file's permissions (with chmod) if he wants to.

For more information on the chmod command, see the chmod manual.

Previous Lesson: Linux File Permissions
Next Lesson: Important Linux Commands



Comments - most recent first
(Please feel free to answer questions posted by others!)

avinash     (03 Mar 2013, 12:51)
I add users in GNOME 2.30.2 version linux sir.
but it doesn't make anyaction.i'm also search in File system/ more users added there.why sir please help me???? I'm beginner in Linux
Jalal     (01 Oct 2012, 18:38)
Hi, I'm using centos5 and trying to install pbxnsip v3 but I guess I will have to give some permission to the executable file which I'm unable to..
I tried some commands and when I type chmod a+x etc it says operand missing. Can you help me with that?
thank you..
vavax     (07 Aug 2012, 23:50)
Is there any tricks that i can set folder permission "Not To Copy || Send to.... " i tried this one: chmod a=rx.... but i had a problem i want my users to READ and Xcute but NOT TO COPY MY FILES TO OTHER PLACE. THANKS
Amol     (25 Mar 2012, 03:50)
.I want to just give read permission to particular user in a group while group have all
read, write, execute permission of one txt file.

Plz assist me....
hmuser     (22 Mar 2012, 17:50)
I have all permissions and am the owner of a directory, but when I try to execute a script that has run fine on another machine I get the following error:
Setuid/gid script is writable by world.
any ideas?
sachin     (11 Jan 2012, 00:07)

I have a storage which is mounted on local systems. What I want is if I create a folder from local systems on the mounted folder it should get the permissions and ownersship as an what it is mention for the folder on the storage

Eg: storage
drwxrwxr-x root test 0 Dec 8 20:06 folder

But if I create a folder from a local system inside folder it should take the same permissions. Where as in my case I am getting like this .....

drwxrwx--- 2 root root 0 Jan 11 2012 abcd

Can u help me out where I am going wrong ?
jong hong yo     (04 Jan 2012, 20:10)
Hi ser
jimboy     (14 Dec 2011, 20:29)
can you teach how to dougie??
Abhishek     (13 Dec 2011, 10:40)
I have two users on my computer (ScientificLinux 6) - myself (in germany) and my boss (in the US). I am the admin and I know the the password to my boss's user account on my computer. Often I have to prepare reports and organise data files on his user account or put the results of my calculations on his account. Though I always give him the permission to everything on his user account by going to the home direcotry and using the command:
chmod -R 777 <boss>
chown -R <boss> <boss>

Still, every time i create a new folder on his user account or move a folder from mine to his user account, he cannot access it. I have to then go back again and use the commands as mentioned above. With all the good stuff that people say about linux, shouldn't it be possible to design some way that both he and me can do anything with his user account without going to command line ? Sorry but I am a new linux user and am forced to use it - have no options.
Amanullah     (21 Oct 2011, 02:22)
I want to give a file permission but ddinot want to use 777 so pls any expert help me..AMANULLAH
Gaucho Agregado     (29 Jun 2011, 21:16)
I really appreciate the way you deliver ideas behind the complexities could be. Keep it up sir! I'm a die hard apprentice of yours. thanks!
umesh     (29 Dec 2010, 03:27) can usage the file and directory permission?please help me.
2.what is means for related and absoulte in file permission?
anil     (12 Oct 2010, 12:15)
I wnat to give the file permission to perticular user,can anyone help me?
Suresh     (07 Sep 2010, 08:22)
The Linux file command are easily described.
A Good Effort to spread knowledge.
dood     (30 Jul 2010, 13:44)
btw, sorry about bad grammer ,I copied some parts of it from someone else's post and forgot to change them.
dood     (30 Jul 2010, 13:39)
Hi,i'm try to change primission of one my hard drives, but the "chmod" doesnt change anything.
this is result of ls -l before chmod 777 /media/win :
debian:~# ls -l /media
dr-x------ 1 root root 12288 2010-07-30 04:33 win

and the result after doing chmod :
dr-x------ 1 root root 12288 2010-07-30 04:33 win

this win folder is a ntfs (my windows vista drive)
that i can access it as root ,but other users cant access it.
i've changed the fstab and the owner so other users have the rights to use it but still i cant see the contents of it but still doesn't work.
do you have any idea why i cant access this folder as an user?thanks
Cristian Kleuser     (20 May 2010, 19:31)
Hi, I'm trying to set a folder, the right permission to all my users read and write content on them (creating and editing files and sub-folders) but I don't know how to set that... How can I do this ? Do I have to create all the users to the same group? how to set groups autorization etc? thanks
Bob Rankin     (17 Feb 2010, 22:54)
Yes. Those 755's and 644's are a tad geeky, dontcha think?
ralphaw     (17 Feb 2010, 11:16)
Did you opt not to include the command with octal changes, so as not to have to explain BCD(binary coded decimal)?

I welcome your comments. However... I am puzzled by many people who say "Please send me the Linux tutorial." This website *is* your Linux Tutorial! Read everything here, learn all you can, ask questions if you like. But don't ask me to send what you already have. :-)

NO SPAM! If you post garbage, it will be deleted, and you will be banned.
Notify me about new comments on this page
Hide my email

Ask Bob Rankin - Free Tech Support

Copyright © by - Privacy Policy
All rights reserved - Redistribution is allowed only with permission.