Linux and UNIX bash shell aliases

shell
Hi

Commonly used for a long strings that are frequently used. Alias allows you to have a small more familiar command or name to execute a long string.

Set an alias
Syntax
alias [name[='command']

nameSpecifies the alias name.
commandSpecifies the command the name should be an alias for.
-aRemoves all alias definitions from the current shell execution environment.
-tSets and lists tracked aliases.
-xSets or prints exported aliases. An exported alias is defined for scripts invoked by name.
-pPrints the list of aliases.

Examples
alias command with no arguments or with the -p option prints the list of aliases:

$ alias
alias ff='firefox'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -l'
alias ls='ls --color=auto'
alias sx='startx'

Sets clr to type clear

$ alias clr='clear'

Remove an alias
Syntax
unalias [name]

nameSpecifies the alias name.
-aRemoves all alias definitions

Clear all Linux / UNIX bash shell aliases

$ unalias -a

Note
When the computer is rebooted all alias will be lost.

How to prevent it?
All alias must be added to .bashrc file located at your user folder (example: /home/saeid/.bashrc)

Example

$ gedit /home/saeid/.bashrc

paste:

alias clr='clear'

now you have to ‘compile’ your .bashrc file

$ source .bashrc

Now clr alias it’s saved.

Good luck

No related posts.

Saeid Zebardast

facebook twitter linkedin Email

I'm Senior software engineer with 5+ years of professional experience includes cross-platform proficiency with considerable knowledge of programming languages especially Java and programming paradigms such as OO and development methodologies. Also I'm MySQL DBA since 2006.


Trackbacks Comments
    Leave a Comment