0% found this document useful (0 votes)
20 views13 pages

Theory Assignment 01

Cyber Securityt1

Uploaded by

Pradip Sarker
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)
20 views13 pages

Theory Assignment 01

Cyber Securityt1

Uploaded by

Pradip Sarker
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/ 13

Bangladesh University of Professionals (BUP)

M.Sc. in Cyber Security

Course Code: MCS 1101


Course Name: Cyber Security Fundamentals
Assignment on
Linux File System, Filesystem Hierarchy, Directory & File Permissions

Submitted To: Submitted By:


Engr. Md. Mushfiqur Rahman Sree Pradip Kumer Sarker
ID No: 24525201005
Guest Faculty, Dept of CE
M.Sc. in Cyber Security
Bangladesh University of Professionals (BUP)
BUP, Dhaka, Bangladesh.
Dhaka, Bangladesh.

0
What is file System
Operating systems, the software that powers your computer, rely on a crucial element known as
the file system. Think of it as a virtual organizational tool that manages, stores, and retrieves your
data efficiently. In the Linux world, a diverse range of file systems has emerged, each crafted to
address specific needs and preferences. This article aims to simplify the intricacies of Linux file
systems, guiding beginners through their layers, characteristics, and implementations. By shedding
light on these nuances, we empower users to make informed choices in navigating the dynamic
landscape of Linux operating systems.

What is the Linux File System?


The Linux file system is a multifaceted structure comprised of three essential layers. At its
foundation, the Logical File System serves as the interface between user applications and the file
system, managing operations like opening, reading, and closing files. Above this, the Virtual File
System facilitates the concurrent operation of multiple physical file systems, providing a
standardized interface for compatibility. Finally, the Physical File System is responsible for the
tangible management and storage of physical memory blocks on the disk, ensuring efficient data
allocation and retrieval. Together, these layers form a cohesive architecture, orchestrating the
organized and efficient handling of data in the Linux operating system.
In this article, we will be focusing on the file system for hard disks on a Linux OS and discuss
which type of file system is suitable. The architecture of a file system comprises three layers
mentioned below.

Characteristics of a File System


 Space Management: how the data is stored on a storage device. Pertaining to the memory
blocks and fragmentation practices applied in it.
 Filename: a file system may have certain restrictions to file names such as the name length,
the use of special characters, and case sensitive-ness.
 Directory: the directories/folders may store files in a linear or hierarchical manner while
maintaining an index table of all the files contained in that directory or subdirectory.

1
 Metadata: for each file stored, the file system stores various information about that file’s
existence such as its data length, its access permissions, device type, modified date-time,
and other attributes. This is called metadata.
 Utilities: file systems provide features for initializing, deleting, renaming, moving,
copying, backup, recovery, and control access of files and folders.
 Design: due to their implementations, file systems have limitations on the amount of data
they can store.

Types of file system in linux

2
1. ext (Extended File System):
Implemented in 1992, it is the first file system specifically designed for Linux. It is the first
member of the ext family of file systems.
2. ext2:
The second ext was developed in 1993. It is a non-journaling file system that is preferred to be
used with flash drives and SSDs. It solved the problems of separate timestamp for access, inode
modification and data modification. Due to not being journaled, it is slow to load at boot time.
3. Xiafs:
Also developed in 1993, this file system was less powerful and functional than ext2 and is no
longer in use anywhere.
4. ext3:
The third ext developed in 1999 is a journaling file system. It is reliable and unlike ext2, it prevents
long delays at system boot if the file system is in an inconsistent state after an unclean shutdown.
Other factors that make it better and different than ext2 are online file system growth and HTree
indexing for large directories.
5. JFS (Journaled File System):
First created by IBM in 1990, the original JFS was taken to open source to be implemented for
Linux in 1999. JFS performs well under different kinds of load but is not commonly used anymore
due to the release of ext4 in 2006 which gives better performance.
6. ReiserFS:
It is a journal file system developed in 2001. Despite its earlier issues, it has tail packing as a
scheme to reduce internal fragmentation. It uses a B+ Tree that gives less than linear time in
directory lookups and updates. It was the default file system in SUSE Linux till version 6.4, until
switching to ext3 in 2006 for version 10.2.
7. XFS:
XFS is a 64-bit journaling file system and was ported to Linux in 2001. It now acts as the default
file system for many Linux distributions. It provides features like snapshots, online
defragmentation, sparse files, variable block sizes, and excellent capacity. It also excels at parallel
I/O operations.

3
8. SquashFS:
Developed in 2002, this file system is read-only and is used only with embedded systems where
low overhead is needed.
9. Reiser4:
It is an incremental model to ReiserFS. It was developed in 2004. However, it is not widely adapted
or supported on many Linux distributions.
10. ext4:
The fourth ext developed in 2006, is a journaling file system. It has backward compatibility with
ext3 and ext2 and it provides several other features, some of which are persistent pre-allocation,
unlimited number of subdirectories, metadata checksumming and large file size. ext4 is the default
file system for many Linux distributions and also has compatibility with Windows and Macintosh.
11. btrfs (Better/Butter/B-tree FS):
It was developed in 2007. It provides many features such as snapshotting, drive pooling, data
scrubbing, self-healing and online defragmentation. It is the default file system for Fedora
Workstation.
12. bcachefs:
This is a copy-on-write file system that was first announced in 2015 with the goal of performing
better than btrfs and ext4. Its features include full filesystem encryption, native compression,
snapshots, and 64-bit check summing.
13. Others:
Linux also has support for file systems of operating systems such as NTFS and exFAT, but these
do not support standard Unix permission settings. They are mostly used for interoperability with
other operating systems.

What is a file in Linux?


“On a UNIX system, everything is a file; if something is not a file, it is a process.”
This statement is true because there are special files that are more than just files (named pipes and
sockets, for instance), but to keep things simple, saying that everything is a file is an acceptable
generalization. A Linux system, just like UNIX, makes no difference between a file and a
directory, since a directory is just a file containing names of other files. Programs, services, texts,
images, and so forth, are all files. Input and output devices, and generally all devices, are

4
considered to be files, according to the system. Linux operating systems use a hierarchical file
system, which means that it is organized from top to bottom (or above and below).
The starting point of the file system is called the root “/” directory, and all other directories stem
from it. Directories above others are called parents or parent directories, while directories below
are called children. Children of children are called grandchildren.

Linux File System Hierarchy Structure


The Linux File System Hierarchy Structure is governed by the Filesystem Hierarchy Standard, a
set of guidelines that determines the structure and contents of directories in Unix-type operating
systems, including Linux. These standards are maintained by the Linux Foundation.
The File System Hierarchy starts at the root “/” directory of the file system, from which all other
directories and their contents branch out. The file system logically organizes files and folders, with
each directory serving a specific purpose. I will explain the significance of various directories
below.

Why Is It Important To Understand the File System Hierarchy?


Having a clear understanding of the Linux File System Hierarchy brings numerous benefits to
users. Most notably, it simplifies navigation through the file system and makes it easy to locate
files and folders. Moreover, it provides insights into the relationships between different files and
folders.
This knowledge makes it easier to perform file management tasks like copying, deleting, moving,
and renaming files and folders.
Understanding the Linux File System Hierarchy is particularly crucial for system administrators
and developers.

5
Process and Directories in the Linux File System Hierarchy

6
Directory Structure & File System Hierarchy

Directory Description & Examples

Primary hierarchy root and root directory of the entire file system
/
hierarchy.

Essential command binaries that need to be available in single-user mode,


/bin
including to bring up the system or repair it, for all users (e.g., cat, ls, cp).

/boot Boot loader files (e.g., kernels, initrd).

Device
/dev
files (e.g., /dev/null , /dev/disk0 , /dev/sda1 , /dev/tty , /dev/random ).

Host-specific system-wide configuration files.


There has been controversy over the meaning of the name itself. In early
versions of the UNIX Implementation Document from Bell Labs, /etc is

referred to as the etcetera directory, as this directory historically held


everything that did not belong elsewhere (however, the FHS
/etc
restricts /etc to static configuration files and may not contain

binaries). Since the publication of early documentation, the directory


name has been re-explained in various ways. Recent interpretations
include backronyms such as "Editable Text Configuration" or "Extended
Tool Chest".

/etc/opt Configuration files for add-on packages stored in /opt .

/etc/sgml Configuration files, such as catalogs, for software that processes SGML.

/etc/X11 Configuration files for the X Window System, version 11.

/etc/xml Configuration files, such as catalogs, for software that processes XML.

/home Users' home directories, containing saved files, personal settings, etc.

7
/lib Libraries essential for the binaries in /bin and /sbin .

Alternate format essential libraries. These are typically used on systems


that support more than one executable code format, such as systems
/lib<qual>
supporting 32-bit and 64-bit versions of an instruction set. Such
directories are optional, but if they exist, they have some requirements.

Mount points for removable media such as CD-ROMs (appeared in FHS-


/media
2.3 in 2004).

/mnt Temporarily mounted filesystems.

Add-on application software packages.


/opt

Virtual filesystem providing process and kernel information as files. In


/proc Linux, corresponds to a procfs mount. Generally, automatically
generated and populated by the system, on the fly.

/root Home directory for the root user.

Run-time variable data: Information about the running system since last
boot, e.g., currently logged-in users and running daemons. Files under
/run this directory must be either removed or truncated at the beginning of the
boot process, but this is not necessary on systems that provide this
directory as a temporary filesystem (tmpfs).

/sbin Essential system binaries (e.g., fsck, init, route).

Site-specific data served by this system, such as data and scripts for web
/srv servers, data offered by FTP servers, and repositories for version control
systems (appeared in FHS-2.3 in 2004).

Contains information about devices, drivers, and some kernel features.


/sys

8
Directory for temporary files (see also /var/tmp ). Often not preserved
/tmp
between system reboots and may be severely size-restricted.

Secondary hierarchy for read-only user data; contains the majority of


/usr (multi-)user utilities and applications. Should be shareable and read-only.

Non-essential command binaries (not needed in single-user mode); for all


/usr/bin
users.

/usr/include Standard include files.

/usr/lib Libraries for the binaries in /usr/bin and /usr/sbin .

Binaries run by other programs that are not intended to be executed


/usr/libexec
directly by users or shell scripts (optional).

Alternative-format libraries (e.g., /usr/lib32 for 32-bit libraries on a 64-


/usr/lib<qual>
bit machine (optional)).

Tertiary hierarchy for local data, specific to this host. Typically has
/usr/local further subdirectories (e.g., bin , lib , share ).

Non-essential system binaries (e.g., daemons for various network


/usr/sbin
services).

/usr/share Architecture-independent (shared) data.

/usr/src Source code (e.g., the kernel source code with its header files).

/usr/X11R6 X Window System, Version 11, Release 6 (up to FHS-2.3, optional).

Variable files: files whose content is expected to continually change


/var during normal operation of the system, such as logs, spool files, and
temporary e-mail files.

9
Application cache data. Such data are locally generated as a result of time-
/var/cache consuming I/O or calculation. The application must be able to regenerate
or restore the data. The cached files can be deleted without loss of data.

State information. Persistent data modified by programs as they run (e.g.,


/var/lib
databases, packaging system metadata, etc.).

/var/lock Lock files. Files keeping track of resources currently in use.

/var/log Log files. Various logs.

Mailbox files. In some distributions, these files may be located in the


/var/mail
deprecated /var/spool/mail .

/var/opt Variable data from add-on packages that are stored in /opt .

Run-time variable data. This directory contains system information data


describing the system since it was booted.[11]

/var/run In FHS 3.0, /var/run is replaced by /run ; a system should either continue

to provide a /var/run directory or provide a symbolic link

from /var/run to /run for backwards compatibility.

Spool for tasks waiting to be processed (e.g., print queues and outgoing
/var/spool
mail queue).

/var/spool/mail Deprecated location for users' mailboxes.

/var/tmp Temporary files to be preserved between reboots.

10
Linux File Permission
No matter what you do in IT, even a basic understanding of Linux empowers you with a hidden
asset that can open doors
It's the engine behind so many technologies we use every day!
Let's break down file permissions in Linux, which might sound tricky, but once you know them,
they're super useful.
Here's a simple guide to each part:

𝗪𝗵𝗮𝘁 𝗮𝗿𝗲 𝗟𝗶𝗻𝘂𝘅 𝗳𝗶𝗹𝗲 𝗽𝗲𝗿𝗺𝗶𝘀𝘀𝗶𝗼𝗻𝘀?


Linux file permissions control who can read, write, and execute a file. There are three types of
permissions:
User permissions: control what the file's owner can do with the file.
Group permissions: control what the file's group members can do with the file.
Other permissions: control what everyone else can do with the file.

The binary permission 𝚛𝚠𝚡𝚛-𝚡𝚛-𝚡 has the following octal permission:


r = read
w = write
x = execute
- = no permission
rwxr-xr-x = 755

𝗖𝗼𝗺𝗺𝗼𝗻 𝗳𝗶𝗹𝗲 𝗽𝗲𝗿𝗺𝗶𝘀𝘀𝗶𝗼𝗻𝘀


Here are some common file permissions:
755: This is the most common permission for files. It allows the owner and group members to
read and write the file, and everyone else to read the file.
644: This permission is often used for read-only files, such as system files. It allows the owner
and group members to read the file, but no one else.
777: This permission allows everyone to read, write, and execute the file. It should only be used
for files that need to be accessible to everyone, such as temporary files.

11
𝗛𝗼𝘄 𝘁𝗼 𝗰𝗵𝗮𝗻𝗴𝗲 𝗳𝗶𝗹𝗲 𝗽𝗲𝗿𝗺𝗶𝘀𝘀𝗶𝗼𝗻𝘀
To change file permissions, you can use the 𝚌𝚑𝚖𝚘𝚍 command. For example, to change the
permission of the file 𝚖𝚢𝚏𝚒𝚕𝚎 to 755, you would run the following command:
chmod 755 myfile
You can also use the 𝚌𝚑𝚖𝚘𝚍 command to change specific permissions. For example, to add the
execute permission for everyone to the file 𝚖𝚢𝚏𝚒𝚕𝚎, you would run the following command:
chmod +x myfile

12

You might also like