Is there anything that you can't live without and will make my life SO much easier? Here are some that I use ('diskspace' & 'folders' are particularly handy).

# some more ls aliases
alias ll='ls -alh'
alias la='ls -A'
alias l='ls -CFlh'
alias woo='fortune'
alias lsd="ls -alF | grep /$"

# This is GOLD for finding out what is taking so much space on your drives!
alias diskspace="du -S | sort -n -r |more"

# Command line mplayer movie watching for the win.
alias mp="mplayer -fs"

# Show me the size (sorted) of only the folders in this directory
alias folders="find . -maxdepth 1 -type d -print | xargs du -sk | sort -rn"

# This will keep you sane when you're about to smash the keyboard again.
alias frak="fortune"

# This is where you put your hand rolled scripts (remember to chmod them)

closed as not constructive by Rob Moir, EEAA, Scott Pack, HopelessN00b, mdpc Oct 31 '12 at 16:50

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

locked by HopelessN00b Dec 3 '14 at 1:31

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

Read more about locked posts here.

  • 3
    This should be community wiki – Toro May 6 '09 at 14:53
  • 1
    Turned into community wiki. Enjoy. – Gareth May 6 '09 at 22:50
  • 4
    piped to more? I bet you'd be happier with less or less -F – derobert May 7 '09 at 16:28
  • Except that there is that "sort" before the more, since sort needs the full input, the less -F would just let you see the sorting faster, and I bet it's pretty dang fast. – GreenKiwi May 26 '09 at 13:56
  • 1
    Just in case anyone is interested, there is a service that allows you to browse, build a list and source your aliases: alias.sh – Sam152 Apr 22 '13 at 0:13

39 Answers 39

IP_ADDRESS_BASH=`ip addr | grep -w inet | gawk '{if (NR==2) {$0=$2; gsub(/\//," "); print $1;}}'`
PS1="\h $IP_ADDRESS_BASH \w % "

And then it displays IP of your machine that you just logged to.

# vi ~/.bashrc # red/green terminal colors regarding exit code
if [[ \$? = "0" ]];
then echo "\\[\\033[0;32m\\]";
else echo "\\[\\033[0;31m\\]";
fi`[\u@\h \w]\[\e[m\] "'
export PS1
  • Will this alter the $? variable after running the command or does it still have the value produced by the last command run? – Andrew Case Jun 28 '12 at 5:00
mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }

ecb () { emacsclient -n -a emacs $@ & } # open in emacsclient in the background
ecp () { emacsclient -n $(which $@) & } # open a given file found in a $PATH in emacsclient
ecr () { SUDO_EDITOR="emacsclient -a emacs" sudoedit $@; } # start emacsclient or emacs and open the file as root

eCf () { emacs --batch --eval "(byte-compile-file \"$@\")"; } # byte-compile file
eCa () { emacs --batch --eval "(batch-byte-compile-if-not-done)" *.el; } # byte-compile all el files in the current directory and it's children

I sometimes have to use a Solaris system at work.

However the system is centrally managed via Puppet, including the password file (which includes the shell setting).

My .bashrc therefore reads something like:

exec /bin/tcsh



. $HOME/bin/git-prompt/git-prompt.sh


A few aliases I use to take the edge off of the daily CLI grind...

# I find myself doing this a lot
alias hg='history | grep '

# Likewise this, plus I'm always mistyping it...
alias findy='find . -name'

# sometimes you're just not sure you want to delete something...
alias trash='mv -t ~/.local/share/Trash/files --backup=t'

alias vb='vim ~/.bashrc'

# I find typing 'cd ..' less than optimal
alias up='cd ..'
alias 2up='cd ../../'
alias 3up='cd ../../../'
alias 4up='cd ../../../../'

# re-map caps lock key to be Ctrl
# (works on Linux, at least)
xmodmap -e "remove lock = Caps_Lock"
xmodmap -e "add control = Caps_Lock"

# helpful history settings:
export HISTCONTROL=ignoredups
export HISTCONTROL=ignoreboth
export HISTIGNORE=ls:ll:la:l:cd:pwd:exit:mc:su:df:clear:cls
  • You could make 1up print a mushroom in ASCII art, just for kicks ;) – David Z Jun 30 '09 at 19:00
  • While almost all of the answers refer to tweaking history, I haven't seen any which enable timestamping which can be useful. export HISTTIMEFORMAT='%F %T ' – cclark Aug 1 '12 at 17:45

To fix window size in GNU screen after resize:

shopt -s checkwinsize

To show the permissions on a directory, shortcut ls -ld:

alias lld='ls -ld'

History viewing:

alias h='history | zgrep'

And contents of my zgrep script, which I couldn't figure out how to cram directly into the alias:

grep "${*-.}"

I'm addicted to screen, and I use the following shortcuts for SSHing to machines. With this script, I type p hostname to SSH to a host and run screen, or o hostname to do the same but run screen on the local machine.

First a script that connects to an SSH server of the same name as the script you're running. I call this simple_ssh:

BASENAME=$(basename $0)

if [ "$SCREEN" = "1" ]; then
    export SCREEN=0
    exec screen -RD scr$BASENAME -s $0
elif [ "$SCREEN" = "2" ]; then
    exec ssh $BASENAME "$@" -t 'screen -RD'

exec ssh $BASENAME "$@"

Symlink this to mars in your path and mars becomes a shortcut for ssh mars:

adam@pluto:bin$ ln -s simple_ssh mars
adam@pluto:bin$ mars

The $SCREEN environment variable lets you automatically execute GNU screen with the connection. SCREEN=1 runs screen locally (say, if screen is not installed on the host) and SCREEN=2 runs it on the host itself.

Use a couple aliases to shortcut this:

alias o='SCREEN=1 exec'
alias p='SCREEN=2 exec'

Use a script to create symlinks for all your hosts given an ~/.ssh/config file like this:

Host mars
    HostName mars.example.com
    User abackstrom

The script, sshconfig2simplessh:


BASENAME=$(basename "$0")
USAGE="Usage: $BASENAME /path/to/bin"

if [ -z "$1" ] ; then
    echo $USAGE
    exit 0

if [ ! -d "$1" ] ; then
    echo "$1 is not a directory" >&2
    exit 1

cd "$1"

HOSTS=$(grep '^Host ' < ~/.ssh/config | cut -d' ' -f2)

for HOST in $HOSTS ; do
    if [ ! -e "$HOST" ]; then
        echo ln -s simple_ssh "$HOST"
        ln -s simple_ssh "$HOST"


alias install=sudo yum install


alias install=sudo apt-get update && sudo apt-get install

Not the answer you're looking for? Browse other questions tagged or ask your own question.