Useful command-line aliases?

Does anyone have suggestions for useful entries in .bash_aliases (or wherever you keep yours)? Here’s what I’ve come up with so far:

> alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
> alias cd/='cd /'
> alias cd..='cd ..'
> alias cd...='cd ../../../'
> alias cd....='cd ../../../../'
> alias cd.....='cd ../../../../'
> alias ..='cd ..'
> alias ...='cd ../../../'
> alias ....='cd ../../../../'
> alias .....='cd ../../../../'
> alias cls='clear'
> alias dir='ls'
> alias l='ls -CF'
> alias la='ls -A'
> alias ll='ls -alF'
> alias ls='ls --color=auto'
> alias h='history'
> alias ff='find . -name $1'
> alias now='date +"%T"'
> alias nowdate='date +"%d-%m-%Y"'
> alias nowtime='now'
> alias path='echo -e ${PATH//:/\\n}'
> alias edit='nano'
> alias pico='nano'
> alias notepad='pluma'
> alias gedit='pluma'
> alias grep='grep --colour=auto'
> alias egrep='egrep --color=auto'
> alias fgrep='fgrep --color=auto'
> alias explorer='caja'
> alias nautilus='caja'
> alias header='curl -I'
> alias wget='wget -c'
> alias root='sudo -i'
> alias su='sudo -i'
> alias apt-get='sudo apt-get'
> alias apt-install='sudo apt-get install'
> alias install='apt-get install'
> alias apt-remove='sudo apt-get remove'
> alias apt-update='apt-get update && apt-get upgrade'
> alias update='apt-get update && apt-get upgrade'
> alias poweroff='sudo shutdown -h now'
> alias restart='sudo shutdown -r now'
> alias j='jobs -l'
> alias cpuinfo='lscpu'
> alias gpumeminfo='grep -i --color memory /var/log/Xorg.0.log'
> alias meminfo='free -m -l -t'
> alias pscpu='ps auxf | sort -nr -k 3'
> alias pscpu10='ps auxf | sort -nr -k 3 | head -10'
> alias psmem='ps auxf | sort -nr -k 4'
> alias psmem10='ps auxf | sort -nr -k 4 | head -10'
> alias monitoroff='xset dpms force off'
> alias playdir='vlc * &'
> alias chrome=google-chrome
> alias editalias='gedit ~/.bash_aliases'
2 Likes

I alias o to xdg-open. (As a longtime Mac user, I also alias open to the same.)

Similarly I alias e to my text editor – lately Geany.

Also, you can now use the apt command for most of the apt-* commands, e.g. apt install.

2 Likes

A few new ones for you here maybe?:

1 Like

Some of my aliases…

Those who like talking computers…

alias say='espeak'

say "Hello world!"

Generate a random strong password

genpwd(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo; }

Find text in a directory

lookfor() {
  echo "grep -r \"$1\" ./"
  grep -r "$1" ./
}

lookfor "foo"

Fix the resolution (if that ever happens)

alias fixres="xrandr -s 1920x1080"
4 Likes

@lah7, your lookfor function can be rewritten as an alias with some benefits:

alias lookfor=“fgrep -rni”

Cheers

4 Likes

Could another term for what this thread is talking about be shortcuts?

Indeed.
And while I’m at it, here’s another awesome one:

alias e=“xdg-open”

Edit: damn @elcste above already had it. Probably where I got the idea from too, I’m getting old.

You shouldn’t alias those…

which shutdown poweroff restart

/sbin/shutdown
/sbin/poweroff
/sbin/restart

I use alias m=‘free -h’

1 Like