Speed up your Bash sessions with “alias”

Some of you probably already know about this, but I just discovered it and wanted to share.

Tired of typing in the same terminal commands all the time? Try this:

alias cy='ssh -Y jdh33@cyberstar.psu.edu'

Now when you type “cy” in the terminal, it automatically replaces it with the command you specify in quotes.

You can do this for each session, but even more helpful is to put these alias commands in your .bashrc file so that they are run whenever you start bash (the “rc” in “bashrc” stands for “run commands” … at least I think it does). If you’re using cygwin, this file will be located at C:\cygwin\home\(your username)\.bashrc. Open it in a text editor and put your alias commands somewhere in the middle. (On the cluster, your .bashrc file is located in your home directory, ~.)

Some useful possibilities:

  • On your computer, create aliases to log into different clusters (“cy” for cyberstar, “lx” for Lion-XO, etc.)
  • On the cluster, create aliases for common queue operations (“qme” for “qstat -u jdh33”, for example, which is a good idea I got from Ryan. Or “killall” for “qdel $(qselect -u jdh33)”. Pretty handy!)
  • Any long commands you find yourself repeating can be aliased! Just be careful not to overwrite any existing Linux commands when you do it.
You can check your current aliases at any time by running alias without any arguments.

That’s all, thanks for reading.

Advertisements

One thought on “Speed up your Bash sessions with “alias”

  1. You can copy these aliases into your .bash_profile to access the PSU Cluster resources:

    alias assist=’ssh -Y userid@assist.aset.psu.edu
    alias cyberstar=’ssh -Y userid@cyberstar.psu.edu
    alias xf=’ssh -Y userid@lionxf.rcc.psu.edu
    alias xb=’ssh -Y userid@lionxb.aset.psu.edu
    alias xc=’ssh -Y userid@lionxc.aset.psu.edu
    alias xh=’ssh -Y userid@lionxh.rcc.psu.edu
    alias xi=’ssh -Y userid@lionxi.rcc.psu.edu
    alias xj=’ssh -Y userid@lionxj.rcc.psu.edu
    alias xk=’ssh -Y userid@lionxk.rcc.psu.edu
    alias xo=’ssh -Y userid@lionxo.aset.psu.edu
    alias hammer=’ssh -Y userid@hammer.rcc.psu.edu

    Just replace ‘userid’ with your user ID.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s