music
OSdata.com: programming text book 

OSdata.com

pwd

summary

    This subchapter looks at pwd, a UNIX (and Linux) command.

    pwd is used to Print the Working Directory. It provides the full path for the current working directory. and is normally run without any options.

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

pwd

    This subchapter looks at pwd, a UNIX (and Linux) command.

    pwd stands for Print the Working Directory. It provides the full path for the current working directory. and is normally run without any options.

    pwd is a builtin command in bash. There is also an external utility with the same name and functionality.

working directory

    The working directory is whatever directory you happen to be working in. The working directory is always the same as the home directory when you start a shell session, but you can change your working directory at any time (and typically do change it). Commands normally are applied to the current working directory.

    The working directory may also be called the current directory, current working directory, or present working directory.

using pwd

    Type pwd from the command line, followed by ENTER or RETURN, and you will see the current working directory.

    $ pwd
    /Users/admin
    $

    There’s not much else to tell you about this command, but this is an important one because you will continually have the need to know where you are.

moving around

    We will go into more detail about these commands later, but for now you need to know how to move around in your file system.

    The ls command is used to list the contents of the current directory.

    Go ahead and type ls followed by ENTER or RETURN and you will see a list of the files and directories in your current working directory (which should still also be your home directory).

    The cd command is used to change directories.

    Go ahead and type cd directory-name followed by ENTER or RETURN and you will move to the new directory. You can confirm this by then typing pwd followed by ENTER or RETURN. You will see that you have successfully changed working directories.

    $ pwd
    /Users/admin
    $ ls
    Desktop     Movies      Send Registration
    Documents   Music       Sites
    Downloads   Pictures
    Library     Public
    $ cd Desktop
    $ pwd
    /Users/admin/Desktop
    $

    As you move around the directory tree, it is common to forget exactly where you are, especially if you do some other tasks (such as file editing). pwd provides an easy way to determine where you are and insure that your next actions are happening in the correct directory.

    Use cd command all by itself to return to your home directory.

    $ cd
    $ pwd
    /Users/admin
    $

advanced topic

    The remainder of this subchapter covers an advanced topic. I am placing this here so that you will be easily able to find them when you are ready for this information.

    Eventually you will make use of symlinks and symlinked directories. There will be times when you need toknow the actual physical path to the current working directory, not just the logical symlinked path.

options

    pwd is almost always used without options and never uses any arguments (such as file names). Anything other than legal options typed after pwd are ignored. Some shells ignore anything other than the legal options typed after pwd without reporting any errors, while most shells report errors for illegal options. All shells seem to ignore all arguments without reporting any errors.

    The two main options for pwd are -L and -P.

    The -L option displays the logical current working directory. This is the default if no options are listed.

    $ cd /symlink
    $ pwd -L
    /symlink
    $

    The -P option displays the physical current working directory, with all symbolic links resolved.

    $ pwd -P
    /Users/admin
    $

    You can use the results of the pwd -P switch to cd to the physical directory.

    $ cd /Users/admin
    $

    You can also use the -P switch directly on the cd command to change to the physical directory.

    $ cd -P /symlink
    $ pwd
    /Users/admin
    $

    You can use the help command to get information about pwd.

    $ help pwd

    Some early Linux shells allow the --help command to get information about pwd.

    $ pwd --help

    Some early Linux shells allow the --version option gives the version number for your copy of pwd.

    $ pwd --version

other

    On November 8, 2010, Ramesh Natarajan named this the number 13 most frequently used UNIX/Linux command at this web page 50 Most Frequently Used UNIX / Linux Commands (With Examples).

    In June 2009, Ken Milberg named this command as one of the Top 50 universal UNIX commands at this web page Top 50 Universal INIX commands. Note that this web page requires agreeing to be spammed before you can read it.


comments, suggestions, corrections, criticisms

please contact us

your name:
email address:
phone number:
message:

free music player coding example

    Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

    View music player in action: www.musicinpublic.com/.

    Create your own copy from the original source code/ (presented for learning programming).


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

view text book
HTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

previous page next page
previous page next page

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2012, 2013 Milo

    Created: January 23, 2012

    Last Updated: August 28, 2013


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

previous page next page
previous page next page