Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
PATH="$HOME/bin:$PATH"
share|improve this question

closed as not constructive by RobM, 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.

3  
This should be community wiki –  Toro May 6 '09 at 14:53
1  
Turned into community wiki. Enjoy. –  gyaresu 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
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
show 5 more comments

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.

share|improve this answer
add comment
# vi ~/.bashrc # red/green terminal colors regarding exit code
export PROMPT_COMMAND='PS1="`
if [[ \$? = "0" ]];
then echo "\\[\\033[0;32m\\]";
else echo "\\[\\033[0;31m\\]";
fi`[\u@\h \w]\[\e[m\] "'
export PS1
share|improve this answer
show 1 more comment
mkdircd () { mkdir -p "$@" && eval cd "\"\$$#\""; }

emb () { emacs $@ & }
ecb () { emacsclient -n $@ & }
esb () { emacs -f server-start $@ & }
share|improve this answer
add comment

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:

%!/bin/bash
exec /bin/tcsh

:)

share|improve this answer
add comment

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
share|improve this answer
show 2 more comments

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:

#!/bin/sh
grep "${*-.}"
share|improve this answer
add comment

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:

#!/bin/sh
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'
fi

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
adam@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:

#!/bin/sh

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

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

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

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"
	fi
done
share|improve this answer
add comment

Fedora

alias install=sudo yum install

Debian

alias install=sudo apt-get update && sudo apt-get install
share|improve this answer
add comment

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