3 - Weber State University
3 - Weber State University
3 - Weber State University
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
90 Chapter 3 Exploring Linux Filesystems<br />
You can also use the ~ metacharacter to refer to another user’s home directory by appending<br />
a user name at the end:<br />
[root@server1 ~]# cd ~mary<br />
[root@server1 mary]# pwd<br />
/home/mary<br />
[root@server1 mary]# cd ~<br />
[root@server1 ~]# pwd<br />
/root<br />
[root@server1 ~]#_<br />
In many of the examples discussed earlier, the argument specified after the cd command is<br />
an absolute pathname to a directory, meaning that the system has all the information it<br />
needs to find the destination directory because the pathname starts from the root (/) of the<br />
system. However, in most Linux commands, you can also use a relative pathname in place<br />
of an absolute pathname to reduce typing. A relative pathname is the pathname of a target<br />
file or directory relative to your current directory in the tree. To specify a directory underneath<br />
your current directory, simply refer to that directory by name (do not start the pathname with<br />
a / character). To refer to a directory one step closer to the root of the tree (also known as a<br />
parent directory), simply use two dots (..). An example of using relative pathnames to move<br />
around the directory tree is shown next:<br />
[root@server1 ~]# cd /home/mary<br />
[root@server1 mary]# pwd<br />
/home/mary<br />
[root@server1 mary]# cd ..<br />
[root@server1 home]# pwd<br />
/home<br />
[root@server1 home]# cd mary<br />
[root@server1 mary]# pwd<br />
/home/mary<br />
[root@server1 mary]#_<br />
In the preceding example, we used “..” to move up one parent directory and then used the<br />
word “mary” to specify the mary subdirectory relative to our current location in the tree;<br />
however, you can also move more than one level up or down the directory tree:<br />
[root@server1 ~]# cd /home/mary<br />
[root@server1 mary]# pwd<br />
/home/mary<br />
[root@server1 mary]# cd ../..<br />
[root@server1 /]# pwd<br />
/<br />
[root@server1 /]# cd home/mary<br />
[root@server1 mary]# pwd<br />
/home/mary<br />
[root@server1 mary]#_<br />
You can also use one dot (.) to refer to the current directory.<br />
Although this is not useful when using the cd command, you do<br />
use one dot later in this book.<br />
© Cengage Learning. All rights reserved. No distribution allowed without express authorization.