Linux – Change Permissions and Ownership for Files and Folders (chmod, chown, members, groups)

The commands chown and chmod allow you to change permissions and ownership of files and folders, but you also need to know the membership of groups to make sure permissions and ownership is appropriate.

View Group Membership

  • groups – shows groups you belong to
  • groups username – shows groups user belongs to
  • cat /etc/group | less – Allows you to view Group file that has all groups and members
  • members groupname – Shows members of a specific group
  • Members is not installed by default in Ubuntu. Install with: sudo apt-get install members

Change Ownership of Files and Folders

  • chown owner:group file – Changes Account Owner and Group Owner of File
  • chown :group file – Changes Group Owner of File
  • chwon -R owner:group folder – Changes Account Owner and Group Owner of Folder and changes contents recursively

Change Permissions

  • chmod 777 file – Changes permissions of file so that Account Owner can RWX, Group Owner can RWX, and Everyone can RWX
  • chmod -R 777 folder – Changes permissions of Folder and Contents so that Account Owner can RWX, Group Owner can RWX, and Everyone can RWX
  • -R is for recursive which means the contents of the folder will be changed also

Be the first to comment

Leave a Reply