White Hat Institute

Linux basics

Command-line interface (part 7)

File permissions

Linux is a copy of UNIX, the multi-client operating framework which can be accessed by numerous clients all at the same time. Linux can likewise be used in centralized computers and servers with no alterations.

Be that as it may, this raises security worries as a spontaneous or malicious user can degenerate, change, or delete crucial information. For viable security, Linux divides authorization into two levels: Ownership and Permission.

 Linux frameworks relegate three user-based types of owners to each document and directory.

1.  A user is the proprietor of the document. Naturally, the individual who created a record turns into its owner. Subsequently, a user is additionally at times called an owner.

2.  A user group can contain various clients. All clients having a place with a group will have similar access consents to the record.

3. Other: This individual has neither created the record nor has a place with a user group who could claim the document. It implies every other person.

  • -identity: At the point when client records are made, clients are allotted a number called a user ID or  which is at that point, for the sake of the humans, mapped to a username. The client is allotted a primary group ID or  and may have a place with another group. To find out information about the user identity, use the  command.

Linux basics 63

 Each record and directory in your Linux framework has the following three permissions characterized for the entire three owners we mentioned above.

1.  This permission authorizes you to open and read the file. Read permission on a folder lets you list its content.

2.  The write permission authorizes to modify the contents of the file. The write permission on a directory lets you add, remove, and rename files stored in the folder.

3.  In Windows, an executable program usually has an extension and which you can efficiently run. In Linux, you cannot run an application unless the  permission applied. If the permission for the document is not set, you might still be able to view and modify the program code, but not run it.

Linux basics 64

The first ten characters of the posting are the document attributes. The first of these characters is the document type. Here are some document types you might continuously see:

 stands for a regular file,

 stands for the directory,

 stands for the symbolic link,

 stands for a character file,

 stands for a block file.

  • – change mode: The  operator is utilized to change the authorizations of a document or registry. To use it, you indicate the ideal permission settings and the document or records that you wish to modify. There are two different ways to specify the permissions mode: Absolute (Numeric) mode and Symbolic mode.

Absolute (Numeric) mode — In this mode, document authorizations are not represented as characters but a three-digit octal number. So, the permission types for the documents and directories would be as follows:

r w x = 7 Read + Write +Execute

r w – = 6 Read + Write

r -x = 5 Read + Execute

r – -= 4 Read

-w x = 3 Write + Execute

-w – = 2 Write

–x = 1 Execute

—= 0 No permission

On the off chance that you represent every one of the three arrangements of permissions (owner, group, and other) as a single digit, you have a genuinely advantageous method for communicating the potential authorizations settings. For instance, if we needed to set a particular file to have read and written authorization for the owner, yet required to keep the record private from others, we would use the following command:

Linux basics 65

Symbolic mode — In the symbolic mode, you can change the permissions of a particular owner by utilizing mathematical symbols. For instance, to add permission to a file or directory use the  sign, remove permission, use the  sign, to set and override permissions use the sign. We can also represent various owners by their group name initials:  for user or owner for the group,  for other, and  for all.

Linux basics 69
  • -change ownership: This command is utilized to change the owner and group owner of a document or directory.  can change the file owner and the file group owner depending on the first argument of the command. For example,  will change the ownership of the file from its current owner to the user   will change the ownership of the file from its current owner to user  and changes the filegroup owner, to group   will change the group owner to the group  and the file owner will not be changed. will change the file owner from the current owner to user  and changes the group owner to the login group of user 

Linux basics 66
  • -change group ownership: In more traditional forms of Unix, the  operator only changed file ownership, not group ownership. For that reason, a different command,  was utilized. It works similarly to except for being progressively limited.

Linux basics 67
  • : When creating a document or directory, a lot of default permissions are applied. The  operator dictates these default authorizations It indicates authorizations that you don’t need to set on by default.

Linux basics 68