Last Updated: February 25, 2016
·
743
· spoike

Aliasing like a pro

Are you new to this Linux or Mac Bash Terminal thingies? Fear not dear Windows user! You can use aliases to make some commands easier. The alias command is invoked like this:

alias [new_command]='[old_command]'

Here is one example that will create the dir command, which windows users may think is missing in non-windows terminals, to list directory contents (using the ls command):

$ alias dir='ls color=auto'

To remove aliases you use the ualias command like this:

$ ualias dir
$ dir
bash: dir: command not found

Note that aliases are not permanently added to your environment. In order to do so you need to add the alias commands in your shell profile. In Linux this is usually the .bash_profile file and on Mac OS X it is usually the .profile file. Both files reside on your home directory (cd ~ or just cd will also do if you want to change to the home directory).

Of course you can do funny things with aliases, how about the following command?

$ alias plz=sudo

Which serves as a humorous reminder for those of us that forget to invoke the sudo command when we're working on system configs and other things.