Terminal - how to navigate to a directory

By default if I open Terminal, I get the prompt from my user directory.


How do I navigate up the hierarchy to the main Applications folder?


I thought it should just be, eg


cd ../Applications/MAMP/htdocs


But that doesn't seem to work.


Any pointers on this much appreciated.


Thanks.

Posted on Dec 1, 2013 6:34 AM

Reply
7 replies

Dec 1, 2013 8:12 AM in response to Iain MacDonald1

Iain MacDonald1 wrote:



How do I navigate up the hierarchy to the main Applications folder?


I thought it should just be, eg


cd ../Applications/MAMP/htdocs


But that doesn't seem to work.


As Tony T1 indicates, the double dot .. is parent.


Your command would have worked if you had cd'd to /Users or any other directory just below the root / directory.


Beyond .. and /, the single dot . is the current directory, and ~ is your login directory. You'll often see the single dot when invoking an application that isn't in your PATH; something like ./foo will invoke foo in your current directory, where you'd otherwise get what was in your PATH. Issuing a cd with no parameter will also take you to your home directory, too. You can see the . and .. directory files "hidden" in each of the directories with commands such as the ls -al command, too.


To learn more about this stuff, Apple has various write-ups for developers including their File System Basics (which describes which files and directories live where, and why), and also has Shell Scripting Basics and Command Line Administration available.


As you get going here, you'll probably also want to set your prompt string (I tend to set the prompt on the production servers to red and then experimenting with your login scripts, and you'll find that in additon to setting your PATH in one of your login scripts. (There's a gonzo graphical write-up on Unix and Linix login scripts here.)


Welcome to Unix.

Dec 1, 2013 9:20 AM in response to MrHoffman

MrHoffman,


Another approach to those gnarly color escape sequences (from my .bashrc):


Bluebld="$(tput bold; tput setaf 63)"

Grn="$(tput setaf 34)"


export PS1='\[$Bluebld\]\h: \w$ \[$Grn\]'


alias clear='tput clear'


The above color choices come from using colortest.pl -w to wide print all colors to the terminal with their index and hex codes displayed.


For those using XQuartz 2.7.5, it will set the default text color for Xterm to the text color used in Terminal.app. White text in Terminal now becomes invisible text in Xterm unless one has appropriate Xdefaults XTerm overrides.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Terminal - how to navigate to a directory

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.