Hello .... Friends , in the last tutorial we discus about the creating text files , creating directories, Deleting files & Deleting Directories . now in this tutorial we are going to discuss about the file permissions. we knows well the Linux or the Unix is a multi-programming as well as multi-user Operating system. then who can access the files & how the Remote user can use any file that means read, write, and execute the file. & how to become a super user temporarily.
so in this tut we are going to discus about these of following commands.
so in this tut we are going to discus about these of following commands.
- chmod
- su
- chown
- chgrp
Now let's understand the permissions . how to check the permissions & how to change them.
to check the permissions of a file we can check ls -l file_name
if we want to check the permissions of Null3 then these are the permission as shown in the image.
-rw-r--r-- 1 nullport nullport 0 Aug 26 12:10 Null3
these are the permissions 644 for this file here 644 means the user here nullport only the person how can write this file & other users only can read the file . this is the Default permissions for any file we create.
& Now if we want to check the permissions for all the files & directory then we can use the options ls -l without giving the name of any file.
here in my home directory i create various files & try to change there permissions to understand the basic
Now if we try to cover this in more deep then understand about this 644 & 777 etc.
rwx rwx rwx = 111 111 111
rw- rw- rw- = 110 110 110
rwx --- --- = 111 000 000
(Note: if you do not knows how 111 is 7 then use my shot cut 8421. method of binary to desimal conversion.)
if we check the binary of 111 stand for 7 and as well 110 for 6 for a particular user let's clear more
rwx = 111 in binary = 7
rw- = 110 in binary = 6
r-w = 101 in binary = 5
r-- = 100 in binary = 4
so can we makes the permissions for any particular files for any particular user
we are discussing some here
777 = (rwxrwxrwx) that means no restrictions for anyone or we can say anyone can do anything. here the security challenges. if we need to secure any file in the system need to change such type of settings.
755 = (rwx-xr-x) that means only the file user can change ,read,write or execute the file . and all other may read and execute the file. they have no permissions to change it.
700 = (rwx------) that means the file owner may read,write, and execute the file. and nobody else has any rights.this is the best permissions for the file which only the owner want to see. & must be kept private from others.
666 = (rw-rw-rw-) that means all users can read and write the file.
644 = (rw-r--r--) that means owner may read and write the file while other may only read the file. only the owner can change the file.
600 = (rw-------) that means owner may read and write the file. all other users have no writes to do anything with file.
Now i think this all makes all clear about file permissions.
so if we want to change the permissions of any file in Linux or Unix operating system then we can simple use the chmod command as chmod 700 file_name
try to change permissions of any directory with this chmod method.
- su : change user ID or become superuser
su command is used for changing or become the super user for any user temporarily . sometime we need to become superuser to perform some important system administrator tasks. and we should not stay logged on as superuser. this command gives us the superuser privileges.
now nullport is a superuser. & here i am in other shell with administrator privileges.
and if we want to go in the previous user stage then we just need to type exit command.
- chown : change file owner and group
if we want to change the ownership of a file or dir. then we use this command chmod user file_name
but before that we need to have superuser privileges and after that we have to exit . let's check it in our Sabayon linux for any file. here we are creating a file with touch command and try to change the ownership from nullport to root user.
-rw-r--r-- 1 nullport nullport 0 Aug 26 14:52 simple (before)
-rw-r--r-- 1 root nullport 0 Aug 26 14:52 simple (after )
- chgrp : change group ownership
if we want to change the ownership of a group then we need to have super user privileges and then just need to type chgrp grup_name file_name . i just create a file here with name admin with admin privileges. and now we need to change the grup from root to nullport . so let's check it
-rw-r--r-- 1 root root 0 Aug 26 15:21 admin
-rw-r--r-- 1 root nullport 0 Aug 26 15:21 admin
here we changed the file admin from root to nullport.
here we are not disusing this all for directories that was the same try it your self for more better understanding.
i think you can easily understand it . plz leave comments behind i will try to improve my tutorials. thank you.
No comments:
Post a Comment