Linux Environment Lab - Linux File System
Linux Environment Lab - Linux File System
1
© 2021 C-DAC, Hyderabad
Table of Contents
Objective 3
Prerequisites 3
Problem Statement 3
Fundamental concepts 3
Summary 3
References 15
2
© 2021 C-DAC, Hyderabad
1. Objective
2. Prerequisites
Prerequisites Version
3. Problem Statement
To understand the Linux File System, Explore the content of each directory present in the
root directory. Understand different Linux commands and execute the same.
4. Summary
Steps Description
Step3 Output
3
© 2021 C-DAC, Hyderabad
5. Fundamental Concept
A Linux file system is a structured collection of files on a disk drive or a partition. A partition
is a segment of memory and contains some specific data. Linux file system is generally a
built-in layer of a Linux operating system used to handle the data management of the
storage. It helps to arrange the file on the disk storage. It manages the file name, file size,
creation date, and much more information about a file.
Command Description
pwd It prints the path of the working directory, starting from the root
mkdir Allows the user to create directories. This command can create
multiple directories at once
less Used to read contents of text file one page(one screen) per time
more Used to view the text files in the command prompt, displaying one
screen at a time in case the file is large
cat Reads data from file and gives their content as output. It helps us
to create, view, concatenate files
4
© 2021 C-DAC, Hyderabad
6. Template for each step
● Go to the root directory by executing command cd / and then list the contents of
root directory using ls commands
● Now, go inside each directory using command cd and list the content of that
directory using command ls or execute the command ls followed by directory
name from the root directory
5
© 2021 C-DAC, Hyderabad
2. Step-2: Execute Directory and File related commands
1. pwd: Print Working Directory
Execute the command pwd. This will print the current working directory
6
© 2021 C-DAC, Hyderabad
4. mkdir: Create Directory
Create a new directory newDir using command mkdir and using ls command
you can check the newly created directory
6. cp: Copy
First create a new file with command touch and a directory using command
mkdir and confirm using ls command
7
© 2021 C-DAC, Hyderabad
● Now using cp command copy the hello.txt file to foo directory and then
check the contents of foo directory using ls command.
● You can also copy the directory using cp.
7. mv: Move
First create a new directory using command mkdir and confirm using ls
command.
Now, move the file hello.txt inside newly created directory and then check
the content of current directory and newly created directory using ls command
8
© 2021 C-DAC, Hyderabad
9
© 2021 C-DAC, Hyderabad
8. less: Allows you to view the contents of a file and navigate
through file
First we will create a new file which has large content in it, for that execute
below command:
Now we will read the content of the file temp.txt using command less. This
command will only show the one page at a time on the screen. If you can press Enter
key it will show next line on the screen. And, if you press page down key, it will show
the next page on the screen. Similarly, page up key will take you one page back.
10
© 2021 C-DAC, Hyderabad
9. more: Open a given file for interactive reading
Now, we will use the more command to read the content of temp.txt. You can
scroll through the contents of the file by pressing ENTER or SPACE BAR keys.
Note: The main difference between more and less is that less command is
faster because it does not load the entire file at once and allows navigation
though file using page up/down keys.
11
© 2021 C-DAC, Hyderabad
10. cat: Concatenate
Now, we will use the cat command to display the content of temp.txt on the
screen.
12
© 2021 C-DAC, Hyderabad
Now, we will use cat command to copy the content of temp.txt file to another
text file. So, first we will create an empty text file using touch command and then
copy the content of temp.txt to newly created file.
Now, print the content of newFile.txt using cat command and you can see
that the content of temp.txt has got copied to newFile.txt using cat command
13
© 2021 C-DAC, Hyderabad
11. head: Print the top N number of data of the given input
We can use a head command to display the content of temp.txt on the
screen. By default it will print first 10 lines on the screen.
14
© 2021 C-DAC, Hyderabad
12. tail: Print the last N number of data of the given input
We can use a tail command to display the content of temp.txt from the end
of the file. By default it will print last 10 lines on the screen.
15
© 2021 C-DAC, Hyderabad
7. References
● https://en.wikipedia.org/wiki/File_system
● https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
16
© 2021 C-DAC, Hyderabad