Tuesday, September 3, 2013

Create Useful and handy commands with alias


Linux Alias
An alias is command line shortcuts. creating alias means that you will spend less time on typing the complex commands, you can create alias in linux that give meaningful names to obscure commands,

Viewing your aliases
Bash is often configured with a few predefined aliases, To view the alias in your shell, just type alias and press enter,
$ alias
alias l.=’ls -d .* --color=tty’
alias ll=’ls -l --color=tty’
alias ls=’ls --color=tty’
Some useful alias as your useful handy commands like,
alias up=”cd ..”
alias unpack=”tar -zxvf “
alias netcon=”netstat -p | grep -v’^unix’”
The find command is a great candidate for an alias or two because it’s such a complex command
alias f=’find . -name’
alias fi=’find . -iname’
After defining these aliases, you can search for a file (by name) like this:
$ f myfile.sh
./tmp/myfile.sh
to search for a filename without regard to letter case:
$ fi myfile.sh
./tmp/myfile.sh
./work/MyFile.sh
The gf alias combines find and grep to search for specific text in all the files in a directory tree. You can use the alias like this:
$ gf Martini
./recipes/igyan_tutes.txt:200: the perfect
Martini
./blog/surficle.html:22: I prefer my
Martinis shaken, not stirred

To save your aliases, use your favorite editor to
add them to the ~/.bashrc file. This way, each time you log in, your aliases are there when you need them. To add system-wide aliases,

No comments: