0% found this document useful (0 votes)
10 views8 pages

Linux Command Line Basics Guide

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)
10 views8 pages

Linux Command Line Basics Guide

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

Reg No: 24153145026 Name= Sameer Kumar Branch=cse(ds)

Operating System
Part 1: Navigation and Directory Management;-
1} * Open a terminal window.

* U se the pwd command to print the current working directory.

Explan:- ( pwd )… command, shows the full path of the directory you
are currently in.

2} * U se the ls command to list the contents of the current directory.

* U se the ls - l command to see a detailed listing with permissions, owner, size,


etc .

Explanation:-

The ls command lists the files and directories in your current location.

The ls - l command shows a long (detailed) listing of files and directories.

3} * U se the ls - a command to display hidden files (starting with a dot).

Explanation:-

ls –command show the hidden file that generally start whit (… ).

4} * Try navigating the directory structure using the cd command.


* U se cd .. to move up one level in the directory hierarchy.

Part 2: File and Directory Operations:-


1} * C reate a new directory named new_ dir using the mkdir command.

2} * C reate an empty file named [Link] using the touch command.

3} * C opy the [Link] file to a new location named test_ [Link] using the cp
command.

4} * Rename the test_ [Link] file to renamed_ [Link] using the mv command.

5} * Delete the [Link] file using the rm command

Part 3: Viewing File Contents:-


1} * U se the cat command to display the contents of the renamed_ [Link] file

2} * U se the less command to view the file's contents with scrolling capabilities.

3} * U se the head command to display the first 10 lines of the file.

4} * U se the tail command to display the last 10 lines of the file.

1} Expl:- cat command is use to display the content of the file.


2} The less command lets you view a file page by page with scrolling

3} The head command shows the first 10 lines of a file by default.

4} The tail command shows the last 10 lines of a file by default.

Part 4: Permissions and Ownership :-


1} * Briefly explore file permissions using the ls - l command output.

* (Optional) Try modifying file permissions using the chmod command (refer to
the

manual page for details)

Part 5: cat Command :-


1. Basic U sage :-

* Create a text file named [Link] and enter some content.

* U se cat [Link] to display the contents of the file.

2. Concatenating Multiple Files :-

* Create another file named [Link] with more content.

* U se cat [Link] [Link] to concatenate the contents of both files


3. Displaying a Range of Lines

* U se cat - n [Link] to display line numbers with the content.

* U se cat - n [Link] | head - 5 to display the first 5 lines with line numbers

Redirection

1. Output Redirection

* U se cat [Link] > new_ [Link] to redirect the output of cat to a new file.

* Verify the contents of new_ [Link].

2. Appending Output

* U se cat [Link] > > new_ [Link] to append the output to the existing
new_ [Link].

3. Input Redirection

* C reate a file named [Link] with some content.

* U se cat < [Link] to read the contents of [Link] and display them on the

terminal.
Part 6: Pipe :-
1. C haining Commands

* U se cat [Link] | wc - l to count the number of lines in [Link].

* U se cat [Link] | grep "search_ term" to search for a specific pattern in the file.

2. Creating a More Complex Pipeline

* U se cat [Link] | grep "keyword" | wc - l to count the occurrences of a


keyword

in the file.

* U se cat [Link] | grep "keyword" | head - 5 to display the first 5 lines


containing

the keyword

Part 7: System Information :-


* U se the uname - a command to view detailed system information.

* U se the top command to see a dynamic view of running processes and resource

usage.
* U se the df - h command to see disk space usage in a human- readable format.

* U se the du - h command to check disk usage for specific files and directories.
Part 8 (Optional): Searching and Finding Files :-
* U se the find command to search for files based on criteria (e.g., name, location)

* U se the grep command to search within files for a specific pattern.

Part 9 (Optional): Networking :-


* U se the ping command to check network connectivity to a host (e.g., ping

[Link]).

You might also like