Alias (Unix)
Posted by FatDBA on July 23, 2012
Alias:
The alias command allows you to make new shortcuts and synonyms for commonly used commands.
Alias settings resets every time you reboots or switch users in Unix. There are number of ways/methods to permanently save Alias in your machine. Below discussed is one of the most common way to fix alias settings to make them global and always available.
1. Edit your bash profile (If using Bash Shell) and add all alias you want to set.
[root@localhost /]# gedit /etc/bashrc
(Below are excerpts from a live bashrc profile from one of my machine)
# /etc/bashrc
# System wide functions and aliases
# Environment stuff goes in /etc/profile
alias base=’cd /u01/app/oracle’
alias c=’clear’
alias home=’cd /u01/app/oracle/product/10.2.0/db_1′
alias sql=’sqlplus / as sysdba’
alias sid=”echo $ORACLE_SID”
# By default, we want this to get set.
# Even for non-interactive, non-login shells.
2. Add source /etc/bashrc to your ~/.bashrc profile.
[root@localhost /]# gedit ~/.bashrc
Will look like —
# .bashrc
# User specific aliases and functions
alias rm=’rm -i’
alias cp=’cp -i’
alias mv=’mv -i’
source /etc/bashrc
# Source global definitions
Enjoy The Shortcuts using ‘alias’ — Below is one of alias used to reach directory – ORACLE_BASE using alias named ‘base’.
[root@localhost ~]# base
[root@localhost oracle]# pwd
/u01/app/oracle
[root@localhost oracle]#
Nadine Haven said
GREAT publish and impressive in turn …will bear a try all the tips..Thanks……