EASILY CHANGE FILE AND DIRECTORY PERMISSIONS USING CHMOD

0
155

Using the command terminal in linux can be very frustrating  if you can’t recollect all your commands,but worry no more chmod is here to help ease out some stress. So what is CHMOD ? CHMOD means ‘change mode’ and it changes file or directory mode bits (the way a file can be accessed). You can use chmod in the command line to change file or directory permissions on unix or unix-like systems such as linux or BSD. The users in chmod  can be categorized into 3 groups namely:

  1. User, meaning the user who owns the file
  2. Group, meaning the files defined ownership group
  3. Other, meaning everyone else

and these 3 groups can be given different types of access to the files or directories

  1. Read (r), meaning the ability to look at the contents of a file
  2. Write (w), meaning the ability to change the contents of a file
  3. Execute (x), meaning the ability to run the contents of a file

Chmod options

You can extend chmod permissions with options.

Most popular options are:

  • -r for ‘recursive’, include same mode in subdirectories
  • -f for ‘force’, forge ahead with all objects even if errors occur
  • -v for ‘verbose’, show objects processed

This can be very complicating so just save time and use chmodcommand

 

CHMOD categories

 

 

chmod permissions

Chmod special modes

Setuid and setgid

Setuid and setgid (short for ‘set user ID upon execution’ and ‘set group ID upon execution’, respectively) are Unix access rights flags that allow users to run an executable with the permissions of the executable’s owner or group respectively and to change behaviour in directories. They are often used to allow users on a computer system to run programs with temporarily elevated privileges in order to perform a specific task. While the assumed user id or group id privileges provided are not always elevated, at a minimum they are specific.

Setuid for a directory

The setuid permission set on a directory is ignored on UNIX and Linux systems.

Setgid for a directory

Setting the setgid permission on a directory (‘chmod g+s’) causes new files and subdirectories created within it to inherit its group ID, rather than the primary group ID of the user who created the file (the owner ID is never affected, only the group ID). Newly created subdirectories inherit the setgid bit. Thus, this enables a shared workspace for a group without the inconvenience of requiring group members to explicitly change their current group before creating new files or directories. Note that setting the setgid permission on a directory only affects the group ID of new files and subdirectories created after the setgid bit is set, and is not applied to existing entities.

All these commands can be done with chmod .

Having trouble with your file and directory permissions ? just head to https://chmodcommand.com/ and ease your worries.

 

Leave a Reply

LEAVE A REPLY

Please enter your comment!
Please enter your name here