Finding Yourself with pwd


Finding Yourself with pwd

As you begin using Unix and start moving around in directories and files, you're likely to get a bit lostthat 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.

Code Listing 1.5. pwd displays the name of the current directory, which is particularly handy if you've been exploring the system. By combining commands, you can request the directory's name and contents at one time.

[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.

To Find Out The Name of The Current Directory:

  • 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.

To Find Out The Name of The Current Directory and Its Contents:

  • 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 defaultsomething 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.





Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net