image from thegeekdiary
In linux you will learn about file permission it's will let users access to certain file on the linux. We used chmod command to change the file permissions on linux. There are two type of chmod which is symbolic and numeric. The symbolic method is good for changing one set of permissions at a time while numeric you required to know about each octal value to give certain permission for example 777 is give User : read, write, execute; group : read, write, execute; others : read, write, executeFrist thing you need to know about role flag on file. its user owner, group owner and other.
user owner : is the user who created the file
group owener : is the group name which user who created the file belong to
other : other user not in the system
let's we check :
sysadmin@localhost:~/perm$ touch andre.txt
sysadmin@localhost:~/perm$ ls -l
total 0
-rw-rw-r-- 1 sysadmin sysadmin 0 May 9 06:22 andre.txt
- The red one is for users owner
- The blue one is for group owner
- The green one is others
- The higlighted yelow is user owner
- The higlighted green is group owner
- The higlighted green is group owner
Now you already know to flag on file, we can continue to the next material.
I already mention in the begining that we have two method which is symbolic and numeric
First you need to understand the symbol below for object
Symbol Group
u user owner
g group owner
o others
a all (user owner, group owner, and others)
Second you need to understand the symbol below for permission
Symbol Permission
r read
w write
x execute
Symbol Operation
+ add the permission, if necessary
= specify the exact permission
- remove the permission, if necessary
We already create the file called andre.txt in the begining
sysadmin@localhost:~/perm$ ls -l
total 0
-rw-rw-r-- 1 sysadmin sysadmin 0 May 9 06:22 andre.txt
sysadmin@localhost:~/perm$ chmod u+x andre.txt
sysadmin@localhost:~/perm$ ls -l
total 0
-rwxrw-r-- 1 sysadmin sysadmin 0 May 9 06:22 andre.txt
We try to remove group write permission
sysadmin@localhost:~$ chmod g-w andre.txt
sysadmin@localhost:~$ ls -l andre.txt
-rwxr--r-- 1 sysadmin sysadmin 0 Mar 21 18:10 andre.txt
One more example we try to give others exact read permission, remove write from group and add executeable to user
sysadmin@localhost:~$ chmod o=wr,g+w,u-x andre.txt
sysadmin@localhost:~$ ls -l andre.txt
-rw-rw-rw- 1 sysadmin sysadmin 0 May 9 06:22 andre.txt
Numeric method :
The other method beside symbolic is numeric rather than using alpabet the numeric method using octal number to define permission on the linux. It's look wierd at the first time but if you know the concept it's also easy to use.
Fitst thing you have to understand well about the concept below
Octal Value Permission
4 read
2 write
1 execute
0 none
xample numeric method
Fitst thing you have to understand well about the concept below
Octal Value Permission
4 read
2 write
1 execute
0 none
xample numeric method
I try to put
sysadmin@localhost:~/perm$ chmod 444 andre.txt
sysadmin@localhost:~/perm$ ls -l
total 0
-r--r--r-- 1 sysadmin sysadmin 0 May 9 08:46 andre.txt
sysadmin@localhost:~/perm$ chmod 764 andre.txt
sysadmin@localhost:~/perm$ ls -l
total 0
-rwxrw-r-- 1 sysadmin sysadmin 0 May 9 08:46 andre.txt
Both symbolic and numeric is just flavour and it's will result the same :)
Tulis komentar anda... Conversion Conversion Emoticon Emoticon