0% found this document useful (0 votes)
16 views3 pages

Pract2 Linux

The document outlines a practical session for the Fundamentals of Linux OS course at Shri Ramdeobaba College of Engineering and Management. It includes various file system and file handling commands, such as creating, copying, moving, and deleting files and directories, as well as experimenting with command outputs. Additionally, it provides specific tasks for students to complete, reinforcing their understanding of Linux commands and file management.

Uploaded by

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

Pract2 Linux

The document outlines a practical session for the Fundamentals of Linux OS course at Shri Ramdeobaba College of Engineering and Management. It includes various file system and file handling commands, such as creating, copying, moving, and deleting files and directories, as well as experimenting with command outputs. Additionally, it provides specific tasks for students to complete, reinforcing their understanding of Linux commands and file management.

Uploaded by

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

Shri Ramdeobaba College of Engineering and Management, Nagpur

Department of Computer Science and Engineering


Session: 2024-2025

Fundamentals of Linux OS I Semester

PRACTICAL NO. 2

Aim: Experimentation with File system and file handling commands

Theory:

File Commands
 $ cat filename display the contents of file filename
$ cat > filename create a file with the name filename
$ cat >> filename append into the file filename

 $ touch filename create an empty file


 $ more filename display screenful content of the file;
press space bar to scroll and ctrl d to quit
 $ less filename same as more but also allows to move
backward and forward; press Ctrl B for
backward and space bar for forward
 $ cp file1 file2 copy file1 to file2, overwrite old file2 if it
exists
 $ mv file1 file2 move/rename file1 to file2, overwrite old
file2 if it exists, move file1 to file2 if file2 is
a directory
 $ rm filenames remove filenames
options : -i asks for confirmation before deleting the file
 $ ls list names of all files in current directory
options: -l list more information about each file
-a list all files, including hidden ones
-t list in time order, most recent first
-u list by time last used
-r list in reverse order
 $ ls filenames list only the named files
 $ wc filename count lines, words, and characters for each
file
options : -l count lines
-w count words
-c count characters

Directory Commands
 $ pwd print current working directory
 $ mkdir dirname creates a directory
 $ cd dirname go to the directory
 $ cd go to home directory
 $ cd .. moves up one level in file system
 $ rmdir dirname removes the empty directory
 $ rm –r dirname recursively deletes the entire contents of the
directory as well as the directory itself

Miscellaneous Commands
 $ grep pattern file display lines matching pattern
options : -v display lines not matching pattern

-i ignore case

-l display filenames instead of lines

-n prefix each line of output with line number

-x select only those matches that exactly match

the whole line

 $ sort filname sort files alphabetically by line


options : -r reverse normal order

-n sort in numerical order

-f fold upper and lower case together

$ tail filename display last 10 lines of file

options : -n display last n lines of file

 $ head filename display first 10 lines of file


options : -n display first n lines of file

 $ cmp file1 file2 display location of first difference


 $ diff file1 file2 display all differences between files
EXPERIMENTATION:
1) What is the purpose of blue and white color in ls command execution.
2) Display your current directory.
3) List all the files (including hidden files) in your home directory
4) Go to path /home/<your username>
5) Create directory structure as follows

6) Do as directed:
1. Change directory to FLOS
2. Change directory to file1 using single command
3. Go back to immediate parent directory from file 1
4. Delete the directory file1
5. Show the contents of pract3
6. Create an empty file (file1.txt) in data1 directory
7. Write student names in file1.txt (one name per line)- Also write the name
“Aryan” 5 times.
8. Display the count of lines, words, and characters in file1.txt
9. Copy all the contents of file1 to file2 (let file 2 be in the same directory)
10. Rename file2 to file3
11. Display the contents of file3 using different methods- display entire content,
display last 3 lines, display first 3 lines
12. Delete file1.txt
13. Display student names alphabetically (from file3.txt)
14. Display the count of occurrence of “Aryan” in file3.txt using grep
command
15. Create a file (file4.txt) in data2 directory with numbers and display sorted
numbers in reverse.

You might also like