NOTE
NOTE
41
Running Commands from the Shell 2
When you request to open or save a file, your shell uses the current directory as the point of reference.
Simply provide a filename when you save a file, and it is placed in the current directory.
Alternatively, you can identify a file by its relation to the current directory (relative path), or you
can ignore the current directory and identify a file by the full directory hierarchy that locates it
(absolute path). The structure and use of the file system is described in detail later in this chapter.
To find out what your current directory (the present working directory) is, type the pwd command:
$ pwd
/usr/bin
In this example, the current/working directory is /usr/bin. To find out the name of your home
directory, type the echo command, followed by the $HOME variable:
$ echo $HOME
/home/chris
Here, the home directory is /home/chris. To get back to your home directory, just type the
change directory (cd) command. (Although cd followed by a directory name changes the current
directory to the directory that you choose, simply typing cd with no directory name takes you to
your home directory.)
$ cd
Instead of typing $HOME, you can use the tilde (~) to refer to your home directory. So,
to see your home directory, you could simply type echo ~.
Pages:
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175