Getting to Know Linux Security: File Permissions
Source: Benjamin D. Thomas - Posted by Benjamin D. Thomas   
Features Welcome to the first tutorial in the 'Getting to Know Linux Security' series. The topic explored is Linux file permissions. It offers an easy to follow explanation of how to read permissions, and how to set them using chmod. This guide is intended for users new to Linux security, therefore very simple. If the feedback is good, I'll consider creating more complex guides for advanced users. Please let us know what you think and how these can be improved. If you have ideas for future topics, please post them in the discussion forum below.

Click image to begin tutorial.

Script

Hello, my name is Benjamin Thomas and I am with Guardian Digital, Inc, the primary sponsor of LinuxSecurity.com Welcome to the first of the "Getting to know Linux Security" series tutorials that will be featured on our site. Today's topic is file permissions. This lesson is primarly intended for those users who are just getting started, and other wishing to brush up old skills. The examples I show you today are from a typical Linux command line. Today, I'll be using EnGarde Secure Linux. More information about this distribution can be found at Guardian Digital.com and it can be downloaded at EnGardeLinux.org.

...

Lets Begin. To see a listing of files in a directory, execute the command 'ls'. As you'll see, there are no files in the temporary directory that I'm using. Let's first create several files.

touch file1 file2 file3

The command 'ls' then shows the files we have created. A more informative way to show the files is ls -la. The 'l' switch lists files in long format, and the 'a' switch lists all files, including hidden ones.

...

Lets look at file1 (select line) The first field reprents the file's type. For regular files this is always a dash, for directories, it will be reprented as a d. (There are other's, but beyond the scope of this lesson) The next nine represent the file's permission. The the number of 'hard' links to the file, the file owner's username, the owner's group, the file's size, its modification date and time, and the file's name.

...

Lets examine the permission field closer. The first three blocks represents the access granted to the file's owner. The next three, represent access granted to other group members, and the last three represent everyone else's level of access. The possibilities for permissions include:

r - read
w - write
x - execute
- - no permission

...

If you are the owner of a file, you have the ability to change its permissions with the chmod command. There are several ways chmod can be used, however in today's lesson I will only focus on the octal system. The first number represents the owner's permission, the 2nd represents the groups permission, and the last one' represents the world's or everyone's access. The permission is calculated using simple arimetic. 1 is for exectute permission 2 is for write permission 4 is for read permission

The permission is set using the chmod command:

chmod 755 file1

You may asking, but what does 755 mean? 7 comes from 1 + 2 + 4. 5 comes from 1 + 4. This means that the file's owner has read, write, and execute permission, but group and world only have read and execute.

...

Overtime you'll find that this method of setting permissions becomes natural. After getting comfortable with this method you'll find that Linux permisssion aren't difficult at all to understand.

...

Once again, thank you for visiting LinuxSecurity.com. I hope you have found this guide helpful and you are looking forward to other tutorials in the Getting to know Linux Security series. Please do no hesitate to send comments, questions, or ideas to me at the following email address: ben@linuxsecurity.com

...

This guide has been sponsored by Guardian Digital, creators of EnGarde Secure Linux. www.guardiandigital.com

Comments
spelling errorWritten by David on 2006-04-03 17:57:29
"arimetic" == "arithmetic" in the article. 
 
good article, though.
Written by ASIM on 2006-05-06 06:11:43
THis is my first time here on this website and I am a new user on Linux. the lecture was excellent and to the point
Linux permissions - number viewWritten by albert on 2006-06-30 09:39:52
I am linux newbee. This was easy and understandable. 
 
Thank you.
Written by Daniel C on 2006-09-07 02:49:37
Excellent Tutorial, I now finally understand what these numbers mean. Thank you!Written by Zim on 2008-09-13 17:48:47Useful, thanks!
thanksWritten by Tory on 2008-11-15 21:01:50
Yeeeah, that was useful, thank you
Linux file permissions for absolute begiWritten by David on 2008-12-07 13:12:12
Here is how I remembered the linux file permissions with examples of changing them by command line  
 
USER GROUP OTHER 
 
u g o 
rwx rwx rwx 777 
read write execute 
 
-rwxr--r-- 744  
 
user has rwx group has r-- and other has r-- also, read only for all but the user 
 
0 --- 
1 --x 
2 -w- 
3 -wx 
4 r-- 
5 r-x 
6 rw- 
7 rwx 
 
 
at the command prompt type 
 
touch myfile.txt  
 
chmod 755 myfile.txt 
 
ls -l  
 
results in this 
 
-rwxr-xr-x 1 root root 37 2008-12-07 15:50 myfile.txt 
------------------------------------------------- 
then change to this 
 
chmod 700 myfile.txt  
 
ls -l 
 
results in this 
 
-rwx------ 1 root root 37 2008-12-07 15:50 myfile.txt 
--------------------------------------------------------- 
 
 
chmod 744 myfile.txt 
 
ls -l 
 
-rwxr--r-- 1 root root 37 2008-12-07 15:50 myfile.txt 
 
and so on..

Only registered users can write comments.
Please login or register.

Powered by AkoComment!