LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-14-2009, 03:57 PM   #1
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Rep: Reputation: Disabled
Get back to original directory


Hi,

Sometimes I cd to a linked directory, and when I issue cd .., it takes me one level back, but not to the parent directory in which the link was there, but the true parent directory of the linked directory (I hope I could spell it clearly!).

How to get back to the parent directory (the one which has the link) from within the linked directory?

PS:
even cd - does not help

~hatim
 
Old 12-14-2009, 04:02 PM   #2
worm5252
Member
 
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX, OS X
Posts: 567

Rep: Reputation: 57
The easiest way is to always know where you are at. Another way is instead of doing 'ls' for find the directories, do 'ls -l' so you can find the links and see where they go. Then you can do an 'ls' on the link location. i.e. 'ls <linklocation>'
 
Old 12-14-2009, 04:03 PM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hello faizlo,

in bash the variable OLDPWD is the "old working directory". So
Code:
cd $OLDPWD
will bring you back to there.

Markus
 
Old 12-14-2009, 04:06 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
On my system, "cd -" and "cd .." both take me back to where I was. If I drill down, cd ../.. also takes me to the original starting point. So......maybe this means there is a config file somewhere???
 
Old 12-14-2009, 04:10 PM   #5
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hello together,

many Linuxdistributions come with the aliases
Code:
alias ..='cd ..' and
alias ...='cd ../..'
Markus

Last edited by markush; 12-14-2009 at 04:14 PM.
 
Old 12-14-2009, 04:12 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by markush View Post
Hello together,

many Linuxdistributions come with the aliases
Code:
alias ..='cd ..' and
alias ...='cd ../..'
.

Markus
If "cd .." does not work as desired, then how would this alias help?
 
Old 12-14-2009, 04:13 PM   #7
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
Thank you all for the quick response (which make feel guilty of not posting before )
Markush, your trick worked. I will create an alias "back, or orig" and insert it in my .bashrc file.

Thank you all again,

~faizlo
 
Old 12-14-2009, 04:16 PM   #8
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
cd $OLDPWD worked with bash, but not with tcsh
It say, OLDPWD: undefined variable.
Any hints!?

~faizlo
 
Old 12-14-2009, 04:23 PM   #9
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850Reputation: 850
Hi,

in tcsh "cd -" should work (refering to the manpage). I'd recommend to read the manpage and search for "working"
Code:
man tcsh
and in the manpage execute
Code:
/working
Markus
 
Old 12-14-2009, 05:50 PM   #10
faizlo
Member
 
Registered: Sep 2008
Location: USA
Distribution: Linux Mint Qiana
Posts: 190

Original Poster
Rep: Reputation: Disabled
On tcsh shells, the command is: cd $owd (small letters)

~faizlo
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
boot sequence reverts back to original links kardster Linux - Server 5 07-23-2008 08:25 PM
how to convert filename mojibake back into original encoding?? wordsmithy Linux - General 1 05-13-2008 03:13 AM
move files in tar.gz back to into original folders GUIPenguin Linux - General 1 05-09-2005 01:11 PM
weird hostname appeared, want the original back rksanders Debian 2 12-05-2004 06:53 PM
how to restore back the gnome original desktop Egyptian_Isis Linux - Newbie 2 10-31-2003 01:20 AM


All times are GMT -5. The time now is 02:48 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration