Tuesday, June 14, 2011

Productive Linux Aliases Initialized Following User Authentication

Sup Folks,

I wanted to take this opportunity to share some of my favorite Linux aliases used by many people in the community.  Some may believe that *nix aliases are the spawn del diablo...mostly because it's easy for aliases to get out of hand if typing descriptive, unique, and easy-to-remember aliases aren't your cup o' tea.

Aliases are really helpful if you find yourself typing long commands on a regular basis, kind of like this simple one-liner that displays the types of files located in the current working directory:


$ ls | while read f; do file $f; done

The small list of aliases found below certainly increase productivity because, well...less keys are required to be pressed on your happy hacker keyboard. 

Setting up aliases in the manner described below will have them initialized following user authentication into your favorite Linux distro (Some of the aliases below are specific to distros with apt available as the package manager):

1. Edit ~/.bashrc and add the following line at the very bottom of the file:


$ source /etc/profile.d/aliases.sh

Save your changes and exit.

2. Create /etc/profile.d/aliases.sh and add the following:

#!/bin/bash
alias acache="apt-cache search"
alias ainstall="apt-get install"
alias aremove="apt-get remove"
alias aupdate="apt-get update"
alias aupgrade="apt-get upgrade"
alias adupgrade="apt-get dist-upgrade"
alias cless="/usr/share/vim/vim72/macros/less.sh"
alias dadd="darcs add"
alias doupgrade="/usr/bin/do-release-upgrade -d"
alias dpull="darcs pull"
alias dpush="darcs push"
alias drecord="darcs record"
alias grep="grep --color=auto"
alias jgeminstall="jruby -S gem install"
alias kpid="kill -9"
alias kall="killall -9"
alias ls="ls --color=auto"
alias ll="ls -l --color=auto"
alias lh="ls -lh --color=auto"
alias netpain="netstat -pane | grep -e udp -e tcp | less"
alias prep="ps -ef | grep"
alias sup="sudo su -"
alias s_rhost="ssh <user>@<rhost>" # Replace <user> with remote ssh user and <rhost> with remote hostname of SSH server.  Replace the alias name with the same <rhost> hostname.

3. Setup executable permissions on /etc/profile.d/aliases.sh.  Not even sure this is necessary due to the way this file is executed from /etc/profile but I do it any way:

$ chmod 755 /etc/profile.d/aliases.sh


4. Log out and log back in...

That's it!

If you enjoyed this post, send us = kudos = 
(Bitcoin Addr: 19n6q3GZfoM64oqv5HsDnhzqvcEvJUvmdx)




For more info on UNIX and Linux system administration, check out this book:



If you have any other aliases that have personally helped you, feel free to post them as comments to help everyone else!

Lat3r sk4t3rz :p

No comments:

Post a Comment