If you’re a new user or student and want to learn how to use and manage Linux systems, the easiest place to start might be on Ubuntu Linux OS… Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other devices…
The same way one uses a mouse and keyboard to manage user permissions to limit access to files / folders or perform others simple tasks on Microsoft Windows OS, Ubuntu also makes it that easy… If you think Windows is easy to use, then Ubuntu might be just what you need and for other beginners…
However, when you’re learning to use and understand Ubuntu Linux, you’ll also want to learn the commands behind the graphics and mouse-clicking… and how to use them… This tutorial is going to show you how…..
This post shows new users and students what the chmod command is used for and how to use it…
When you’re ready to learn how to use the chmod commands, follow the guide below:
About chmod command:
The chmod command is used to define or change permissioins or modes on files and limit access to only those who are allowed access… It changes the mode of each FILE to MODE…. The chmod command stands for change mode… and it’s used to limit access to resources…
It’s a same as using your mouse to right-click a file or folder and selecting the permission tabs and defining who can access the resource…. the chmod command is the way to do it on the command line…
The syntax is the rule and format of how the chmod command can be used… the systax options can be reordered.. but a straight format must be followed.,.
Below is an example syntax of how to use the chmod comamnd….
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
The command line options are switches or flags that determined how the commands are executed or controlled… they modify the behavior of the commands… they are separated by spaces and followed after the commands…
Below are some options of the chmod command:
|FILE…||Replace FILE….. with the file you want to change its permissions|
|MODE, OCTAL-MODE||Replace the MODE (rwx) or OCTAL-MODE (777) with value to change the permission to|
|-c, –changes||Use the -c or –changes option to show verbose but report only when a change is made|
|-f, –silent, –quiet||Use the -f or –silent or –quiet option to suppress most error messages|
|-R, –recursiven||Use the -R or –recursiven option to change files and directories recursively|
|–helpn||Use the –version option to display this help and exit|
|–version||Use the –version option to output version information and exit|
Below are some examples of how to run and use the chmod on Ubuntu Linux…
If you’re a owner of a file called Confidential and want to change the permisions or modes so that user can read / write and execute, group members can read and execute only and others can only read, you will run the commands below…
sudo chmod u=rwx,g=rx,o=r Confidential
The commands above changes the permission of the file called Confidential so that user can read (r), write (w)and execute (x) it… group memebers can only read (r) and execute (x) and others can only read (x) its content…
The same command above can be written as shown below using its octal permission notation….
sudo chmod 754 Confidential
If you’re not logged in as a root account, you may have to use the sudo command it it…
sudo chmod 754 Confidential
The digit 7 is equl, read, write and execute… the digit 5 is equal, read and execute, the digit 4 is equal read…
- 4 = Read
- 2 = Write
- 1 = Execute
- 0 = no permission
So, 7 = 4 + 2 + 1 (rwx); 5 = 4 + 1 (rx); 4 (r)
To configure access to a file so only the user can read, write and execute and group / others can read, run the comands below…
sudo 744 Confidential
The commands below changes the permissions of the Confidential file so that everyone has full access…. read/write/execute
sudo 777 Confidential
When you run chmod with the –help option, you’ll see the help text below:
Usage: chmod [OPTION]... MODE[,MODE]... FILE... or: chmod [OPTION]... OCTAL-MODE FILE... or: chmod [OPTION]... --reference=RFILE FILE... Change the mode of each FILE to MODE. With --reference, change the mode of each FILE to that of RFILE. -c, --changes like verbose but report only when a change is made -f, --silent, --quiet suppress most error messages -v, --verbose output a diagnostic for every file processed --no-preserve-root do not treat '/' specially (the default) --preserve-root fail to operate recursively on '/' --reference=RFILE use RFILE's mode instead of MODE values -R, --recursive change files and directories recursively --help display this help and exit --version output version information and exit Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.
Hope you like it and please come back soon for more Ubuntu Linux command!
You may also like the commands below: