Linux File Permissions

Are you ready to explore file management skills in Linux systems? Then you are at the right place, in the file permissions in the Linux system blog, we are going to explain how to manage various kinds of files and also file permissions used to execute the Linux commands. If you are a Linux developer, I think this blog is very important to know about the file systems used while writing and executing the Linux codes. Let’s start learning the various kinds of file systems of Linux system;

Introduction to Linux operating system:

Linux is a popular operating system, which is designed on the base of Linux Kernel. Linux is an open-source system and which can run on multiple hardware platforms. The importance of using the Linux operating system is to provide free and less expensive operating services for users. Linux operating system is also considered as a user-friendly work nature which can be modified easily and also enables the user to create variations in the source code. Users can use this operating system like Windows, MAC, Android, and IOS. This type of operating system always conveys the input data which is processed by the processor and brings them to the hardware for the displaying purpose.

Building Blocks of Linux system:

The following are the major building blocks of the Linux operating system;

1. Kernel: This one is a major building block of Linux architecture, and also known as the heart of the system. The kernel interacts with various hardware devices and performs most of the memory management tasks, task scheduling methods, and also files management.

2. Shell: The shell component is used to process the requests. First, you need to type the commands at the terminal node, and then the shell interprets the commands and calls the program which you want to execute.

3. Commands and Utilities: There is various type of commands used in Linux which can be later used to perform day-to-day activities. For example; cp, grep, cat, and mv, etc.

4. Files and Directories: All the data of the Linux system will be organized into files. Then all the files will be organized into directories. Afterward, all the directories will be organized into a tree-like structure. We will discuss various file types and permission later.

 For the effective directory, the Linux system can be divided into 2 levels of authorization.

1. Ownership

2. Permission

 These two concepts of Linux file ownership and file permission play a crucial part in linux.

Want to know more about Linux, visit here Linux Training

Lets’ discuss Ownership of the Linux system;

Every files and directory on the given Linux system can be assigned into three types of the owner;

a. User:

A user is the owner of the Linux file. By default, the person who creates a file can be its owner. Therefore the user is also called an owner.

b. Group:

Here user group contains multiple users. All the Linux users will be belonging to the group of the same Linux group permissions to access the files.

c. Other:

Any other or third user can access the Linux file system. This third user has neither created the file, nor does he belong to the user group that can own the file.

 Now it’s time to learn about permission

d. Permission:

Every file and directory in Linux system consists of three permissions, they are;

1. Read:

This type of permission gives the authority to read and open the file. Read permission on a given directory helps you the ability to list the various contents.

2. Write:

The write permission of the Linux file system offers you the authority to modify or update the file contents. This type of file permission on any directory gives you the permission to add, delete, or rename the files stored in any directory.

3. Execute:

In the windows operating system, an executable program has an extension known as “.exe” and it’s very easy to run. In Linux operating system, users cannot run your program without using executes permission. If the execute permission is not set in your file system, you can still modify or see the program codes but you cannot run the program .

The following image explains the file permission in the Linux system:

Ownership of the Linux system

Now it’s time to know more about various file permissions in Linux system with an example;

ls –l   available on the terminal.

file permissions in Linux system with an example

In the above diagram, we have highlighted the column “-rw-rw-r—“and this is one of the important file permission given to the owners, user group, and the world. Here “-“ implies that you have selected a file .p>

file permission

If it’s a directory then you have to represent them in ‘d’.

directory then you have to represent

The characters can be explained as follows;

 r = this indicates the read permission

 w   = this indicates the write permission

  x   = this indicates the execute the permission

-      = this indicates no permission given to the system.

Linux Certification Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning
Changing File or directory permissions with ‘chmod’ command:

If you want to hide your file then you to use this command “changing the file permission”.

Here you can use the command “chmod” which stands for change mode. Along with this command, you can use the permissions (read, write, and execute) on any file or directory for the file owner, group users, and the world.

The syntax is as follows;

Chmod permissions filename

There are two ways available to use these change command;

  1. Absolute mode
  2. Symbolic mode

Let me explain them one by one;

  1. Absolute or numeric mode:

In this mode, the Linux file permissions cannot be represented s characters but with a three-digit octal number.

The following are the different types of file permissions;

----                       -> No permission

--x                         -> execute the file

 -w-                          -> write

-wx                       -> execute + write

r--                          -> read the file

r-x                          -> read + execute

rw-                        -> read + write

rwx                        -> read+ write + execute

Now see the command permission;

command permission

It’s time to know some example; “file permission number 764”

file permission number

Subscribe to our youtube channel to get new updates..!

“764” file permission code says the following:

  1. owner can read, execute, and read the file.
  2. User group can read and write the file.
  3. World can read-only file.

 You can represent it as a ‘-rwxrw-r—‘.

 Symbolic Mode:

In the absolute mode, the user can change the file permissions for all three owners. In the symbolic mode, you can also modify the files. Here you need to make use of mathematical symbols to modify any Linux file permissions.

+       -> this symbol will add permission to the directory or a file.

-               -> This symbol removes the file permission.

=      -> this symbol will set the permission for a given file and also overrides the permission set.

 The owners can be represented as;

User Denotations

 U       -> user or owner

 G        -> Group

 O        -> other

  A        -> all

Want to know more about Linux, visit here Linux Tutorial!

Linux – File management:

When you start working with Linux, most of the time you need to work with files and directories. In this section, we are going to explain how to create, remove, copy, rename, and create links to them, etc.

 There are three basic types of files:

  1. Ordinary files: Ordinary files in the Linux system consist of data, programming instructions, and text.
  1. Directories: Directories in the Linux system helps to store both special and ordinary files. Most of the directories can also be stored with Windows, MAC OS, and they are equivalent to folders.
  1. Special files: Some special files help to access hardware devices like hard drives, modems, Ethernet adapters, and CD-ROM. They are similar to aliases and enable us to access a single file with the help of different names.

Some other properties of the file management system:

  1. Listing files:

You can list the files and directories which are stored in the current directory with the help of the following command:

$ls.

  The following are the important list files:

  1. -     ->   this is a regular file, like ASCII text files, hard links, and binary executable.
  2. b -> This is a block special file. You can be used this as an input/output file like physical hard drives.
  3. 3. c    -> this is a character special file. Raw input or output device files like the physical hard drive.
  4. d -> this is a directory file that consists of list files and directories.
  5. I   -> this is also known as a symbolic link file. You can also use them as links on any other regular files.
  6. P  -> it is called a named pipe. This is also a mechanism to interprocess the communication.
  7. s  -> this is a socket file mainly used to interprocess the communication between any two devices.

Linux Certification Training

Weekday / Weekend Batches

Metacharacters:

Metacharacters hold special meaning in the Linux system. For example, * and ? are the metacharacters. You can use * to match the characters and ? Used to match any single character.

For example:

$ls ch*.doc

Hidden files:

This is an invisible file type; the first character of the file can be represented as a dot or nay period character (.). In a Linux system, use these file types to store the configuration information.

For example:

  1. .profile  -  the Bourne shell (sh), this is an initialization script.
  2. .kshrc   - the Korn shell or (ksh) to perform the configuration process.
  3. 3. .cshrc - the C shell or (csh) to work with c programming.
  4. 4. .rhosts - this is a remote shell configuration file.
Conclusion:

In this Linux file permission, we have designed to help Linux developers to work with various file systems and access the various file types. This blog also helps to understand the basic file types, their functionalities, covering Linux commands, Linux shell scripting, and various file utilities. I hope this blog may help a few of you to learn and explore the Linux file types and helps you to access them.

Other Articles:

Find our upcoming Linux Certification Training Online Classes

  • Batch starts on 3rd Jun 2023, Weekend batch

  • Batch starts on 7th Jun 2023, Weekday batch

  • Batch starts on 11th Jun 2023, Weekend batch

Global Promotional Image
 

Categories

Request for more information

Saritha Reddy
Saritha Reddy
Research Analyst
A technical lead content writer in HKR Trainings with an expertise in delivering content on the market demanding technologies like Networking, Storage & Virtualization,Cyber Security & SIEM Tools, Server Administration, Operating System & Administration, IAM Tools, Cloud Computing, etc. She does a great job in creating wonderful content for the users and always keeps updated with the latest trends in the market. To know more information connect her on Linkedin, Twitter, and Facebook.