LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 02: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, 03: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, 03:03 PM   #3
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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, 03:06 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 03:10 PM   #5
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
Hello together,

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

Last edited by markush; 12-14-2009 at 03:14 PM.
 
Old 12-14-2009, 03:12 PM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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, 03: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, 03: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, 03:23 PM   #9
markush
Senior Member
 
Registered: Apr 2007
Location: Germany
Distribution: Slackware
Posts: 3,979

Rep: Reputation: Disabled
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, 04: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



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 07:25 PM
how to convert filename mojibake back into original encoding?? wordsmithy Linux - General 1 05-13-2008 02:13 AM
move files in tar.gz back to into original folders GUIPenguin Linux - General 1 05-09-2005 12:11 PM
weird hostname appeared, want the original back rksanders Debian 2 12-05-2004 05:53 PM
how to restore back the gnome original desktop Egyptian_Isis Linux - Newbie 2 10-31-2003 12:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:47 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
Open Source Consulting | Domain Registration