Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Linux File Permissions

  • Please log in to reply
3 replies to this topic

#1 defurman


  • Members
  • 138 posts
  • Gender:Male
  • Location:Wales
  • Local time:01:57 AM

Posted 14 September 2013 - 01:32 PM

I already know how to change individual file permissions at the command-line but is it possible to cd to a directory and change all the files permissions within without having to enter the directory itself? Hope you can understand what i mean lol. Thanks

BC AdBot (Login to Remove)


#2 buddy215


  • Moderator
  • 13,501 posts
  • Gender:Male
  • Location:West Tennessee
  • Local time:07:57 PM

Posted 14 September 2013 - 05:07 PM

The info you are looking for is here: FilePermissions - Community Ubuntu Documentation


Scroll down to this heading (I think this is what you want):

Recursive Permission Changes

To change the permissions of multiple files and directories with one command. Please note the warning in the chmod with sudo section and the Warning with Recursive chmod section.

“Every atom in your body came from a star that exploded and the atoms in your left hand probably came from a different star than your right hand. It really is the most poetic thing I know about physics...you are all stardust.”Lawrence M. Krauss
A 1792 U.S. penny, designed in part by Thomas Jefferson and George Washington, reads “Liberty Parent of Science & Industry.”

#3 defurman

  • Topic Starter

  • Members
  • 138 posts
  • Gender:Male
  • Location:Wales
  • Local time:01:57 AM

Posted 15 September 2013 - 04:19 AM

Thanks for the help buddy215. Cheers mate!

#4 retnaut


  • Members
  • 11 posts
  • Local time:09:57 PM

Posted 29 September 2013 - 08:48 PM

Here is all you need to know. From my notebook.



  1. One Owner and Group per folder and file
  2. Multiple users can be in a group to be granted same permissions
  3. Bit level permissions allow to control if Owner, Group, and Others (Public) have permission

chmod ogp -options /directory/of/folder/file
options: -R | changes permission for all files and folders in the tree


These contain number values 1 2 and 4. 1 is execute. 2 is write. 4 is read.

example: chmod 774 /home/cmtech = owner and group can read write and execute while others can only read. 

chown username:groupname /directory/of/folder/file - changes the owner of the file or folder

chgrp groupname /directory/of/folder/file - changes group of file or folder

To apply permissions to all subfolders/files use option -R for recursive. Ex: sudo chown owner -R /home/owner

useradd username - creates new user and group that are equal
groupadd groupname - creates group
adduser username groupname - adds user to group
usermod -G groupname username - adds user to group as primary
usermod -a -G groupname username - adds user to group as secondary

Folder Inheritance/Default Permissions

Newly created folders or files created in Linux by default do not contain inherited permissions from its parent unlike in Windows. This is one feature I honestly wish was available by default, as it creates a lot of issues for public folders. For example, if we have purely public folder, but user A creates a file.. only user A will have write access to that file, so no one else will be able to delete this file. This makes it hard for Administrators to delete unnecessary files/folders or to achieve a purely public/everyone folder.

The plus side of this is that when a user creates a file in a public folder, it is only for others to view. That user will decide whether to delete it or not. This is more or less a privileged folder.. so we will call it privilege.

To enable folder inheritance.. simply use this command below. Make sure to have set all the permissions of the folder, subfolders, and files before using this command.

setfacl -R -d -m u:username:rwx,g:groupname:rwx ,o::rwx /directory
mount -o remount,acl /
source: http://superuser.com/questions/264383/set-file-permissions-so-that-new-files-inherit-same-permissions

if setfacl doesn't work, make sure to sudo apt-get instal acl

Edited by retnaut, 29 September 2013 - 08:51 PM.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users