Help - Search - Members - Calendar
Full Version: Chmod...
Linuxhelp > Support > Technical Support
Ok, thats it, I admit defeat. I need somebody to point me twords a good tutorial on permission and chmod because I don't get it. I keep locking myself out of my own folders and files, I can't keep user data private from one user to the next, my whole system is one securities nightmare. I need somewhere where I can get more than just a list of numbers, but actually somewhere that will explain what each one really means and how to use it effectively. If I am going to have a server on-line I need to get this under-control. Thanks guys.
I don't know any site, but I can give you a (probally useless) list of examples. biggrin.gif

chmod -R 750 /home
This would allow the owner to do anything in /home or any other file/dir in it. Members of that group could read and execute (execute: execute executable files, or enter a directory). Other members can't see, enter, etc. /home and the things in it

chown root /public_upload && chgrp hippies /public_upload && chmod 773 /public_upload
This would have your owner be root, with anyone in the "hippies" group having full access. Other users (your anonymous user, for example) can upload stuff to this folder, but will be unable to see anything in it (though can enter it and write to it). This is quite nifty for FTP. They can still view the contents of a file if they know the name of the file though.

chgrp -R nobody public_html
This would make nobody the group that owns this directory, and all files/dirs under it.

chown -R pimp htdocs
Same as above, only it's the username instead of the group. biggrin.gif

Here's the laydown:

Read Write Execute (rwx)
4 2 1

So 5 would be: Read + Execute
6 would be Read + Write
4 would be Read only

Now, there are 3 numbers for each. (Example: 750)

The three stand for: User Group Others

User: (chown!) Is the owner of the folder/file
Group: (chgrp!) Is the group that owns the folder/file
Other: Everyone who isn't that owner/group. smile.gif
Ok, so if I wanted to give everyone access to read a foler, but only a specific user, say enki, to write to that folder, how would I do that?

What I want to create is one user (other than root) who can edit my /var/www/html folder but still allow everyone to download from it.
You would make him the owner of the folder and give it 644 permissions ....

rw- r-- r--
42- 4-- 4--
= 644


owner has permissions of r+w (or 4+2) = 6
group has permissions of r (or 4) = 4
everyone not in group has permissions of r (or 4) = 4

More examples:

rwx rwx rwx
421 421 421
= 777
everyone has full permissions

r-x r-x r--
4-1 4-1 4--
= 554
owner read/execute, group read/execute,everyone else read

rw- rw- ---
42- 42- ---
= 660
owner read/write, group read/write, everyone else no access.
how do I make him the owner?
Also, this might have nothing to do with chmod, but how to I create a directory on my apache searver than people can browse? I want people to just be able to change to the "stuff" folder and see all the files that are in it, and than download from it.
chown username folder/file

(Read my first post! arg! wink.gif)

chown termina /candy
chown -R termina /candy (all files/folders in candy are now owned by termina)
But when dealing with apache, the user that runs the apache server is usually nobody or apache ... so if you want to be able to write from lunix and not the web interface, then make the owner and group be the user you want to have write permissions...

for example, if my username is johnny and my primary group is admin and I wanted to make it so only I could update my website, and it resides at /var/www, I would do this:

the chown command is used to change owners ... it can also be used to change owner and group if used in this format:

chown owner:group /directory .... using a -R would make it recursive.

so in my example, I would use this:

chown -R johnny:admin /var/www

Next, to change the permissions, I would do this:

chmod -R 644 /var/www

Now every file and directory under /var/www is owned by johnny, the group is admin, and the permissions are read,write for the user johnny, read for other members of the group admin, and read for everyone else....

If I wanted other people in the admin group to also be able to make changes to the /var/www directory, I would use the command:

chmod -R 664 /var/www
I have found this chart to be helpful when trying to figure out chmod. It's based off of the binary numbering system which shows all the possible combinations. Anywhere you see a 1 in the chart it grants the permission listed above that column. Just remember that u,g and o each gets a decimal number that comes from last column of this chart where and it tends to make it easier on me to do the conversion. chmod ugo <file/directory name> where u equals the user(owner), g equals the group and o equals everyone else. After awhile I found I didn't need the chart because you get to know the common numbering for the permissions that you want.

4 2 1
r w x
0 0 0 = 0
0 0 1 = 1
0 1 0 = 2
0 1 1 = 3
1 0 0 = 4
1 0 1 = 5
1 1 0 = 6
1 1 1 = 7
You can also use letters instead of integers when assigning permissions (some find it easier to remember). See the chmod man page for details.

Good Luck!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.