Jump to content

File Permissions: Difference between revisions

No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
File permissions and chmod
This is a tutorial on how to use file permissions and the chmod command.




== What are file permissions? ==
== What are file permissions? ==


File permissions are important, they specify what you let people do to your files. There are generally three types of file permissions:
File permissions are rather important as they specify what you let people do to your files. There are generally three types of file permissions:


* Read Permission
* Read Permission
Line 32: Line 32:
* Others
* Others


Basically, this means everyone else. e.g. those outside of your group, or another very important example is webpages. You need to specify others to allow people to view your HTML files.
Basically, this means everyone else, eg - those outside of your group. Another very important example is webpages as you need to specify others to allow people to view your HTML files.


* All
* All
Line 79: Line 79:
  -rwxr--r--
  -rwxr--r--


and so on.
and so on. These are the permissions that you've set. There are ten spaces there for characters if you notice. The first 'bit' as we call it, tells us if it's a directory. If there's a 'd' there, then it is a directory, otherwise, if there's a '-' there, then it's a file.
 
These are the permissions that you've set. There are ten spaces there for characters if you notice. The first 'bit' as we call it, tells us if it's a directory. If there's a 'd' there, then it is a directory, otherwise, if there's a '-' there, then it's a file.


Now, divide the remaining nine characters into three groups of three. The first group of three represent the permissions for 'user', the next three for 'group' and the last three for 'others'. The first 'bit' of any of these three groups represent whether that group has 'read' permission (a '-' means no). The next bit means 'write' permission, and the third bit means 'execute' permission.
Now, divide the remaining nine characters into three groups of three. The first group of three represent the permissions for 'user', the next three for 'group' and the last three for 'others'. The first 'bit' of any of these three groups represent whether that group has 'read' permission (a '-' means no). The next bit means 'write' permission, and the third bit means 'execute' permission.
Line 88: Line 86:


  Permission Binary Octal
  Permission Binary Octal
  rwx        111    7
  rwx        111    7
  rw-        110    6  
  rw-        110    6  
Line 98: Line 95:
  ---        000    0
  ---        000    0


So all you have to do is stick the numbers together for the three groups, some examples would be
So all you have to do is stick the numbers together for the three groups, some examples would be rwxr-xr-x, which is rwx r-x r-x, or 111 101 101, or in octal, 755 which means that to set the permission for rxwr-xr-x, you type:
 
rwxr-xr-x which is rwx r-x r-x or 111 101 101 or in octal, 755 which means that to set the permission for rxwr-xr-x, you type:


  chmod 755 filename
  chmod 755 filename
Line 112: Line 107:
For webpages, you should remember the following:
For webpages, you should remember the following:


Your home directory (~) should be go+x or 711, so use the command chmod 711 ~ (return). Your public_html folder must also be go+x or 711, so again, use chmod 711 ~/public_html (return). All subfolders of your public_html to be used by your website must be go+x or 711 as well...
Your home directory (~) should be go+x or 711, so use the command chmod 711 ~ (return). Your public_html folder must also be go+x or 711, so again, use chmod 711 ~/public_html (return). All subfolders of your public_html to be used by your website must be go+x or 711 as well... See [[Webspace]] for more info on webpages on Redbrick.


Finally, all files, eg HTML files, must be go+r or 644. You can use a recursive chmod to change all files in public_html or subdirectories of public_html to have permission 644, by using the command chmod 644 ~/public_html/*.
Finally, all files, eg HTML files, must be go+r or 644. You can use a recursive chmod to change all files in public_html or subdirectories of public_html to have permission 644, by using the command chmod 644 ~/public_html/*.


You can get more detailed information on chmod by typing man chmod at the prompt and of course, contact [[Helpdesk]] if you have any problems.
You can get more detailed information on chmod by typing man chmod at the prompt and of course, contact [[Helpdesk]] if you have any problems.
== lil_cain and file permissions ==
One day in #lobby, lil_cain, at this point an elected systems administrator, decided he was having trouble with Linux and asked the kind people of RedBrick for help. His question was something along the lines of "how do I check the permissions for a file in a directory?"
Now, as everyone knows, you can check the permissions of all files in a directory using either
ls -l
or
ls -al
ls is one of the most basic commands EVAR!!1!!!11 lil_cain U DESERVE NO R00T!1!!
<-->
Actually, what I was looking for is stat. It's a far better tool for individual files.
<--->
Orly? I just remember "thanks".
[[Category:Helpdesk]]
244

edits