Howto modify permissions by chmod on Centos 6 or Redhat 6 RHEL

Howto modify permissions by chmod on Centos 6 or Redhat 6 RHEL

 

Before go to this, please read this article to understand about file permission on Linux

http://ithelpblog.com/os/linux/how-to-understand-linux-file-permissions/

1. List file with permission

[root@dhcppc51 ~]# ls -lah
total 30M
dr-xr-x—. 29 root root 4.0K Dec 14 19:21 .
dr-xr-xr-x. 22 root root 4.0K Dec 14 17:48 ..
-rw-r–r–. 1 root root 185K Dec 9 19:24 a
-rw——-. 1 root root 2.7K Dec 8 01:20 anaconda-ks.cfg
-rw——-. 1 root root 5.9K Dec 15 06:19 .bash_history
-rw-r–r–. 1 root root 18 May 20 2009 .bash_logout
-rw-r–r–. 1 root root 176 May 20 2009 .bash_profile
-rw-r–r–. 1 root root 176 Sep 22 2004 .bashrc
drwxr-xr-x. 2 root root 4.0K Dec 7 18:24 .cache
drwxr-xr-x. 4 root root 4.0K Dec 7 18:23 .config
-rw-r–r–. 1 root root 100 Sep 22 2004 .cshrc
drwx——. 3 root root 4.0K Dec 7 18:23 .dbus
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Desktop
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Documents
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Downloads
-rw-r–r–. 1 root root 15K May 10 2012 epel-release-6-7.noarch.rpm
-rw——-. 1 root root 16 Dec 7 18:23 .esd_auth
drwx——. 4 root root 4.0K Dec 7 18:23 .gconf
drwx——. 2 root root 4.0K Dec 7 18:44 .gconfd
drwxr-xr-x. 3 root root 4.0K Dec 8 22:28 .gem
drwx——. 5 root root 4.0K Dec 7 18:23 .gnome2
drwxr-xr-x. 3 root root 4.0K Dec 7 18:23 .gnote
drwx——. 2 root root 4.0K Dec 12 19:40 .gnupg
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 .gstreamer-0.10
-rw-r–r–. 1 root root 107 Dec 7 18:23 .gtk-bookmarks
drwx——. 2 root root 4.0K Dec 7 18:23 .gvfs
-rw——-. 1 root root 314 Dec 7 18:23 .ICEauthority
-rw-r–r–. 1 root root 40K Dec 8 01:20 install.log
-rw-r–r–. 1 root root 9.9K Dec 8 01:17 install.log.syslog
drwxr-xr-x. 3 root root 4.0K Dec 7 18:23 .local
-rw-r–r–. 1 root root 1.4K Dec 9 19:48 mac.txt
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Music
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 .nautilus
-rw-r–r–. 1 root root 5.2K Sep 23 15:47 pgdg-centos92-9.2-6.noarch.rpm
-rw-r–r–. 1 root root 5.2K Sep 23 15:47 pgdg-redhat92-9.2-7.noarch.rpm
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Pictures
drwxr—–. 3 root root 4.0K Dec 10 07:02 .pki
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Public
drwx——. 2 root root 4.0K Dec 7 18:23 .pulse
-rw——-. 1 root root 256 Dec 7 18:23 .pulse-cookie
-rw-r–r–. 1 root root 35K Dec 9 19:34 results
-rw——-. 1 root root 1.0K Dec 12 19:52 .rnd
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 .spice-vdagent
drwx——. 2 root root 4.0K Dec 7 18:23 .ssh
drwxr-xr-x. 3 root root 4.0K Dec 10 16:16 .subversion
-rw-r–r–. 1 root root 129 Dec 3 2004 .tcshrc
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Templates
-rw-r–r–. 1 root root 8.9M Nov 15 17:32 usermin-1.530-1.noarch.rpm
drwxr-xr-x. 2 root root 4.0K Dec 7 18:23 Videos
-rw-r–r–. 1 root root 239 Dec 9 19:09 wapscan.gnmap
-rw-r–r–. 1 root root 239 Dec 9 19:09 wapscan.nmap
-rw-r–r–. 1 root root 1.1K Dec 9 19:09 wapscan.xml
-rw-r–r–. 1 root root 21M Nov 15 14:45 webmin-1.610-1.noarch.rpm
drwxr-xr-x. 2 root root 4.0K Dec 12 01:22 .wireshark
-rw——-. 1 root root 66 Dec 13 02:12 .xauth0Vw6Xt
-rw——-. 1 root root 66 Dec 9 18:36 .xauthMgjCHb
-rw——-. 1 root root 66 Dec 14 19:21 .xauthsOonaB
[root@dhcppc51 ~]#

2. Change permission to a file or folder

Examples:

[root@dhcppc51 ~]# chmod 777 results
[root@dhcppc51 ~]# ls -lah results
-rwxrwxrwx. 1 root root 35K Dec 9 19:34 results
[root@dhcppc51 ~]#
[root@dhcppc51 ~]# chmod 644 results
[root@dhcppc51 ~]# ls -lah results
-rw-r–r–. 1 root root 35K Dec 9 19:34 results
[root@dhcppc51 ~]#
[root@dhcppc51 ~]# ls -lah results
-rwx——. 1 root root 35K Dec 9 19:34 results
[root@dhcppc51 ~]#
[root@dhcppc51 ~]# chmod -R 777 Music/

–> This command will change all permision for folder and all files in that folder.

That’s all. Thanks for using IThelpblog.com

 

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>