File Management System - CSU360 - Shoolini University

Practical 3: Perform an operation of operating system for File Management System

3. File Management System Operations

File Management System (FMS) is an essential component of an operating system that organizes, stores, retrieves, and manages data files on a computer. This practical involves using command-line tools in Kali Linux to perform basic file operations.

3.1. Creating, Listing, and Removing a File

Create a file, list it, and then remove it to demonstrate basic file operations:

touch example.txt # Create a new file
ls -l # List the file
rm example.txt # Remove the file
ls -l # List the file
Creating, Listing, and Removing a File
Figure 3.1.1: Creating, Listing, and Removing a File
Creating, Listing, and Removing a File
Figure 3.1.1: Creating, Listing, and Removing a File

3.2. Working with Directories

Create a directory, list it, and then remove it:

mkdir dir # Create a new directory
ls -l # List directories to check if directory created
rmdir dir # Remove the directory
ls -l # List directories to check if directory removed
Working with Directories
Figure 3.2.1: Working with Directories
Working with Directories
Figure 3.2.1: Working with Directories

3.3. Copying and Moving Files

Create a file, copy it to a new file, move the new file to a new name, and then clean up:

touch original.txt # Create a new file
cp original.txt copy.txt # Copy the file to a new file
ls -l # List files to check if copied
mv copy.txt moved.txt # Move the copied file to a new name
ls -l # List files to check if moved
rm original.txt moved.txt # Remove both files
ls -l # List files to check if removed
Copying and Moving Files
Figure 3.3.1: Copying and Moving Files
Copying and Moving Files
Figure 3.3.1: Copying and Moving Files

3.4. Directory Operations with Content

Create a directory with a file in it, copy the directory, move the copied directory, and then remove everything:

mkdir testDir # Create a directory and a file within it
touch testDir/file.txt
ls -l # List the directory
ls -l testDir # List the directory and file
cp -r testDir copiedDir # Copy the directory recursively
ls -l # List the directory
mv copiedDir movedDir # Move the copied directory
ls -l # List the directory
rm -r testDir movedDir # Remove directories and their contents
ls -l # List the directory
Directory Operations with Content
Figure 3.4.1: Directory Operations with Content
Directory Operations with Content
Figure 3.4.1: Directory Operations with Content

3.5. Viewing File Content

Create a file, add text, view the content, and then remove the file:

nano viewfile.txt # Create a new file and add 10 lines of text to the file and save it using 'CTRL + X' and 'Y' (yes), 'Enter' in sequence.
cat viewfile.txt | wc -l # Count the number of lines in the file
tail -n 2 viewfile.txt # Display last 2 lines of content of the file
cat viewfile.txt # Display the content of the file
rm viewfile.txt # Remove the file
Viewing File Content
Figure 3.5.1: Viewing File Content
Viewing File Content
Figure 3.5.1: Viewing File Content

Image Reference