In unix/linux navigating through a long folder path repetitively is bit painful task and takes a bit time when you have large number of severs to manage and perform administration task.
In such situation creating folder path alias is the best way to create abbreviated shortcuts and change folder path quickly without navigating through whole path.
In this very simple article instruction will be given how to create folder alias for a particular folder path and change directory easily without navigating to whole path.
Below are the steps required to create folder alias-
1) List out the long folders path which you need to navigate frequently
2) Write down the abbreviated name for each long folder path
3) Update .bashrc and .profile file
4) Load the .profile file for particular os user.
5) Use the abbreviated value to cd to that long folder path
Step 1:
For example purpose, I have listed out below long most used folders path for implementation –
/u01/app/oracle/admin/domains/aserver/prd_domain
/u01/app/oracle/admin/domains/mserver/prd_domain
/u01/app/oracle/product/fmw
/u01/app/oracle/admin/domains/cluster
/u01/app/oracle/admin/domains/aserver/domain/servers/AdminServer/logs
/u01/app/oracle/admin/mserver/domains/servers
/u01/app/oracle/admin/cluster/logs
Step 2:
Abbreviated value Long folder path
Abbreviated
value
|
Long folder
path
|
aserver
|
/u01/app/oracle/admin/domains/aserver/prd_domain
|
mserver
|
/u01/app/oracle/admin/domains/mserver/prd_domain
|
fmw
|
/u01/app/oracle/product/fmw
|
cluster
|
/u01/app/oracle/admin/domains/cluster
|
alog
|
/u01/app/oracle/admin/domains/aserver/domain/servers/AdminServer/logs
|
mlogs
|
/u01/app/oracle/admin/mserver/domains/servers
|
logs
|
/u01/app/oracle/admin/cluster/logs
|
Step 3:
Folder alias can be updated either directly in .profile or .bashrc file for a particular os user. The test environment where I have implemented this I have created folder alias inside .bashrc file located inside particular os user home folder.
So, e.g. sample os user name is ‘oracle’ the .bashrc file must exist at this location /home/oracle/. If .bashrc file does not exist then admin can create this file as well using vi editor.
Add below entries into .bashrc file
alias aserver='cd ~/../../u01/app/oracle/admin/domains/aserver/prd_domain
alias mserver='cd ~/../../u01/app/oracle/admin/domains/mserver/prd_domain
alias fmw='cd ~/../../u01/app/oracle/product/fmw
alias cluster='cd ~/../../u01/app/oracle/admin/domains/cluster
alias alog='cd ~/../../u01/app/oracle/admin/domains/aserver/domain/servers/AdminServer/logs
alias mlogs='cd ~/../../u01/app/oracle/admin/mserver/domains/servers
alias logs='cd ~/../../u01/app/oracle/admin/cluster/logs
Step 4:
Now, update .profile file for same user to load .bashrc file
e.g.
source ~/.bashrc
Step 5:
Now load the .profile file for ‘oracle’ user.
Use putty to login using oracle user, after successful login, it will land ‘oracle’ user home directory, run below command
source ~/.profile
Once you run the above command, oracle user profile will be loaded which will set all the folders path alias.
Now, we can use the abbreviated value to access particular folder.
e.g. to access this path ‘/u01/app/oracle/product/fmw’ just type this abbreviated value ‘fmw’ as per below snap.
No comments:
Post a Comment