Commonly Used Linux Commands: A Quick Reference Guide
This article provides a comprehensive cheat‑sheet of the 21 most frequently asked Linux commands, covering file navigation, content viewing, searching, permissions, text processing, archiving, system control, and process management for interview preparation and daily use.
This article compiles the 21 most frequently used Linux commands, often asked in interviews, serving as a quick‑reference manual.
1. File and Directory
cd : change directory (e.g., cd /home, cd .., cd -).
pwd : display current working directory.
ls : list files ( ls -l, ls -a, ls -R, etc.).
2. Viewing File Content
cat : display file, with options like cat -n file.
more , head , tail : paginate or show specific lines (e.g., head -n 2 file, tail -n +1000 file).
Combination example: cat filename | head -n 3000 | tail -n +1000 shows lines 1000‑3000.
3. File Search
find : locate files (e.g., find / -name file1, find /usr/bin -type f -atime +100).
whereis and which : locate binaries or source files.
Delete files larger than 50 M:
find /var/mail/ -size +50M -exec rm {} \;4. Permissions
chmod : modify mode (e.g., chmod ugo+rwx dir, chmod go-rwx dir).
chown : change owner (e.g., chown user1 file, chown -R user1 dir).
chgrp : change group (e.g., chgrp group1 file).
5. Text Processing
grep : filter lines (e.g., grep Aug /var/log/messages).
sed : stream editor for substitution and deletion.
paste : merge files (e.g., paste file1 file2).
sort and uniq : sort and deduplicate.
comm : compare two sorted files.
6. Archiving and Compression
tar : create, list, extract archives with options -c, -t, -x, -z, -j, -v, -f, -C.
Examples: tar -jcv -f archive.tar.bz2 dir, tar -jxv -f archive.tar.bz2 -C /dest.
Other tools: gzip, bzip2, gunzip, rar, zip, unzip.
7. System Shutdown and Reboot
shutdown -h now, init 0, telinit 0 – power off. shutdown -r now, reboot – restart. logout – log out. time command – measure execution time.
8. Process Management
jps : list Java processes.
ps : display processes (e.g., ps aux, ps -lA).
kill , killall , pkill : send signals to terminate processes (e.g., kill -9 pid).
top : interactive performance monitor.
Check listening ports: netstat -tunlp | grep PORT.
Signed-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.
Laravel Tech Community
Specializing in Laravel development, we continuously publish fresh content and grow alongside the elegant, stable Laravel framework.
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.
