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  
teeraAsked:
Who is Participating?
 
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
 
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
 
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.