Essential Linux Commands Every Engineer Should Master
This guide compiles the most essential Linux commands for directory handling, file manipulation, text processing, compression, system monitoring, networking, and routine administration, providing concise examples and practical tips to help beginners and seasoned users alike navigate and manage Unix-like environments efficiently.
Directory Operations
Common commands for creating, copying, moving, and deleting files and directories include mkdir (make directory), cp (copy), mv (move), and rm (remove). Example usage:
# create nested directories a/b/c/d
mkdir -p a/b/c/d
# copy directory a to /tmp
cp -rvf a /tmp/
# move a to /tmp and rename to b
mv -vf a /tmp/b
# delete everything (use with extreme caution)
rm -rvf /Navigation ("Roaming")
Use ls to list directory contents, ls -l for detailed info, pwd to show the current working directory, cd to change directories, and find to locate files based on criteria.
Text Processing
Key editors and filters include vim, sed, and awk. Links to detailed tutorials are omitted for brevity.
Viewing Files
cat displays file contents (use Ctrl+C to stop large outputs). less provides paginated viewing with search ( / to search, n / N to navigate). tail follows file growth (e.g., tail -f access.log) and can show the last N lines ( tail -n100 access.log); head shows the first N lines.
tail -f access.log tail -n100 access.log
head -n100 access.logStatistics
Combine sort and uniq to count occurrences. Example to list top 10 IPs by page views in an nginx log:
awk -F"|" '{print $3}' access.log | sort | uniq -c | sort -nk1 -r | head -n10Other Useful Commands
grep – filter text; --color highlights matches, -n shows line numbers (e.g., grep -rn --color POST access.log).
A , B , C – grep context options: -A (after), -B (before), -C (both) (e.g., grep -rn --color Exception -A10 -B2 error.log).
diff – compare files; often used with patch for applying changes.
Compression
Common formats and commands: .tar (tar), .bz2 (bzip2), .gz (gzip), .zip (unzip), .rar (unrar). The most used combined format is .tar.gz (tar archive then gzip compression).
# create a tar.gz archive
tar cvfz archive.tar.gz dir/
# extract a tar.gz archive
tar xvfz archive.tar.gzDaily Operations
shutdown – power off the machine (requires appropriate permissions).
passwd – change user password.
mount – mount external devices (e.g., mount /dev/sdb1 /mnt).
chown and chmod – change file ownership and permissions (e.g., chmod 000 -R / is destructive; chmod +x script.sh makes a script executable).
yum – package manager on CentOS (e.g., yum install wget -y).
service / systemctl – manage services (e.g., service mysql restart or systemctl restart mysqld).
kill – terminate processes; signals -9, -15, -3 have different effects.
su – switch user (e.g., su - xjj).
System Overview
uname -a – display kernel and system information.
ps -ef | grep java – list Java processes.
top -H -p PID – monitor threads of a specific process.
free – show memory usage.
df -h – display disk usage in human‑readable format.
ifconfig or ip addr – show network interfaces.
ping – test connectivity.
netstat -ant – list active TCP connections.
Networking
ssh – remote login; use -v for verbose output and ssh -L for tunneling.
scp – copy files over SSH (e.g., scp a.txt [email protected]:/tmp/).
wget -c – download files with resume support.
Database Access
Connect to MySQL from the command line:
mysql -u root -p -h 192.168.1.2Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
