In today's Command Line Basics we'll create some customized commands with alias. You can think of alias as a sort of command line shortcut. Odds are, your system already has a few aliases defined by default. If you enter the command by it's self, without an argument, it will tell you what aliases already exist on your system. Open a terminal window and give it a try.
alias l='ls -CF'
alias la='ls -A'
alias ls='ls --color=auto'
You may see some output that looks like the above. That output shows the proper syntax to create a new alias. One command I like to alias is 'ls -l'.
This functionality works great, but defining an alias on the fly only makes it stick to the current shell. If you open another terminal window, this alias won't be defined.
If you want an alias to be available every time you open a terminal window, you can define it in the .bashrc file. Go to your terminal and enter the following:
Now arrow down to an appropriate place in this file to define your alias. If you're not sure where to put it, the very bottom of the file should be fine. Now add a line to define an alias.
alias ll='ls -l'
Save the file and exit the editor. The .bashrc file is read each time you start a new bash shell. To test your new file you can close the terminal window and open a new one, or force the current window to re-read the .bashrc file with:
Have an aliased command that you find particularly useful? Leave a comment.