3.18. Moving to a Directory: cdAlthough I could remain in my home directory and access the various versions of my lyric files by preceding them with the prefix "lyrics/", this would be rather inconvenient. For example, to edit the file "heart.ver1" with the Linux vim editor, I'd have to do the following: $ vim lyrics/heart.ver1 ...invoke the vim editor. In general, it's a good idea to move your shell into a directory if you intend to do a lot of work there. To do this, use the cd command. cd isn't actually a Linux or GNU utility, but instead is an example of a shell built-in command. Your shell recognizes it as a special keyword and executes it directly. Notice that I write shell commands using italics, in adherence to the nomenclature that I described at the start of this book. Figure 3-21 shows how cd works:
The following example shows how I moved into the "lyrics" directory and confirmed my new location using pwd: $ pwd ...display where I am. /home/glass $ cd lyrics ...move into the "lyrics" directory. $ pwd ...display where I am now. /home/glass/lyrics $ _ Figure 3-22 illustrates the shell movement caused by the previous cd command: Figure 3-22. cd moves a shell.
Since "." and ".." refer to your shell's current working directory and parent directory, respectively, you may move up one directory level by typing "cd ..". Here's an example: $ pwd ...display current position. /home/glass/lyrics $ cd .. ...move up one level. $ pwd ...display new current position. /home/glass $ _ |