How to save time in terminal with Bash Aliases

Many people say you shouldn’t need to use the terminal to get things done in linux , but personally I couldn’t do without it , and believe its an integeral part of linux and can be very useful. The problem is , that for many new users to linux find it daunting or even irritating to have to use a prompt and typing out long commands. This is where bash aliases come in handy. A bash alias is a simply just using another name for a command. This can be useful so instead of typing out a command like sudo apt-get install packageX it can be shortened to giveme packageX. To Accomplish this open your /home/username/.bashrc , if this file doesnt exist you can create it. Either add to the bottom if text is already there , and if it doesnt we can start adding bash aliases, some examples for debian/ubuntu based systems are

alias giveme=’sudo apt-get install’
alias purge=’sudo apt-get –purge remove && sudo apt-get autoremove’
alias show=’apt-cache show’
alias update=’sudo apt-get update && sudo apt-get install -f && sudo apt-get dist-upgrade’
alias cls=’clear’
alias l=’ls -a’
alias load=”sudo mount -a”
alias lspart=’sudo fdisk -l && sudo blkid’

Since .bashrc can be used for more than bash aliases , ie bash completion and enviroment variables. Personally i use .bash_profile to setup the terminal colours etc, .bash_aliases for my aliases, .bashrc for everything else. Pretty much anything that goes it the .bashrc file can be moved to another file if it makes things easier just make sure that in your .bashrc you have
if [ -f ~/.filename ]; then
. ~/.filename
fi
To start using the new aliases all you have to do is in terminal source .bashrc or .filename

Advertisements
Tagged with:
Posted in 01Ben, Linux
2 comments on “How to save time in terminal with Bash Aliases
  1. […] Also you could setup bash aliases for your ssh, x11vnc and exporting the display. I wrote a quick guide http://sneekygeekers.com/2012/08/26/how-to-save-time-in-terminal-with-bash-aliases/ […]

  2. […] the command line as it becomes more efficient to get the job done. I have previously discussed how to save time in terminal with bash aliases. However today I would like to show you a few useful tools that can make life […]

Please feel free to leave a reply.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 68 other followers

%d bloggers like this: