Essential Linux Commands Handbook

A categorized reference manual for absolute beginners covering directory navigation, file manipulation, text processing, system diagnostics, and shell configuration.

Group 2

2. File Creation & Manipulation

Learn how to create empty files, copy items, move or rename files, and safely clean up unwanted files from your filesystem.

Command Description Example Usage
touch Creates an empty file or updates access/modification timestamps. touch notes.txt
cp Copies files and directories from one location to another. cp file.txt backup.txt
mv Moves or renames files and directories. mv old.txt new.txt
rm Removes (deletes) files or directories. rm unwanted.txt
ln Creates hard or symbolic links between files. ln -s /path/to/file link_name
# Create a file, copy it, then rename the copytouch document.txt
cp document.txt document_backup.txt
mv document_backup.txt final_doc.txt
Group 3

3. Text Viewing & Inspection

Inspect the contents of text files using tools ranging from quick printouts to interactive pagers and file snippet extractors.

Command Description Example Usage
cat Concatenates and displays file contents straight to the screen.cat config.cfg
less Views file contents interactively with forward and backward scrolling.less large_file.log
more Views file contents page by page scrolling forward. more report.txt
head Outputs the first few lines of a file (default is 10 lines).head -n 5 log.txt
tail Outputs the last few lines of a file, great for real-time log monitoring.tail -f /var/log/syslog
nano A simple, user-friendly terminal text editor. nano script.sh
# Quickly check the first 5 lines and continuously watch the end of a log filehead -n 5 /etc/passwd
tail -f /var/log/auth.log
Group 4

4. Text Processing & Filtering

Filter strings, search patterns, sort entries, and manipulate text content efficiently right inside the terminal stream.

Command Description Example Usage
echo Prints text strings or environment variables to the standard output.echo "Hello World"
printf Formats and prints text data with precise formatting control.printf "%s\n" "Item 1"
grep Searches text files or input streams for specific matching patterns.grep "error" app.log
sort Sorts lines of text files alphabetically or numerically.sort unsorted.txt
uniq Filters out or reports repeated adjacent lines in text.sort list.txt | uniq
wc Counts lines, words, and characters in files. wc -l data.txt
cut Extracts specific sections or columns from each line of text.cut -d':' -f1 /etc/passwd
diff Compares files line by line to highlight differences. diff file1.txt file2.txt
cmp Compares two files byte by byte. cmp bin1 bin2
# Search for a keyword in a file and count the matching linesgrep "failed" /var/log/auth.log | wc -l
Group 5

5. System Diagnostics & Hardware

Check overall system health, resource consumption, hardware specs, date/time parameters, and storage allocation.

Command Description Example Usage
whoami Displays the current active username. whoami
date Displays or sets the current system date and time. date
cal Displays a calendar in the terminal. cal
uname Prints system and kernel architectural information. uname -a
hostname Shows or sets the system's network hostname. hostname
uptime Shows how long the system has been running alongside load averages.uptime
free Displays total, used, and available system RAM memory. free -h
df Displays disk space usage for all mounted filesystems. df -h
du Estimates file and directory space utilization. du -sh /var/log
stat Displays detailed file or filesystem status attributes.stat index.html
# Check system memory status and available disk storage in human-readable formatfree -h
df -h
Group 6

6. Search, Help & Utility Tools

Locate files across your system, query command manuals, inspect environment setups, and configure shell shortcuts.

Command Description Example Usage
file Determines the true data type of a file. file archive.tar
find Searches for files and directories based on diverse criteria.find /home -name "*.txt"
which Locates the executable binary file for a specific command.which python3
whereis Locates binary, source, and manual pages for a command.whereis nginx
basename Extracts the filename component from a given file path.basename /var/log/syslog
dirname Extracts the directory path component from a file path.dirname /var/log/syslog
history Displays your command history list. history
man Opens the manual documentation page for any command. man ls
alias Creates a temporary custom shortcut or alias for commands.alias ll='ls -la'
unalias Removes a previously established command alias. unalias ll
type Indicates how a given command name is interpreted by the shell.type cd
sleep Pauses command execution for a specified number of seconds.sleep 5
exit Closes the current terminal session or shell. exit
# Look up the manual page for a command or check where its binary is storedman find
which grep

Guide Index