As you begin using Unix and start moving around in directories and files, you’re likely to get a bit lost—that is, forget which directory or subdirectory you’re in. You can use the pwd command to get a reminder of where you are, as shown in Code Listing 1.5.
[jdoe@frazz jdoe]$ pwd /home/jdoe [jdoe@frazz jdoe]$ ls ; pwd codelisting1.2 codelisting1.4 mail/ → public_html/ testlink@ codelisting1.3 limerick Project/ testfile → tmp/ /home/jdoe [jdoe@frazz jdoe]$ cd [jdoe@frazz jdoe]$ cd / [jdoe@frazz /]$ pwd / [jdoe@frazz /]$ |
You can request just the directory name, or you can get fancy and request the directory’s name and its contents, courtesy of ls.
pwd
This command displays the path and name of the directory you are currently in. The path names each of the directories “above” the current directory, giving you the full picture of where you are in relationship to the system root.
ls ; pwd
By combining the ls and pwd commands, you can request the directory’s contents and name, as shown in Code Listing 1.5.
✓ Tips
Type in pwd immediately after you log in. You’ll see where your home directory is in the overall system (aka the full path name for your home directory).
On some Unix systems, you won’t need to use pwd to find out where you are. Some systems display the current directory at the shell prompt by default—something like /home/ejr>. If you’d like to add or get rid of this, or if you want more information about shells and customizing your shell, see Chapter 8, Configuring Your Unix Environment.
18.218.55.14