Contributor
Kyle
October 24
Edit

How to Manage File and Folder Permissions in Linux

Command line: File permissions

The commands for modifying file permissions and ownership are:

chmod – change permissions

chown – change ownership.

  • chmod – the command to modify permissions
  • R – this modifies the permission of the parent folder and the child objects within
  • ugo+rw – this gives User, Group, and Other read and write access.

The breakdown of permissions looks like this:

  • u – user
  • g – group
  • o – other

The 'other' entry is the dangerous one, as it effectively gives everyone permission for the folder/file. The permissions you can give to a file or folder are:

  • r – read
  • w – write
  • x – execute

Using the -R switch is important. If you have a number of sub-folders and files within the SHARE directory, and you want the permissions to apply from the parent object (the containing folder) to the child objects (the sub-folders and files), you must use the -R (recursive) switch so the same permissions are applied all the way to the deepest folder, contained within the parent.

Command line: File ownership

sudo chown -R bethany /DATA/SHARE

  • chown – the command for changing ownership
  • R – the recursive switch to make sure all child objects get the same ownership changes
  • bethany – the new owner of the folder
  • /DATA/SHARE – the directory to be modified

Send us a message. We will reply as soon as we can.