Linux Time Saving Tip: Use Bash Aliases for Commands!
If you frequently use the same command andparameters over and over in Linux or Bash, I’ve got an easy time-saving trick thathas made my life much easier.
I’m EposVox here to make tech easier andmore fun and today I’m going to show you how to set up an “Alias” for commandsto save you time from typing the parameters over and over or copy-pasting a lot.
For my example, I’m going to use the Bashon Windows Ubuntu subsystem in Windows 10 – here I frequently use wget to download opendirectories from one of my favorite subreddits.
For this, my usual command is “wget -r -erobots=off -nc -np” and then the URL of the directory or site.
This is a lot, and even if I copy-paste it,it’s a hassle, as I also need to copy-paste the URL and it just becomes tedious.
So instead, I set up an alias called “dl”so then all I have to do is type “dl” followed by pasting in the URL and it automaticallydoes the whole command for me.
It has saved me a ton of time! So in just about any Linux distro or eventhe Bash on Windows terminal if you have that enabled – type in “nano.
Bashrc” being one word and no slashes.
This will open up the nano text editor.
If you’re on a full Linux install, you canuse Gedit or Vim or something, but for the Windows system, nano is easier.
Use the arrow keys to navigate to the endof the existing Aliases section, and hit enter to make a new line.
To make your alias, simply type “alias”space, then your alias name – for example mine is “dl” (for download) – then theequals sign (no space), a single apostrophe, then the command you’re entering – hereI’m using wget and the parameters I use – and end with another apostrophe at the end.
Save the file.
In Nano, it’s Control o, enter, then ControlX to exit the file.
Now simply close your terminal and re-launchit and you’re good to go.
Now I can just type “dl” followed by theURL and it uses the full string I used to have to type.
You do need to close the terminal and re-open,however.
This method involves editing the Bash configurationfile that is only loaded when you first open the terminal.
So if you don’t close it, it won’t recognizeyour command yet.
But that’s it! Super simple, easy to implement, but savesyou a lot of time.
I love it a lot.
If you’re looking for a dedicated Linuxmachine to unleash your potential, check out System76 – the best Linux-based PC distributorin the U.
ran by real humans.
They’re a great team and I really standbehind them.
Learn more by clicking the link in the videodescription.
I hope this video has been helpful to you.
Hit the like button if it was, and subscribefor more awesome tech content.
I’m EposVox and I’ll see you next time.