20 Essential Linux Commands You Probably Don't Know (But Should)
20 Essential Linux Commands You Probably Don't Know (But Should)

20 Essential Linux Commands You Probably Don't Know (But Should)

The Linux command line is a powerful tool, but many users only scratch the surface. This guide introduces 20 underrated commands that can simplify complex tasks, from file management to system monitoring. Perfect for beginners and experienced users alike

By Avisek Ray |
5 min read | 700 views
20 Essential Linux Commands You Probably Don't Know (But Should)

20 Linux Commands That'll Make You a Command-Line Ninja (Even If You're a Beginner)

Hey everyone! I'm a developer, and like many of you, I spend a good chunk of my time in the Linux terminal. Over the years, I've picked up some incredibly useful commands that aren't exactly household names, but they've drastically improved my workflow. I figured I'd share 20 of my favorites with you in this blog post. These aren't just your basic ls and cd – we're going a little deeper. I'll explain each command in simple terms, so even if you're new to Linux, you'll be able to follow along.

1. history | grep "keyword": Your Command-Line Time Machine

Ever typed a long command and then needed it again later? Instead of retyping it, use history to see your command history. Pipe that output to grep to search for a specific command. For example, history | grep "install" will show all the commands you've used that contain "install".

2. !!: Repeat the Last Command (with a Bang!)

This is a tiny but huge time saver. !! simply repeats the last command you executed. Super useful if you made a typo or need to run the same command again.

3. !n: Repeat Command Number 'n'

If you know the number of the command in your history (you can see it with history), you can execute it directly with !n. For example, if history shows that command number 123 is sudo apt update, you can run it again with !123.

4. Ctrl + R: Reverse Search Through History (Interactive)

This is my absolute favorite. Press Ctrl + R and start typing part of the command you're looking for. It will search backward through your history and find the most recent match. Keep pressing Ctrl + R to cycle through older matches.

5. alias: Create Your Own Shortcuts

Tired of typing long commands? Create aliases! For example, alias la='ls -la' will let you type la instead of ls -la. Put aliases in your .bashrc file (or .zshrc if you use Zsh) to make them permanent.

6. watch: Keep an Eye on Things

The watch command lets you run a command repeatedly and see its output update in real-time. For example, watch -n 1 "ls -l" will run ls -l every second and show you the updated directory listing. Great for monitoring file changes or system status.

7. du -sh *: Disk Usage Breakdown

du (disk usage) shows you how much disk space files and directories are using. du -sh * gives you a human-readable summary of disk usage in the current directory.

8. df -h: Disk Free Space

df shows you disk free space. df -h makes the output human-readable (e.g., in GB or MB).

9. top or htop: System Monitoring

top (or the more user-friendly htop if you have it installed) shows you a dynamic real-time view of running processes, CPU usage, memory usage, and more. Essential for troubleshooting performance issues.

10. ps aux | grep "process_name": Find a Specific Process

ps aux lists all running processes. Pipe it to grep to find a specific process by name. For example, ps aux | grep "firefox" will show you information about the Firefox process.

11. kill PID: Terminate a Process

Once you've found a process ID (PID) using ps, you can terminate it with kill PID. Be careful with this command!

12. xargs: Build and Execute Command Lines

xargs takes input from another command and turns it into arguments for another command. This is incredibly powerful for batch processing. For example, find . -name "*.txt" | xargs grep "keyword" will search for "keyword" in all .txt files in the current directory and its subdirectories.

13. cut: Extract Parts of Lines

cut lets you extract specific parts of a line based on delimiters or character positions. For example, cut -d: -f1 /etc/passwd will extract the first field (username) from the /etc/passwd file, using ":" as the delimiter.

14. sort: Sort Text Files

sort sorts the lines of a text file. For example, sort myfile.txt will sort the lines of myfile.txt alphabetically. You can use options like -n for numerical sorting or -r for reverse sorting.

15. uniq: Remove Duplicate Lines

uniq removes consecutive duplicate lines from a file. It's often used with sort. For example, sort myfile.txt | uniq will sort the lines of myfile.txt and then remove any duplicate lines.

16. tr: Translate or Delete Characters

tr can translate characters from one set to another or delete characters. For example, tr 'a-z' 'A-Z' < myfile.txt will convert all lowercase letters in myfile.txt to uppercase.

17. wc: Word Count

wc counts the number of lines, words, and characters in a file. wc -l myfile.txt will only show the number of lines.

18. diff: Compare Files

diff shows the differences between two files. It's essential for comparing code versions or configuration files.

19. curl or wget: Download Files

curl and wget are command-line tools for downloading files from the internet. curl is more versatile, while wget is simpler for basic downloads. For example, wget https://example.com/file.zip will download file.zip from the specified URL.

20. tar: Archive and Compress Files

tar is used for creating and extracting tar archives (often compressed with gzip or bzip2). tar -czvf archive.tar.gz directory will create a compressed archive of directory. tar -xzvf archive.tar.gz will extract the archive.

These 20 commands are just a starting point. There are countless other useful commands out there. The more you explore the command line, the more efficient and productive you'll become. So, get out there, experiment, and have fun! Happy coding!


About the Author

Avisek Ray

I am a skilled full-stack developer with expertise in Python (Django, FastAPI) and JavaScript (Next.js, React). With over a year of experience, I’ve delivered scalable web applications, including a news website and an AI-powered project planner. I focus on creating secure, high-performance solutions while continually expanding my skills in SQLAlchemy, Docker, and advanced Python practices. Driven by curiosity and a passion for problem-solving, I aim to build impactful, innovative applications

Related Posts

Stop Website Crashes:  A Simple Guide to Token Bucket Rate Limiting for Developers

Stop Website Crashes: A Simple Guide to Token Bucket Rate Limiting for Developers

Is your website slowing down or crashing under heavy traffic? Learn how the token bucket algorithm can be your secret weapon! This easy-to-understand guide breaks down rate limiting with real-world examples, showing developers how to protect their sites and APIs from overload – no complex jargon needed!

Read this post
DeepSeek: Genius or Cheater? The Debate on AI Transparency & Data Practices

DeepSeek: Genius or Cheater? The Debate on AI Transparency & Data Practices

Is DeepSeek a cheater or a genius? Should OpenAI be held accountable for its data practices? Dive into this post as we break down the debate on AI transparency, data ethics, and the future of AI technology. Share your thoughts in the comments! 😊

Read this post
DeepSeek AI: What is it, is it better than Chatgpt ?

DeepSeek AI: What is it, is it better than Chatgpt ?

Since 2022, we’ve seen significant innovations in artificial intelligence. If we talk about OpenAI, they have introduced models like GPT-3, GPT-4, and now their latest model, O1, which has brought several advancements. But what’s the main reason behind these innovations? One of the biggest factors is cost. Earlier models from OpenAI and other companies were expensive, but recently, China launched DeepSeek R1, which has disrupted the industry because they built the entire project for less than $

Read this post