Mac Os X 10.4 Tiger (Visual Quickstart Guides)
Up to now, you haven't moved around in the directory tree. You've been fixed in place in your home directory. Changing directories is easyjust use the cd (change directory) command, followed by the destination you want to move to. You have two ways to indicate a destination: with an absolute path or a relative path.
Let's look at an example. Suppose I'm currently in my home directory (/Users/ronh) and I want to move to the /usr/bin directory. I could specify the destination with its absolute path: /usr/bin. Or I could use the relative path to go up two directories to the root and then down two directories to the one I want. This is where the special "double-dot" (..) directory name that I discussed earlier comes into play; it indicates the directory above the current one. So the relative path from my home directory to /usr/bin would be ../../usr/bin.
To change directories using an absolute path
Type cd followed by the absolute path to the directory you want (for example, cd /usr/bin) and press The current directory changes and the path to the directory appears in the shell prompt (Figure 11). Figure 11. Here's how you can change the current directory to /usr/bin using an absolute path…
To change directories using a relative path
Type cd followed by the relative path to the directory you want (for example, from your home directory, type cd ../../usr/bin) and press The current directory changes and the path to the directory appears in the shell prompt (Figure 12). Figure 12. …or a relative path from your home directory.
To move to a subdirectory using an absolute path
Type cd followed by the absolute path to the subdirectory (for example, cd /Users/ronh/Sites) and press The current directory changes and the path to the directory appears in the shell prompt (Figure 13). Figure 13. Here's how you can move to a subdirectory using an absolute path…
To move to a subdirectory using a relative path
Type cd followed by the relative path to the subdirectory (for example, from your home directory, type cd Sites) and press The current directory changes and the path to the directory appears in the shell prompt (Figure 14). Figure 14. …or with a relative reference.
To list the contents of the current directory
Type ls and press The contents of the directory appear in the Terminal window (Figure 16). Figure 16. Once you're in a directory, using the ls command by itself displays the contents of that directory.
To return to your home directory
Type cd (without any arguments) and press The current directory changes to your home directory and the tilde (~) character appears in the shell prompt.
|