Chmod Command - Chmod Common Command & Description

04/14/2017 11:30 PM by Ellys Kho in Web development

If you are a Linux or UNIX user, you must know some useful commands that can be used in the operating system. One of the most used commands for Linux and UNIX is the chmod command. Chmod stands for change mode which is what the command does. It is used to change the permissions of the files and directories in your system. The usage of the command is quite simple and the syntax is as follows:

chmod options permissions filename

You can put the necessary information in this syntax and you can change the https://www.myseotools.co.uk/blog/chmod-calculator-chmod-permission-and-chmod-sample.phpfile permissions. All of syntax must be written in short forms so that the operating system understands it. Suppose if you want a file such that the current user can read, write and execute it, members of groups can read and execute it and others may only read it, the following command shall be written:

chmod u=rwx, g=rx, o=r myfile

Chmod Command Illustration

Chmod Command Technical Description

As you now know, the chmod command is used to change file permissions, the technicalities behind it will explain the function in a better way. When you execute the chmod command, the file mode for every specified file is changed. Usually, they are symbolic representations or octal numbers which indicate the bit pattern.

There are combinations of letters that can be used to execute a command just like we saw earlier in an example. Even numbers are used for the same purpose. There are few set letters and numbers that allow you to write the command and it is necessary for you to know about them.

Setuid and Setgid Bits

Every time you write the chmod command, it preserves the directory's setuid and setgid. But if you specifically ask it not to, it won't preserve the ids. There are two different modes alphabetic and numerals and you can use any of them to get your desired result.

Restricted Deletion Flag

Now we all must have imagined that couldn’t someone who is unauthorized can change the file type or mode? With the help of Restricted Deletion Flag, no one can change the file type and permissions unless they own that file. This is a sorted way to manage the whole system securely and efficiently. There are some world writable directories such as the /temp file we all have in our systems and it is used in them. There is also something known as the sticky bit which stores important data so that it loads quickly when opened again.

Chmod Command Examples

Following are some examples of how the command can be used in various circumstances:

chmod u+s file.txt

When you write this command, you are setting the user id for the file so that everyone can access it as if they are the owner.

chmod 666 file.txt

The above command can set the permissions as read and write by everyone. This is a useful shortcut to know.

Some related Commands to chmod

Chown – You can change the ownership of files through this command.

Ls – A popular command which lists all the directories and files in a system.


leave a comment
Please post your comments here.

  Latest Articles
Blog Directory