Basic linux command
Basic linux command
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.
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
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.
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.