Friday, January 2, 2015

Changing permissions use chmod command in linux

Leave a Comment
How to change permissions in linux? To change the permissions for file or directory in linux, you use chmod command. in this articles, descriptions and step by step via for example.

chmod command

The chmod command use two arguments at minimum: the criteria/numeric and filename to change.

Syntax
chmod [Criteria/numeric ] [file-to-change]

chmod command
Criteria
chmod command
numeric 

For example chmod command

For example use criteria
[root@localhost ~]# ls -l
total 28
drwxr-xr-x. 5 root root 4096 Nov 14 13:12 newfolder
drwxr-xr-x. 2 root root 4096 Dec 18 19:17 perlPro
-rw-r--r--. 1 root root  606 Nov 13 05:56 test1-rw-r--r--. 1 root root  618 Nov 13 05:48 test2
-rw-r--r--. 1 root root   35 Nov 13 05:52 test3
-rw-r--r--. 1 root root   72 Nov 14 22:23 test4
-rw-r--r--. 1 root root    9 Nov 18 00:33 test6
Change the permissions test1 file with : user: read, write, execute. Group: Read, Write. Other: execute
[root@localhost ~]# chmod u+rwx,g+rw,o+x test1[root@localhost ~]# ls -l
total 28
drwxr-xr-x. 5 root root 4096 Nov 14 13:12 newfolder
drwxr-xr-x. 2 root root 4096 Dec 18 19:17 perlPro
-rwxrw-r-x. 1 root root  606 Nov 13 05:56 test1-rw-r--r--. 1 root root  618 Nov 13 05:48 test2
-rw-r--r--. 1 root root   35 Nov 13 05:52 test3
-rw-r--r--. 1 root root   72 Nov 14 22:23 test4
-rw-r--r--. 1 root root    9 Nov 18 00:33 test6
Change the permissions test1 with: user: read. Group: read,write. other: nothing
[root@localhost ~]# chmod u-wx,o-rx test1[root@localhost ~]# ls -l
total 28
drwxr-xr-x. 5 root root 4096 Nov 14 13:12 newfolder
drwxr-xr-x. 2 root root 4096 Dec 18 19:17 perlPro
-r--rw----. 1 root root  606 Nov 13 05:56 test1-rw-r--r--. 1 root root  618 Nov 13 05:48 test2
-rw-r--r--. 1 root root   35 Nov 13 05:52 test3
-rw-r--r--. 1 root root   72 Nov 14 22:23 test4
-rw-r--r--. 1 root root    9 Nov 18 00:33 test6
For example use numeric
[root@localhost ~]# ls -l
total 28
drwxr-xr-x. 5 root root 4096 Nov 14 13:12 newfolder
drwxr-xr-x. 2 root root 4096 Dec 18 19:17 perlPro
-r--rw-r--. 1 root root  606 Nov 13 05:56 test1
-rw-r--r--. 1 root root  618 Nov 13 05:48 test2
-rw-r--r--. 1 root root   35 Nov 13 05:52 test3
-rw-r--r--. 1 root root   72 Nov 14 22:23 test4
-rw-r--r--. 1 root root    9 Nov 18 00:33 test6
Change the permissions test2 file: user: Read, Write, execute. Group: Read, Execute. Other: nothing
[root@localhost ~]# chmod 750 test2[root@localhost ~]# ls -l
total 28
drwxr-xr-x. 5 root root 4096 Nov 14 13:12 newfolder
drwxr-xr-x. 2 root root 4096 Dec 18 19:17 perlPro
-r--rw-r--. 1 root root  606 Nov 13 05:56 test1
-rwxr-x---. 1 root root  618 Nov 13 05:48 test2-rw-r--r--. 1 root root   35 Nov 13 05:52 test3
-rw-r--r--. 1 root root   72 Nov 14 22:23 test4
-rw-r--r--. 1 root root    9 Nov 18 00:33 test6
Copyright by: www.linuxoperatingsystem.info http://goo.gl/kMscJ4

0 comments:

Post a Comment