Alias is some kind of shortcut in command lines, and it can be really productive if you can alias all the long commands that you use to manage your linux system.
Example:
To permanently set alias "d=dmesg | tail" for user "abu"
1. Append "alias d=dmesg | tail" to the /home/abu/.bashrc
$ echo "alias 'd=/bin/dmesg | /usr/bin/tail'" >> /home/abu/.bashrc
2. Activate the change
$ . /home/abu/.bashrc
3. Test the new alias
$ d
[drm] LVDS-8: set mode 16
[drm] LVDS-8: set mode 17
[drm] LVDS-8: set mode 18
[drm] LVDS-8: set mode 19
[drm] LVDS-8: set mode 1b
[drm] LVDS-8: set mode 1d
[drm] LVDS-8: set mode 1e
[drm] LVDS-8: set mode 1f
[drm] LVDS-8: set mode 20
[drm] LVDS-8: set mode 21
To temporarily set alias, just use the alias command at the terminal
$ alias d='dmesg | tail'
To remove alias. you can either delete it from ~/.bashrc or use unalias command
$ unalias d
Thursday, January 7, 2010
Using alias in bash
Labels:
bash
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment