Unix and Linux aliases are a really nice way of customizing the command line to work the way you want it to work. With alias commands, you’re essentially doing a little programming, and creating new Unix and Linux commands custom-tailored to the way you work. You can create aliases to use instead of existing commands, and you can also create aliases as Linux command pipelines.
I’m not going to describe my Linux aliases too much, but mostly just put them out here so you can see how they work. One thing I should note is that this syntax assumes you’re using the Bash or Korn shells. The syntax is a little different with other shells, like csh, but I don’t remember the syntax differences, so I’m just going with the Bash alias syntax.
Sample Linux aliases
Here’s a list of sample aliases I currently use (or have used in the past):
alias cd..="cd .." alias cd...="cd ../.." alias cd...="cd ../.." alias gi="grep -i" alias l="ls -al" alias lm="ls -al | more" alias lf="ls -FG" alias h=history alias hm="history | more" # places alias bin="cd /Users/al/tomcat/bin" alias html="cd /home/apache/html" # file finding alias ff="find . -type f -name " # "que pasa" (an old friend said this a lot) alias qp="ps auxwww | more" # ssh: i modified this one for public consumption alias fb="ssh email@example.com" # for dos users alias dir="ls -al" alias md=mkdir alias ren=mv alias type=cat alias search=grep
Hopefully most of those aliases are very straightforward. Note that any time you have spaces in your commands (to the right of the equal sign) you'll need to put quotes around your commands.
Using Linux aliases
Once you've configured your aliases you can use them just like a normal Linux command, like this:
The system responds by replacing your alias with the actual command(s) the alias represents:
The weirdest alias I've shown may be
ff, which I use like this:
which expands to this:
find . -type f -name some_file
If you know the Linux find command, you know that this will search in the current directory and all subdirectories for a file named some_file.
Storing your aliases
If you create an alias from the command line it will last only as long as your login session lasts. When you log out, then back in again, your alias will be gone. To make your aliases available for future login sessions, store them in your .bash_profile or .profile files, which are read by the bash shell when a login session is started.