There is a terminal command called alias, that many users may not know exists, but likely will be very happy to find out about it.
The alias command, allows you to redefine what you type, to make things happen. It gives you the option to map large commands to an alias that you may run then instead of the large command to execute it.
A very straightforward (although risky) example of this would be:
alias dla="rm -rf *"
The reason this is both handy, but risky, is now if I enter any directory and simply type dla, I will delete everything in that directory. I did not add sudo to this, purposely, so at least system files can’t be deleted through this method, but caution must still be used. However, once accustomed to it, this alias combined with others like it, can speed up workflow exponentially.
Tip: Type alias to display the list of aliases set on the Linux machine.
Another that I use frequently, since I use nginx as my webserver of choice on all my remote servers, and I have to restart or reload nginx often when mucking around with configurations, so I use the alias:
alias n="sudo service nginx restart"
Now, I simply need to type the letter n, and the command will be executed, saving me insane amounts of time and keystrokes.
Here are some other aliases that you might find useful!
Aliases can make things so much faster when working with the command line, but always be careful not to set aliases up that could destroy your system with a simple keystroke, like a="sudo rm -rf *"as this runs far too many risks.
Now you: Do you use any aliases? What? Show us in the comments!
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.