[SOLVED] Change directories without cd? (or a variant)
Linux - NewbieThis 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!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I am trying to change directories without using cd (or popd or any variant thereof).
I think the way to go is to just change the environment variable for pwd, but when I do export PWD=/, it immediately looks like I'm in the root (anon@comp: / 32$) but when I do pwd or ls, it shows I'm still in my home directory.
PWD is just an environment variable, it is updated when you traverse to a different directory. The reason your prompt changes is because it reads $PWD, but you haven't actually traversed anywhere and it will be reset when you do.
Does this count?
eval "cd /tmp"
I'm not aware of any other process but it wouldn't surprise me if there was ..
Ok it makes sense that it is only changing the environment variable. I figured it was something like that. Does anyone know of a way that I could directly alter the value that is stored for current working directory? Surely cd doesn't have a monopoly on it.
Originally Posted by NevemTeve
Why would you want to 'cd without cd'? Because you're in a restricted shell? Then you should realize that it is called restricted for a reason.
No nefarious deeds at work here, just trying to get a better understanding of how the shell operates.