0% found this document useful (0 votes)
19 views

File Management in OS

The document discusses file permissions in Linux. It defines file permission classes as user, group, and others. It describes the types of file permissions as read, write and execute. It provides the command to check file permissions using ls -l and explains how to interpret the output. It also discusses the different modes to modify file permissions - symbolic, literal and numeric mode.

Uploaded by

Hari Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

File Management in OS

The document discusses file permissions in Linux. It defines file permission classes as user, group, and others. It describes the types of file permissions as read, write and execute. It provides the command to check file permissions using ls -l and explains how to interpret the output. It also discusses the different modes to modify file permissions - symbolic, literal and numeric mode.

Uploaded by

Hari Hari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

FILE

MANAGEMENT

IN LINUX

BY - Gauri Yadav
LIST OF TOPICS

01 WHAT ARE FILE PERMISSION


CLASSES?

WHAT ARE FILE PERMISSION


02 TYPES?

03 HOW TO CHECK FILE


PERMISSIONS?

04 TYPES OF PERMISSION MOD?

05 WHAT IS SYMBOLIC MODE?

06 WHAT IS A LITERAL MODE?


LIST OF TOPICS

07 WHAT IS NUMERIC MODE?


What are file permission
classes?
Q1 What are file permission?

File permissions ensure that sensitive data and system files are
protected from unauthorized access. By setting appropriate
permissions, system administrators can control who can view,
modify, or execute specific files or directories. This prevents
unauthorized users from tampering with critical system
configurations, altering important files, or accessing confidential
data.
File permissions enable users to maintain privacy by restricting
access to their personal files. Each user has their own home
directory with permissions set in a way that only they (and the
system administrator) can access the files stored within it. This
ensures that users can keep their personal data confidential and
secure from other users on the system.
File permissions help maintain data integrity by preventing
accidental or intentional modifications to files by unauthorized
users. With proper permissions in place, users can trust that
their files remain unchanged unless they have explicitly granted
permission for modifications.
System files and directories often require specific permissions to
function correctly. By restricting access to these files,
administrators can prevent accidental modifications or deletions
that could disrupt system operations or cause instability.
Owner (u): The user who owns the file or directory.
Group (g): Users who are members of the group associated with
the file or directory.
Others (o): All other users on the system who are not the owner
or members of the group.
Users are categorized into three unique classes for maintaining
file security through access rights. These classes are user (u),
group (g), and other (o, also referred to as public). These
permission classes represent the owner, the set of users with
identical access requirements, and everyone else on the system,
respectively. There is another special user class called all (a)
that represents the three user classes combined.
What are file permission
types?

ons control what actions can be performed on a file or directory


and by whom. There are three types of permissions bits -read
(r), write (w), and execute (x)-and they behave differently for
files and directories. For files, the permissions allow viewing and
copying (read), modifying (write), and running (execute). And in
the case of directories, they allow listing contents with Is (read);
creating, erasing, and renaming files and subdirectories (write);
and enter (with the cd command) into it (execute).
If a read, write, or execute permission bit is not desired, the
hyphen character (-) is used to represent its absence.
How to check file
permissions?
To check file permissions in Linux, you can use the ls command
with the -l option, which provides a detailed listing of files and
directories, including their permissions. Here's how you can do it:

Step 1 : Open a terminal window on your Linux


system

Step 2 : Navigate to the directory containing the file


whose permissions you want to check, using the cd
command if necessary.

Step 3 : Use the ls -l command followed by the


filename to display the permissions. For example:
Step 4 : ls -l <myfile.txt>
This command will show you a detailed listing of the
file myfile.txt, including its permissions.

The output will look something like this:

Let's break down what each part of the output means:


The first character (- in this example) indicates the type of file
(regular file, directory, etc.).
The next three characters (rw-) represent the owner's
permissions (read and write, but not execute in this case).
The next three characters (r--) represent the group's
permissions (read only).
The last three characters (r--) represent others' permissions
(read only).
The number 1 indicates the number of hard links to the file.
The user and group represent the owner and group associated
with the file, respectively.
The 4096 indicates the file size in bytes.
Mar 22 17:02 indicates the last modification date and time of the
file.
Types of permission mode?

Symbolic mode allows you to modify file permissions by using


symbolic representations. It provides a more human-readable
and intuitive way to change permissions. Symbolic mode
consists of three parts: the target (file or directory), the operator
(to add, remove, or set permissions), and the permission(s) to be
modified.
Literal mode is a less commonly used method for changing
permissions, as it requires specifying the permissions explicitly
using the r (read), w (write), and x (execute) characters for the
owner, group, and others.
Numeric mode allows you to modify file permissions using
numerical values. Each permission (read, write, execute) is
assigned a numeric value: 4 for read, 2 for write, and 1 for
execute. These values are then added together to represent the
desired permissions.
What is symbolic mode?
Symbolic mode is a method of modifying file permissions in
Linux by using symbolic representations rather than
numerical values. It provides a more human-readable and
intuitive way to change permissions, making it easier to
understand and remember the permissions being applied.
In symbolic mode, you specify three components:
Target: This represents the users or groups whose
permissions you want to modify. It can be one or more of the
following:
u: Owner/User
g: Group
o: Others
a: All (equivalent to ugo)
Operator: This specifies the action to be performed on the
permissions. It can be one of the following:
+: Adds permissions
-: Removes permissions
=: Sets permissions
Permission: This indicates the specific permissions to be
modified. It can be one or more of the following:
r: Read
w: Write
x: Execute
To modify permissions using symbolic mode, you combine
these components together to form a command.
Q1 How to add file permission?

we can add permission by using “+” command.

Q2 How to check which permission is for which


category?
Q3 How to add permission for user (u)?

Syntax : chmod u+x myfile.txt:


Adds execute permission (x) for the owner (u) of
the file myfile.txt

Q4 How to add permission for group (g)?


Q5 How to add permission for group (g)?

Syntax : chmod g+x myfile.txt:


Adds execute permission (x) for the owner (g) of
the file myfile.txt
Q6 How to add permission for other (o)?

Syntax : chmod o+x myfile.txt:


Adds execute permission (x) for the owner (o) of
the file myfile.txt
Q7 How to revoke permission for user (u)?

Syntax : chmod u-x myfile.txt:


removes execute permission (x) for the owner (u)
of the file myfile.txt

Q8 How to remove permission for group (g)?


Syntax : chmod g-x myfile.txt:
removes execute permission (x) for the group (g)
of the file myfile.txt
Q9 How to revoke permission for others (o)?

Syntax : chmod o-x myfile.txt:


removes execute permission (x) for the others (o)
of the file myfile.txt
What is Numeric mode?
4or example:
Q1 How to calculate ‘4’ in 421 has which octal
permission ?

Q2 How to calculate ‘2’ in 421 has which octal


permission ?
Q3 How to calculate ‘1’ in 421 has which octal
permission ?
Q4 How to add read, write, and execute permission?

Syntax : chmod 755 myfile.txt


r: Gives read, write, and execute permissions to
the owner, and read/execute permissions to the
group and others on the file myfile.txt. (Owner:
rwx, Group: r-x, Others: r-x)
Q5 How to add write permissions to the owner, and
read-only permissions to the group and others on
the file?
Syntax : chmod 644 myfile.txt
Gives read and write permissions to the owner,
and read-only permissions to the group and others
on the file (Owner: rw-, Group: r--, Others: r--)
Q6 How to add read, write, and execute permissions
to the owner, group, and others?

Syntax : chmod 777 myfile.txt


Grants read, write, and execute permissions to
the owner, group, and others on the directory
(Owner: rwx, Group: rwx, Others: rwx)
What is a Literal mode?

Literal mode, also known as text or alphabetic mode, is a


method of modifying file permissions in Linux by explicitly
specifying the permissions for the owner, group, and others
using alphabetic characters. Unlike symbolic mode, which
uses symbolic representations (e.g., u for owner, g for group),
literal mode directly spells out the permissions with letters: r
for read, w for write, and x for execute.
In literal mode, you provide a series of letters to represent
the desired permissions for the owner, group, and others,
respectively. Each letter indicates whether the corresponding
permission should be granted (r, w, or x) or denied (-). You
can use a combination of these letters to specify the exact
permissions you want to set.
Q1 How to set read, write, and execute permission?

Syntax : chmod u=rwx,g=rx,o=r myfile.txt


Grants read, write, and execute permissions to
the owner (u), read and execute permissions to
the group (g), and read-only permissions to others
(o) on the file myfile.txt.
Q2 How to set write permissions for the owner (u)
and the group (g), while removing all permissions for
others (o) file permission?

Syntax : chmod u=rw,g=r,o= myfile.txt


Grants read, write, and execute permissions to
the owner (u), read and execute permissions to
the group (g), and read-only permissions to others
(o) on the file myfile.txt.
THANK

YOU

Follow - @Gauri Yadav

You might also like