• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

come back to the own directory that just past in linux

/var/www/vhosts/huatanon.com/httpdocs/joomecos/components/com_virtuemart/shop_image/product/

I stay in the direc tory above then i go to   cd /home

How can i come back to  /var/www/vhosts/huatanon.com/httpdocs/joomecos/components/com_virtuemart/shop_image/product/


I can not use arrow up and down be cause I goto cd/var then d www then cd vhosts  
0
teera
Asked:
teera
4 Solutions
 
ghostdog74Commented:
you can always set the path as a variable, and use it in your shell session

eg

# longpath="/var/www/vhosts/huatanon.com/httpdocs/joomecos/components/com_virtuemart/shop_image/product/"
# cd /home
# ls
# cd $longpath
0
 
omarfaridCommented:
Hi,

One way of doing it is as recommended by ghostdog74, by setting env variable then using it whenever you want.

Another way is to use pushd / popd commands. For more info, please see:

http://www.iti.cs.tu-bs.de/cgi-bin/UNIXhelp/man-cgi?pushd+1

0
 
Gabriel OrozcoSolution ArchitectCommented:
put these functions on your ~/.bashrc so they are in your environment when you open the terminal:

function dmark {
DMARK=$(PWD)
}

function djump {
cd $DMARK
}

now you can go to /var/www/vhosts/huatanon.com/httpdocs/joomecos/components/com_virtuemart/shop_image/product/
and execute:
dmark
#change to home
cd ~
# see? you are in home now:
pwd
# change even to root directory
cd /
# now get back to the beginning:
djump
# see? you are just where you dmark-ed the directory


you can name these two commands as you please. you can also add more functionality like push and pop multiple times, but this is the answer to what you asked.

regards!
pwd
0
 
TintinCommented:
It's also useful to know that

cd -

Will cd you to the last directory you were in, which in this instance won't help you directly, but it still useful to know.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now