Aliases are shortcuts. They are simple keystrokes commands. Aliases avoid the need to type complex commands and their options. Aliases are easy to create. An alias is rarely more than one line of code. It is typical to store an alias in the hidden .bashrc file. In contrast, aliases can be stored in a dedicated file that is sourced by .bashrc. The .bashrc file is run when the computer is booted. As a result, the aliases are sourced and are placed into memory for immediate use. Examples are listed below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
alias # list all alias commands in terminal unalias <alias> # disable an alias alias dir='dir --color=auto' # list directories with auto color alias vdir='vdir --color=auto' # list directories with auto color alias grep='grep --color=auto' # search file; print lines matching a pattern alias fgrep='fgrep --color=auto' # search file; print lines matching a pattern alias egrep='egrep --color=auto' # search file; print lines matching a pattern alias lll='ls -l --color=auto' # long list format alias lla='ls -la --color=auto' # long list format, all (includes hidden) alias llt='ls -laFt --color=auto' # long list format, all, classify, time sort alias lls='ls -lahS --color=auto' # all, long list, human readable, size sort alias lld='ls -ld */ --color=auto' # directories only alias ..="cd .." # navigate up one directory alias ..2="cd ../.." # navigate up two directories alias ..3="cd ../../.." # navigate up three directories alias ..4="cd ../../../.." # navigate up four directories alias ..5="cd ../../../../.." # navigate up five directories alias path='echo -e ${PATH//:/\\n}' # list path members in rows alias cls="clear" # clear screen alias copy="cp -i" # copy with confirm prompt alias move="mv -i" # move with confirm prompt alias del="rm -i" # delete with confirm prompt alias h10="history 10" # show last 10 history elements alias h20="history 20" # show last 20 history elements alias h20="history 30" # show last 30 history elements alias screenoff="xrandr --output DP-4 --off" # shift video output to monitor; laptop off alias screenon="xrandr --output DP-4 --auto" # shift video back to laptop screen alias bat="gnome-power-statistics" # GUI for laptop, keyboard and mouse battery ##-----------------------------------------------------------------------------------------## |