How To Use Chmod For Access Rights On Linux

how to use chmod for access rights on.

 How To Use Chmod For Access Rights On Linux


How to Use Chmod


Hello Sob! This time the admin will explain how to use chmod for permissions on Linux. Chmod itself is a command in Linux whose name comes from the word Change Mode (change mode). This command is used to change the mode of a file or folder. How to use chmod is quite easy but you must first understand the properties and additional code for this chmod command.


In Linux, rules about user access rights to the system, especially file or directory access. Giving the attribute (permission) to the file indicates the level of user access rights to a file. You can use the ls -l command to see the permissions of a file


Access rights or file permissions use a 10-bit format, which is divided into four groups as follows.

  * The first bit or the leftmost 1 bit is the file type information.

  * The next 3 bits of the first bit (2, 3, 4) is information about access permissions for the fule owner (user).

  * The next 3 bits (5,6,7) are to indicate the access permissions of users who are in the same group as the owner of the file (other,g).

  * The last 3 bits (8th bits,9,10) show the access permissions of users who are not in the same group as the file owner (other,o).


User accounts on Unix or Linux operating systems are divided into several categories, namely:

  * User and file owner

  * Users who are in the same group as the user or the owner of the file.

  * Other users who are not in the same group as the owner of the file.


Each user, has limitations and different access rights from each other to a file or the system itself. Each policy applied will be classified in a group to determine the extent to which a user is authorized to access information on a file.


Also Read: 25 Basic Linux Commands to Learn

TABLE OF CONTENTS

1. Symbol of reading permissions for a file

2. Permission Bit Value

3. User Code

4. Conclusion

Symbol for reading permissions for a file


d Directory Shows that the file you are currently accessing is a directory

r Read Access rights that allow the user to read the contents of the file

w Write An access right that allows the user or users to make edits in the form of writing, adding or deleting the contents of the file

x Execute A sign that the file can be executed directly on the system by calling the name of the file. The condition for an executable file is that the file contains program script information that can be run by Linux or Unix operating systems which can contain C, Perl, or shell programming languages.

s Suid This s symbol has the same definition as the x symbol which means it can be executed as a program that should only be run by the root user level. In addition, the symbol s is also intended as a file belonging to the system so that every user in the system can run it. For example, a file that uses the s attribute is a file that functions to access hardware

– None If this flag is present in the first bit, it indicates that this is a data file not a directory. However, if it is located in another position, it means that the user does not have the right to read, modify, or execute


The following is an example of a property of file permissions when accessed.


-rwxrwxrwx

  * The first bit contains information that the type is a data file.

  * Bits 2,3, and 4 are rwx which means that the file allows the user to be able to read, then write and execute it.

  * Bits 5,6, and 7 are rwx which means that the condition to be able to read the contents of the file, then write the contents of the file, and execute it is that the user must be in the same group as the user who owns the file.

  * The last bits 8,9, and 10 are rwx which indicates that even if the user who accesses the file is not in the same group as the user who owns the file, it can read the contents of the file, write or add the contents of the file, and can even execute it.


To configure the permissions of a file or directory using the command:


#chmod (option) (bitpermission) filename_or_directory


Policies generally applied by Linux and Unix systems basically by default set the permissions of a file or directory when created in the -rw-r-r– format, which means that the file or directory can be read by everyone, and only the owner. who can change or delete it. The chmod command can be used to reconfigure the default value of the file or directory permissions configuration. The most frequently used option is -R (recursive). This option code has the purpose of providing general access rights for a directory and its subdirectories and the contents of that directory. Usually this option is often used when you configure the cache storage working directory on a Proxy Server that uses the Squid package. In addition to using the method of granting permissions to files or directories, you can configure using bit permissions with a numerical model. The following is a list of bit values ​​table

permissions.


Permission Bit Value


Value Bit Permission

0 —

1 –x

2 -w-

3 -wx

4 r–

5 r-x

6 rw-

7 rwx


An example of using the permission bit is as follows.


#chmod 777 file.txt

  * The decimal value of 7 (first bit) means rwx , the user can read, write, and execute the file.

  * The decimal value 7 (second bit) means rwx , is a requirement for the user to be able to read, write the contents of the file, and execute it with the condition that it must be in the same group as the user owner of the file.

  * The decimal value 7 (last bit) means rwx , meaning that even though other users are not in the same group as the user who owns the file, they can read, write, or add to the contents of the file, and can even execute it.


To control and edit file or directory permissions, especially when monitoring the network on the server machine, you can use the following command.


#chmod code_group [ + or - ] permisson filename


The group code shows the category of the user who has access, (user owner, other users in one group, other).


User Code


User Code Description

u user – file owner

g group – same group for users

o other – users who are not in the same group as the file owner

a all – intended for all user groups either for the owner, one group, or different groups


For example, in the case that you will add access rights to users of one group so that they can write or add the contents of the file.txt file, use the command:


#chmod g +w file.txt


As for removing the file access attribute so that it cannot be executed by other users in different groups, the command is:


#chmod o -x file.txt


Conclusion


So how to use chmod in access rights or permissions of a file has several properties or certain codes and each code and property has different functions. To use these access rights, use the Chmod command which stands for Change Mode, which means a command that can change the mode of a file. The thing to note from this permissions command is, never give full access rights to a file or directory, especially if the file or directory is very important.

  __________________________________________________________________________________________________________________________________________________________________________________________________________________ ____________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ _________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________ ________________________________________________________________________________________________ ________

Hopefully, this article about How To Use Chmod For Access Rights On Linux, gives you a little insight. Also, read an article about How to Use Nmap For Beginners that you may need to know. Thank you.

Previous Post Next Post