Alias



If you're new here, you may want to subscribe to my RSS feed.

The alias command is very useful. It is kind of a shortcut in some ways. I get tired of tying ls -la so I can see all the info for my files so what i do is type alias ls 'ls -la'. What this command does is that it sets up an alias so that every time I type ls the computer treats is as though I typed ls -la. There are many other things you can do also. Say you have a long command you run a lot. You can alias it to something like mc.

Ex: alias mc 'locate log_error | grep -R 192.168.1.1 *'

Your command can be as long or as short that you want to alias. I also use it to setup ssh connections.

Ex: alias con1 'ssh usrname@192.168.1.1'

Now any time I type con1 it will try to make an ssh connection to that ip address.

2 Responses to “Alias”

  1. bt Says:

    tried this in terminal. didn’t work; received msg: “-bash: alias: ls: not found” and “-bash: alias: ls -la: not found”. did some hunting and found out that for the bash shell the command needs to be: “alias ls=’ls -la’”.

    by the way, thanks for the tips. glad to see this feed is still active.

  2. fk Says:

    alias isn’t working for me like that. I have to put a “=” between the two commands. Example: alias con1=’ssh usrname@192.168.1.1′
    Nice blog by the way.

Leave a Reply