Skip to main content

Command Palette

Search for a command to run...

Linux Command Superpowers: From Hidden Tricks to Process Control

Updated
3 min read
Linux Command Superpowers: From Hidden Tricks to Process Control
M

Hello, I’m Badhon. I tend to forget things easily, which is why I started this blog.

Linux is full of powerful shortcuts and commands that can save you time and make you look like a pro. This article explains some of the most useful ones from two YouTube videos — covering both everyday command-line tricks and process management basics.

1. Run as Root Instantly with sudo !!

Ever typed a command only to see “Permission denied”? Just type sudo !! to rerun your last command with root privileges. This saves time and avoids retyping long commands.

2. Hide Commands from History

Add a space before a command to prevent it from being saved in your .bash_history file. This is useful for commands containing passwords or sensitive data.

3. Fix Mistyped Commands with fc

The fc command opens your last command in a text editor. You can fix it there instead of struggling with arrow keys. Save and exit to run the corrected version.

4. Use Brace Expansion to Save Time

You can create multiple directories at once using braces. For example:
mkdir -p {ProjectA,ProjectB}/{src,bin}
This makes folders for both projects with src and bin inside.

5. Use tee to Log and View Output

The tee command splits the output of a program — it shows it on your screen and saves it to a file at the same time. Example:
ls | tee files.txt

6. Keep Programs Running After You Exit

Use disown -a before closing the terminal. This detaches running jobs so they keep going even after you log out.

7. ps – See What’s Running

Shows all current processes. Use ps -f for detailed information like parent and child processes.

8. exec – Replace the Current Shell

Runs a command that takes over your current shell. When the command ends, the shell closes too.

9. Ctrl + C – Stop a Process

Sends a SIGINT signal to stop the running process gracefully. It is not the same as kill -9, which forces the process to end immediately.

10. Ctrl + Z – Pause a Process

Sends a SIGTSTP signal, which pauses the program. You can resume it later with fg or bg.

11. jobs – List Background Tasks

Shows all processes you have paused or sent to the background in the current terminal.

12. fg and bg – Resume Tasks

Use fg to bring a job to the front or bg to continue it in the background.

13. & – Run in Background

Adding & after a command starts it in the background. Example:
sleep 60 &

14. kill – Stop a Process by ID

Sends a signal to a process using its PID.

  • kill PID sends SIGTERM (15) to stop it gracefully.

  • kill -9 PID sends SIGKILL, forcing it to stop immediately.

  • kill -20 PID stops it (like Ctrl + Z).

  • kill -18 PID continues it (like bg).

These commands are the heart of Linux productivity. From rerunning commands with sudo !! to managing jobs with fg, bg, and kill, mastering them will make your terminal life much smoother.

Try them out step by step, and you’ll soon feel right at home in the command line.