How do I use the chgrp command in Linux?

Last updated: March 29, 2011

The chgrp command is how you change the group attribute applied to a directory or file in Linux.

The syntax to use the chgrp command for a directory:

# chgrp groupname directoryname

The syntax to use the chgrp command for a file:

# chgrp groupname filename

Now you may ask. How do I change the group ownership of a directory recursively? That means the directory and all the directories and files inside it.

The syntax to us the chgrp command for a directory recursively  requires the -R flag:

# chgrp -R groupname directoryname

Tags: linux, bash, cli, permissions




How do I use the chmod command in Linux?

Last updated: March 28, 2011

The chmod command is how you change the permissions applied to a directory or file in Linux.

The syntax to use the chmod command for a directory:

# chmod 755 directoryname

The syntax to use the chown command for a file:

# chmod 644 filename

Now you may ask. How do I change the permissions of a directory recursively? That means the directory and all the directories and files inside it.

The syntax to us the chmod command for a directory recursively  requires the -R flag:

# chmod -R 755 directoryname

With the above please note that you may not want the files to have that 775 permissions so if you just want to change the permissions of directories recursively but not touch the files in those directories you need to do something a little more advanced. If the public_html directory is a directory in your current working directory:

# find public_html -type d -exec chmod 775 {} \;

Tags: linux, bash, cli, permissions