Creating aliasses in Linux

Standaard

An alias in Linux gives you the possibility to shorten your command’s syntax.

For example, if you need to enter following code in your terminal to compile less code to css:

node less-watch-compiler.js less css

You can shorten this so you only need to enter the following code in your terminal:

less-watch-compiler less css

How do we do that? Simple, just follow the steps below:

  • Open /etc/profile in an editor
    • sudo nano /etc/profile
  • Add the following rule to your /etc/profile file
    • alias your-short-command-name=”the/command/directory/command parameter1 parameter2 …”
  • Exit and save your /etc/profile file
  • Execute “source /etc/profile”
  • That’s it

Based on the above example, I’ve added the next rule to /etc/profile:

alias less-watch-compiler=”node /Location/to/the/tool/Dead-Simple-LESS-Watch-Compiler/less-watch-compiler.js”