
That blinking cursor. It’s both a promise and a challenge. For Linux users, it’s the gateway to unparalleled power, flexibility, and efficiency. But let’s be honest, that first glimpse into the terminal can be…daunting. It’s a blank canvas demanding a masterpiece, and all you’ve got is a blinking cursor. Fear not! Unlock the secrets of the command line. These Bash tips and tricks will transform you from a terminal novice to a command-line ninja. Work smarter, not harder, and bend the terminal to your will.
Bash vs. the Terminal
Think of your computer as a sophisticated stage. The terminal? That’s just the curtain, the portal through which you speak. Bash? That’s the playwright, the interpreter fluent in the arcane language your computer understands. When you type commands into the terminal, you’re not talkingtothe terminal; you’re whispering instructions to Bash (or perhaps zsh, fish, or another equally intriguing shell). Forget thinking “terminal = Bash.” Think of it as: Terminal + Bash = Your command central. The following tips and tricks unlock the power of Bash, not just the terminal’s window dressing.
1. Create Custom Aliases for Frequent Commands
Tired of finger fatigue from repeatedly typing lengthy commands? Drowning in a sea of daily keystrokes? Escape the mundane with aliases – your secret weapon for command-line efficiency. Short, sweet, and instantly memorable, aliases transform tedious typing into effortless execution.
Tired of typinggit status
ad nauseam? Unleash your inner Git guru by crafting custom aliases! Transform that verbose command into a sleek shortcut likegs
– or any other cryptic concoction you desire. These aliases can be fleeting, existing only for your current session, or immortalized, etched into your Git configuration for eternity.
To create a temporary alias for your current session, you can use the alias command like this:
“`
alias
gs
=
“git status”
“`
Unlock Git mastery with a simplegs
command! Bash now executesgit status
at your fingertips. But that’s just the beginning. Imagine an entire arsenal of personalized shortcuts, permanently etched into your workflow, transforming your Git experience forever.
Simply open your Bash configuration file (usually “~/.bashrc” or ~/.bash_profile) with your preferred editor, like nano:
“`
sudo
nano
~
/
.bashrc “`
Next, add your alias commands to the end of the file.

Save it, restart your terminal, or run:
“`
sudo
source
~
/
.bashrc “`
Imagine instant access to your favorite tools, right when you fire up the terminal. I’ve streamlined everything with aliases, especially those crucial update and upgrade commands – they’re now just a keystroke away.
“`
alias
update
=
‘sudo apt update && sudo apt upgrade -y’
“`
Now, instead of typing the full command, I just typeupdate
, and it will do the rest. In addition, you can even create aliases with parameters using functions:
“` mkcd
(
)
“`
Forget tedious setups! Withmkcd projects/new-app
, conjure your project directoryandteleport inside instantly. A word of caution: steer clear of naming your creations after existing commands, unless you enjoy a good brain scramble.
2. Search Through Your Command History Instantly
Lost in the labyrinth of your terminal history? Tired of endlessly tapping the up arrow, hunting for that elusive command? Stop the scroll! Bash has a secret weapon: a built-in search function that transforms command recall from tedious trek to instant retrieval.

Unleash the power of your command history with a simple keystroke:Ctrl
+R
. Your terminal transforms into a search portal, ready to recall your past commands. Just start typing – any fragment will do – and watch as Bash instantly resurrects the most recent match from your command graveyard. It’s like having a command-line time machine at your fingertips!
Alternatively, paste this snippet to your “~/.inputrc” file (if it doesn’t exist, create it):
“`
“\e[A”
: history-search-backward
“\e[B”
: history-search-forward
set
show-all-if-ambiguous on
set
completion-ignore-case on “`
Unleash the power of your bash history! Tired of retyping lengthy commands? Just start typing! Then, tap the Up arrow and watch as your terminal magically recalls commands matching what you’ve already entered. For instance, begin with “cd /”, hit Up, andpoof– your history unfurls, revealing all commands starting with “cd /”. Terminal mastery unlocked.
3. Chain Commands Together Using Pipelines and Redirection
Unleash the power of Bash by forging command chains! Forget executing commands in a boring, single-file line. The pipeline operator (|) lets you weave them together, turning the output of one into the input of the next – a symphony of shell commands working in perfect harmony.
Instead of wrestling with separate commands just to pinpoint those Python processes, imagine wielding a single, elegant chain. Here’s how to lasso exactly what you need.
“`
ps
aux
|
grep
python “`

Unleash the power of the command line! Want to pinpoint those sneaky Python processes?ps aux | grep python
is your magic wand. It’s like having a detective sniff out Python in a crowd of running programs. But the real fun begins when you chain commands – build your own custom one-liners and become a command-line ninja!
“`
cat
logfile.txt
|
grep
“error”
|
wc
-l
“`
This counts how many error lines appear in a log file – three commands working together seamlessly.
Imagine your screen as a stage. Normally, the spotlight shines directly on it, displaying every command’s performance. But what if you could direct that performance elsewhere? Redirection is your stage manager, allowing you to reroute the output of commands – not to the screen, but to a file of your choosing. Want to capture a snapshot of your current directory structure? Just redirect the listing to a file andpoof, instant record.
“`
ls
-l
files.txt “`
Want to add to a file without wiping it clean? Use> >
instead of>
to append data. This simple trick is a lifesaver for logging events, creating backups, or archiving any output you want to revisit later. Think of it as adding a new chapter to an existing book, instead of rewriting the whole story.
4. Send Any Running Command to the Background
Terminal frozen mid-task? Don’t kill it! Instead of abandoning your marathon file transfer or that epic compilation, banish it to the background. Free up your terminal without losing progress.
Imagine a runaway train – your process careening out of control. Need to slam on the brakes?Ctrl
+Z
is your emergency lever. Hit it, andwhoosh– the process freezes mid-stride, dropping you back at your command prompt, ready to reassess the situation. Now type:
“`
bg
“`
Think of it as a silent engine humming in the background, letting you power forward on other tasks. Need to peek under the hood and see which jobs are revving up or idling? Just use this:
“`
jobs
“`
You can also bring one back to the foreground with this:
“`
fg
%
1 “`
“Need to bring a backgrounded process back to the foreground? Just typefg
followed by the job’s number. Forget the number? No problem!fg
will automatically grab the most recently backgrounded process. Want a command to start in the background right from the get-go? Simply tack on an ampersand&
at the end of your command, like so:”
“` somelongtask
&
“`
Want a super-clean start? Detach that process! Your prompt’s ready the instant you hit enter. Worried about a sudden shutdown killing your long-running task? Here’s your lifeline:
“`
disown
-h
%
job “`
Imagine launching a process from your terminal, only to have it abruptly killed the moment you close the window. Bummer, right? Prevent that terminal disconnect heartbreak! By default, closing your shell sends a “hangup” signal (SIGHUP) to its child processes, effectively telling them to quit.
Want your process to soldier on, even after you’ve logged off? Enter thenohup
command. Simply prefix your command withnohup
, and your process will become immune to the SIGHUP signal.
Keep in mind, though: detached processes still love to chat. They’ll continue to output to your terminal unless you redirect that output to a file. Not all commands play nicely in the background either. So, usenohup
with redirection (> filename.out
) for a truly independent, backgrounded process. Think of it as sending your command off on a solo mission!
5. Rerun the Previous Command With Root Privileges (sudo !!)
Ever fumble when you forget “sudo”?!!
is your instant replay button. It resurrects your last command, letting you slapsudo
in front and execute it flawlessly. Stop retyping; start commanding.
Ever fumble an installation, only to be told you need superuser powers? Forget retyping that command! Just punch insudo !!
, slam that Enter key, and unleash the password beast. Boom. Problem solved. It’s pure command-line wizardry that’ll have you breezing through permissions errors faster than you can say “access denied.” Trust me, once it’s muscle memory, you’ll wonder how you ever lived without it.

6. Run Multiple Commands Simultaneously
Tired of the one-command-at-a-time grind? Unleash the power of Bash chaining! Imagine a world where commands flow seamlessly, executing back-to-back while you kick back. The secret weapon? A simple semicolon (;). Use it to string commands together and watch them execute in ruthless succession, regardless of success or failure. Conquer your terminal – one semicolon at a time!
“`
mkdir
newdir;
cd
newdir;
touch
file.txt “`
If you only want the second command to run when the first one succeeds, use&&
, like this:
“`
sudo
apt update
&&
sudo
apt upgrade “`
On the flip side, you can use||
to run something only if the first command fails:
“` backup_database
||
echo
“Backup failed!”
“`
Tired of your terminal hogging all the attention? Unleash its multitasking power! Just tack an ampersand (&) onto any command andpoof– it vanishes into the background, freeing up your prompt for more action. Want to launch a fleet of apps from the command line? The possibilities are endless… and incredibly efficient.
“` python script.py
&
firefox
&
“`
Unleash the Power of Parallel Execution: Launch your Python script and Firefox simultaneously! Master the art of command chaining, background jobs, and subtle process substitution, and watch your command line evolve. No longer single steps, these become Lego bricks for crafting powerful, automated workflows.
7. Finding Commands with Apropos
Ever needed a secret weapon to unearth the perfect Linux command? Meetapropos
(say it like “app-row-POE”). Think of it as your command-line bloodhound, sniffing out commands with man pages based on their descriptions. Forget endless Google searches!apropos
is your direct line to the treasure trove of theman
command. What will your manual page look like?

Ever wondered how to unearth hidden gems within your terminal? TheNAME
section, that unassuming line at the top of a command’s manual, is your secret weapon. Let’s say you’re hunting for theping
command, but all you remember is something about “ICMP.” Just fire upapropos icmp
case doesn’t matter here and watch as your terminal conjures up a list of commands whoseNAME
entries mention “ICMP.” It’s like having a digital archaeologist at your fingertips, unearthing the tools you need with a simple, intelligent search.

Unleash the power ofapropos
to discover hidden gems in your system, likeselinux
. Typingapropos selinux
is like unlocking a secret vault, revealing a treasure trove of commands. Master these, and you’ll be well on your way to becoming an SELinux enforcement guru.
8. Substituting in the Previous Command
Ever fat-finger a command in the terminal, only to stare in horror at your mistake? Fear not! There’s a ninja-level trick to fix typos or swap options in yourlastcommand without retyping the whole shebang. Just unleash the power of the caret:^old^new^
. Boom! Terminal time warp achieved. Instantly replace “old” with “new,” and watch your previous command morph into perfection.
Imagine you’re a digital explorer, sending out a signal to a distant land: “maketecheasier.com.” It’s a simple check to see if the path is clear, if the internet’s bridges are all standing strong. But what if your message is slightly off? What if you typed “maktecheaser.com,” accidentally dropping an “i” along the way? Suddenly, silence. The connection falters, and your digital ping vanishes into the void, highlighting the internet’s unforgiving nature.
“Misspelled a crucial domain? No sweat. A quick^maktecheaser.com^maketecheasier.com
will fix it on the fly, executing the command as if it were perfect all along. This simple trick is a lifesaver when you’re wrestling with lengthy commands packed with options. Imagine accidentally using>
instead of> >
mid-execution. This substitution command lets you correct the error and avoid restarting the whole process.”

Tired of typingsystemctl start
,systemctl stop
,systemctl disable
over and over? Unleash the power of command-line shortcuts! I swap out the mundane with the magic of^start^enable
. It’s a tiny tweak that adds up to monumental time savings.
9. Passing Arguments from Previous Commands
Unleash the power of your command line! With the magic of!$
, grab the last argument from the previous command and wield it in your current one. But that’s not all – tweak it, twist it, and you can pluckanyargument from the past, instantly making it part of your present command. Level up your terminal game!
Ever feel like a coding wizard? Conjure this: you’re knee-deep in script edits,nano samplescript.sh
blazing across your terminal. Done? BAM! Turn that script into a lean, mean, executable machine with a swiftchmod 755 !$
. But wait, need to call upon its name again? No sweat. A mystical./!:2
and the second argument appears as if summoned by magic.

Some other examples:
“`
!
^ – first argument
!*
- all arguments
!
:
2
-$ – second through
last
arguments
!
:
2
–
4
- second through fourth arguments “`
Want to supercharge your Bash scripting? Forget painstakingly typing arguments. This trick lets you swap in variables on the fly. Bash can juggle nearly 100 arguments at once, letting you bulldoze through repetitive tasks with lightning speed. Think batch renaming files or bulk processing data – all automated and streamlined.
Ready to level up your terminal game? These Bash tips and tricks were just the beginning. Now, unlock the true potential of your shell: master Bash variables and special characters to bend the command line to your will.
Thanks for reading 9 Bash Tips and Tricks Every User Should Know