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.
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.
Type pwd from the command line, followed by ENTER or RETURN, and you will see the current working directory.
$ pwd /Users/admin $
Theres 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.
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 Desktop $ pwd /Users/admin $
pwd is almost always used without options and never uses any arguments (such as file names). Anything other tahn 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.
$ pwd -L /Users/admin $
The -P option displays the physical current working directory, with all symbolic links resolved.
$ pwd -P /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.
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.
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).
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.