Practical 3: Perform an operation of operating system for File Management System
2024, February 14
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.
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
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
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
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
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