Basics: Use of alias at OS level in SAP

AliasOS command
cdAS‘cd /usr/sap/$SAPSYSTEMNAME/ASCS[0-9][0-9]’
cdD‘cd /usr/sap/$SAPSYSTEMNAME/DVEBM*[0-9][0-9]’
cdDi‘cd /usr/sap/$SAPSYSTEMNAME/D[0-9][0-9]’
cdexe‘cd $_DEF_EXE2’
cdG‘cd /usr/sap/$SAPSYSTEMNAME/G[0-9][0-9]’
cdglo‘cd /usr/sap/$SAPSYSTEMNAME/SYS/global’
cdJ‘cd /usr/sap/$SAPSYSTEMNAME/J[0-9][0-9]’
cdJC‘cd /usr/sap/$SAPSYSTEMNAME/JC[0-9][0-9]’
cdpro‘cd /usr/sap/$SAPSYSTEMNAME/SYS/profile’
cdput‘cd /usr/sap/$SAPSYSTEMNAME/put’
cdS‘cd /usr/sap/$SAPSYSTEMNAME/SCS[0-9][0-9]’
cdT‘cd /usr/sap/$SAPSYSTEMNAME/TRX[0-9][0-9]’
dir‘ls -l’
h‘history’
hostname‘hostname -s’
l‘ls -abxCF’
pdpushd
poppopd
Pwd‘/bin/pwd’
Surlogin `hostname` -l

These aliases are case sensitive, and if there will be more than one directory at the destination satisfying the regular expression [0-9][0-9]

For example if we have D00 and D10 then the command cdDi will not yield a result.

Similarly  below are the aliases provide by SAP for HANA server

AliasOS Command
cdexe‘cd /usr/sap/$SAPSYSTEMNAME/SYS/exe/run’
cdglo‘cd /usr/sap/$SAPSYSTEMNAME/SYS/global’
cdhdb‘cd /usr/sap/$SAPSYSTEMNAME/HDB[0-9][0-9]’
cdins‘cd /usr/sap/$SAPSYSTEMNAME/SYS/global/hdb/install’
cdpro‘cd /usr/sap/$SAPSYSTEMNAME/SYS/profile’
cdpy‘cd /usr/sap/$SAPSYSTEMNAME/HDB[0-9][0-9]/exe/python_support’
dir‘ls -l’
h‘history’
l‘ls -abxCF’
pdpushd
poppopd
Pwd‘/bin/pwd’
Surlogin `hostname` -l

If we want to know where these alias has been defined, go to home directory of <sid>adm user.

Execute this $> grep alias .*

You’ll see that approximately 4 hidden environment files are there in which these aliases are defined.

.sapenv.sh

.sapenv.csh

.sapenv_<hostname>.sh

.sapenv_<hostname>.csh

.sapenv.csh.sapenv.sh
alias cdexe ‘cd $_DEF_EXE2’alias cdpro ‘cd /usr/sap/$SAPSYSTEMNAME/SYS/profile’alias cdglo ‘cd /usr/sap/$SAPSYSTEMNAME/SYS/global’alias cdexe=’cd $_DEF_EXE2′alias cdpro=’cd /usr/sap/$SAPSYSTEMNAME/SYS/profile’alias cdglo=’cd /usr/sap/$SAPSYSTEMNAME/SYS/global’

What is the difference between .csh and .sh file?

It depends on what your <sid>adm user uses are shell.

you can execute below command to know:

grep <sid>adm /etc/passwd

example

$> grep q1sadm /etc/passwd

q1sadm:x:437840:5922::/home/q1sadm:/bin/csh

This means that files with .csh will be used.

If I need to add my own aliases, In above scenario I will edit file .sapenv_<hostname>.csh

for dialog instance

alias cdW ‘cd /usr/sap/$SAPSYSTEMNAME/D[0-9][0-9]/work’

for Primary application instance

alias cdW ‘cd /usr/sap/$SAPSYSTEMNAME/DVEBM*[0-9][0-9]/work’

With this done, we need to log-out and log back in with <sid>adm, and execute cdW and it will take us directly to the work directory.

We can also add customer specific paths which are most commonly used to store backup files or installation files etc.

source:https://blogs.sap.com/2015/07/27/use-of-alias-at-os-level-in-sap/

Leave a comment