|
12 years ago 19 |
The average linux users use the terminal commands for many tasks and some certain commands are very frequently used. For example, if you are a user of Ubuntu, you have to type " sudo apt-get install" every time you want to install a new package or the command "xset dpms force off" to turn off the desktop/laptop monitor. To save time, you can create shortcuts for these commands by adding aliases into the bash configuration file (~/.bashrc or /etc/bash.bashrc). The syntax to use aliases is:
For example:
After adding these lines into the bash configuration file and log out and log in again, you can use the new aliases. For example, to install new packages, you can use the following command after you used the above aliases:
In Ubuntu ~/.bashrc checks if ~/.bash_aliases file exists, so it's nice to add aliases to ~/.bash_aliases instead. Or you can just add
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
You don't need to logout and login after changing the aliases, just do (can also use a dot (.) instead of "source", as "." is an alias for "source"):
source ~/.bashrc
one command! makes things so simple! great....
Some suggestions for frequently used commands:
alias cd..='cd ..'
alias cp='cp -i'
alias d='ls'
alias df='df -h -x supermount'
alias du='du -h'
alias egrep='egrep --color'
alias fgrep='fgrep --color'
alias grep='grep --color'
alias l='ls'
alias la='ls -a'
alias ll='ls -l'
alias ls='ls -F --color=auto'
alias lsd='ls -d */'
alias md='mkdir'
alias mv='mv -i'
alias p='cd -'
alias rd='rmdir'
alias rm='rm -i'
Very good, simple and to the point.
Thanks, a newbie.