The shell is always in one directory. This is the current directory. When the shell starts, the current directory is your home directory.
pwd: write the current directory
pwd writes the full path of the current directory:
learner@tidepool:~$ pwd
/home/learnerThe prompt shows it
The part of the prompt between : and $ is the current directory. In your home directory, and under it, the prompt uses ~:
| Prompt | Current directory |
|---|---|
learner@tidepool:~$ | /home/learner |
learner@tidepool:~/shop$ | /home/learner/shop |
learner@tidepool:/etc$ | /etc |
The prompt shortens the path. pwd never does.
Names without a path
When an argument is a name with no /, the program looks for it in the current directory:
- /home/learner
- notes.txt
- shop← current directory
- prices.txt
- orders
learner@tidepool:~/shop$ cat prices.txt
tea 4.50
coffee 3.20This is why you could use notes.txt in Chapter 2 with no path. The file was in the current directory.
Commands that work on a directory, such as tree, use the current directory when you give no argument.