Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Basic linux command

This document provides a comprehensive overview of essential Linux commands, including their syntax and usage examples. Key commands covered include pwd, mkdir, ls, cd, rm, cp, mv, cat, less, more, locate, find, grep, ssh, scp, ping, top, and htop. It serves as a practical guide for users to navigate and manage files and directories in a Linux environment.

Uploaded by

veyodo3765
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Basic linux command

This document provides a comprehensive overview of essential Linux commands, including their syntax and usage examples. Key commands covered include pwd, mkdir, ls, cd, rm, cp, mv, cat, less, more, locate, find, grep, ssh, scp, ping, top, and htop. It serves as a practical guide for users to navigate and manage files and directories in a Linux environment.

Uploaded by

veyodo3765
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Linux Commands

Ayush Singh
February 16, 2025

1 Commands
Bold letter (LHS) are command which you can use for practise.

Like in some places I uses small bracket() to write things like (source-path)
so when you will be writing command dont use small braket just write source
path only

pwd: • Stands for Present Working Directory (folder), gives you the
location of your current directory.

mkdir name: • Makes another directory in the present directory.


• Example: If you are in a desktop directory and you want
to make a folder named ”sec303” on the desktop, use the
command: mkdir sec303.

ls [-larht] : • It will list all the files or folders (directory) which are present
inside the current directory (folder you are inside).
• larht stand for different type of output that we want to
see in result of list function
-l : Long listing format. Displays detailed information about
each file, such as Permission, Number of links,Owner and
group,Size Modification date and time. Example: ls -l
-a: Shows all files, including hidden files (those starting with
a dot .). Example: ls -a
-r : Lists files in reverse order (Z to A or newest to oldest if
used with -t). Example: ls -r

1
-h: Displays file sizes in a human-readable format (e.g., KB,
MB, GB) instead of bytes. Usually used with -l. Example:
ls -lh
-t: Sorts files by modification time, with the newest files first.
Example: ls -lt
• combine uses will do respective works combined

cd : The cd (Change Directory) command is used to go from one di-


rectory to another.
• cd directory name Moves to the specified directory
whose name you will input.
• cd .. Moves to previous directory (if you are prently
in (N)th directory then this command will put you in
(N-1)th directory).
• cd address Moves to directory as given in address.
Example Usages: cd /home/user/Downloads - Moves
to the Downloads directory using an absolute path.
• cd - Switches to the previous directory.

rm [-rf ] file/folder : The rm (Remove) command is used to permanently


delete files and directories.

• -r : deletes a directory files / folders one by one after


asking for each
• -f : Forces the deletion without prompting for confir-
mation.
• -rf combine use will delete folder even if there are files
/ folder inside of that folder without asking.
cp [-r] (source-path) (destination-path): The cp (Copy) command is used
to copy files and directories.
• -r : Recursively copies an entire directory along with
its subdirectories and files.
mv (source-path) (destination-path): The mv (Move) command is used to
move or rename files and directories.
• Moves the entire content, either files or folders, to the
specified destination.

2
• Can also be used to rename a file or folder.

cat (filename): The cat (Concatenate) command is used to display the con-
tents of a file on the terminal.
• Displays the entire content at once, without pausing.
• Can also be used to concatenate multiple files.

less (filename): The less command is used to view the contents of a file one
page at a time.
• Allows scrolling through the file using arrow keys.
• Press q to quit and return to the terminal.

more (filename): The more command is similar to less but with limited
navigation.
• Displays the file contents page by page.
• Press the space bar to go to the next page.
• Press q to quit and return to the terminal.

Combining Commands: These commands can be combined for easier read-


ing and navigation.
• cat <filename> | less - Displays the file contents
with less navigation.
• cat <filename> | more - Displays the file contents
with more navigation.

locate (filename): The locate command is used to quickly find the location of
a file by searching through a prebuilt database of filenames.
• Faster than find because it searches the database, not
the file system.
• May need to update the database using sudo updatedb
for accurate results.
find (path) -name (filename): The find command searches for files and
directories in real-time.
• Searches through the directory tree recursively.
• Can search by name, size, modification date, and more.

3
grep [-c] (my-string) (where to search): The grep command is used to
search for a specific string or regular expression in files.
• Supports powerful pattern matching using regular ex-
pressions.
• -c: Counts the number of matches instead of displaying
the matched lines.

ssh (user)@(remote-ip): The ssh (Secure Shell) command is used to securely


connect to a remote computer.
• Establishes an encrypted communication channel.
• Commonly used for remote login and command execu-
tion.
scp (source) (user)@(remote-ip):(destination) : The scp (Secure Copy)
command is used to securely copy files between local and
remote systems.
• Utilizes SSH for secure data transfer.

ping (ip-addr): The ping command checks if a remote server or machine is


online and accessible.

• Sends ICMP echo requests to the target machine.


• Measures network latency and packet loss.

top: The top command displays real-time information about system


processes.
• Shows system summary, including CPU and memory
usage.
• Lists active processes managed by the Linux Kernel.
htop: The htop command is an enhanced version of top with a more
user-friendly interface.
• Allows scrolling and searching for specific processes.
• Provides color-coded CPU and memory usage graphs.

You might also like