chmod command Linux Centos 8/Redhat8/Oracle Linux

chmod command Linux Centos 8/Redhat8/Oracle Linux

Hello colleagues.

In Linux, the permissions system is important. In Linux, there are only three types of rights: the right to read, write and execute. As well as three categories of users to which they can apply: the owner of the file, the group of the file, and all other users.

In this article, we will explore how to change permissions in Linux using practical examples of the chmod command. The article is suitable for novice system administrators and for those who want to refresh their memory. We look.

 

The content of the article:

  1. chmod command.
  2. Examples with the chmod command.

 

1. chmod command.

The chmod command has the following syntax:

$. sudo chmod [u/g/o] +/- r/w/x file/directory

 

What is chmod anyway? chmod stands for change mode. This command is used to change the access mode. And it has three modes of change.

  1. r - reading.
  2. w - record.
  3. x - performance.

 

Well, there are three categories of users for which you can set the rights to a file or directory in Linux.

  1. u - owner (user).
  2. g - group.
  3. o - all other users.

 

Signs are used as actions.

  1. +  Add right.
  2. -  Delete right.

 

2. Examples with the chmod command.

Example 1: The user can only read.

$. sudo chmod u+r start.sh

Example 2. The user can only write.

$. sudo chmod u+w start.sh

Example 3: The user can only execute.

$. sudo chmod u+x start.sh

Example 4: The user can only read and write.

$. sudo chmod u+rw start.sh

Example 5: The user can only read and execute.

$. sudo chmod u+rx start.sh

Example 6. The user can only write and execute.

$. sudo chmod u+wx start.sh

Example 7. The user can read write and execute.

$. sudo chmod u+rwx start.sh


Example 8. A group can only read.

$. sudo chmod g+r start.sh

Example 9. A group can only write.

$. sudo chmod g+w start.sh

Example 10. A group can only execute.

$. sudo chmod g+x start.sh

Example 11. A group can only read and write.

$. sudo chmod g+rw start.sh

Example 12: A group can only read and execute.

$. sudo chmod g+rx start.sh

Example 13. A group can only write and execute.

$. sudo chmod g+wx start.sh

Example 14. A group can read write and execute.

$. sudo chmod g+rwx start.sh


Example 15. Everyone else can only read.

$. sudo chmod o+r start.sh

Example 16. Everyone else can only write.

$. sudo chmod o+w start.sh

Example 17. Everything else can only be performed.

$. sudo chmod o+x start.sh

Example 18. Everyone else can only read and write.

$. sudo chmod o+rw start.sh

Example 19. Everyone else can only read and execute.

$. sudo chmod o+rx start.sh

Example 20. Everyone else can only write and execute.

$. sudo chmod o+wx start.sh

Example 21. Everyone else can read write and perform.

$. sudo chmod o+rwx start.sh


Example 22: User and group are read-only.

$. sudo chmod ug+r start.sh

Example 23. User and group can only write.

$. sudo chmod ug+w start.sh

Example 24: User and group can only execute.

$. sudo chmod ug+x start.sh

Example 25: User and group can only read and write.

$. sudo chmod ug+rw start.sh

Example 26: User and group can only read and execute.

$. sudo chmod ug+rx start.sh

Example 27: User and group can only write and execute.

$. sudo chmod ug+wx start.sh

Example 28. User and group can read write and execute.

$. sudo chmod ug+rwx start.sh


Example 29: User and group and everyone else can only read.

$. sudo chmod ugo+r start.sh

Example 30. User and group and everyone else can only write.

$. sudo chmod ugo+w start.sh

Example 31. User and group and everyone else can only execute.

$. sudo chmod ugo+x start.sh

Example 32: User and group and everyone else can only read and write.

$. sudo chmod ugo+rw start.sh

Example 33: User and group and everyone else can only read and execute.

$. sudo chmod ugo+rx start.sh

Example 34. User and group and everyone else can only write and execute.

$. sudo chmod ugo+wx start.sh

Example 35. User and group and everyone else can read write and execute.

$. sudo chmod ugo+rwx start.sh


In these examples, we only added rights, well, to take away the rights, you need to change + instead of - and that's it.

 

Thank you all, I hope my article was of some help to you.

 

SIMILAR ARTICLES

tar utility - how to zip and unzip files in linux
tar utility - how to zip and unzip files in linux
LINUX
Read more
How to find out the size of a file and directory in Linux
How to find out the size of a file and directory in Linux
LINUX
Read more
bzip2 utility - how to compress and decompress files in Linux
bzip2 utility - how to compress and decompress files in Linux
LINUX
Read more