Page 169 - DCAP106_OPERATING_SYSTEM_TOOLS
P. 169

Operating System Tools




                    Notes          9.4.1 Commands for Directory Navigation

                                   In case of Linux, when you log in as root, then /root is your home directory. For other users,
                                   the home directory is usually in the /home directory. My home directory (when we log in as
                                   edulaney) is /home/edulaney. This information is stored in the /etc/passwd file.
                                   By default, only you are allowed to save files in your home directory, and only you can create
                                   subdirectories in your home directory in order to further organise your files.
                                   The concept of a current directory is supported by Linux. Current directory is the directory on
                                   which every file and directory command operate.


                                          Example: After you log in, your current directory is the home directory.
                                   To see the current directory, type the pwd command.
                                   To change the current directory, use the cd command.


                                          Example: To change the current directory to /usr/lib, type the following:
                                   cd /usr/lib
                                   Then, to change the directory to the cups subdirectory in /usr/lib, type this command:

                                   cd cups
                                   Now, on using pwd command shows /usr/lib/cups as the current directory.
                                   Thus,  you can refer to a directory’s name in two methods:

                                   z z  Absolute pathname:  An  example  of  absolute  pathname  is  /usr/lib,  which  is  an  exact
                                       directory in the directory tree. Absolute pathname is considered as the complete mailing
                                       address for a package that the postal service will deliver to your next-door neighbor.
                                   z z  Relative directory name: An example of relative directory name is cups. It  represents the
                                       cups subdirectory of the current directory, whatever that may be. The relative directory
                                       name gives the postal carrier directions from your house to the one next door so the carrier
                                       can deliver the package.
                                   Typing cd cups in /usr/lib will change the current directory to /usr/lib/cups. However, if we
                                   type the same command in /home/edulaney, the shell tries to change the current directory to
                                   /home/edulaney/cups.

                                   In order to change the current directory back to your home directory, use the cd command
                                   without any arguments. No matter where you are, typing cd at the shell prompt brings you back
                                   home!

                                   Now let discuss he tilde character (~). It refers to your home directory. So, the current directory
                                   can be changed to your home directory by using the command cd ~. You can also refer to another
                                   user’s home directory. This is done by appending the name of that user to the tilde. For instance,
                                   cd ~superman changes the current directory to the home directory of superman.
                                   Now we will discuss the concept of a single dot (.) and two dots (. .) They also have special
                                   meanings. A single dot (.) specifies the current directory, whereas two dots (. .) specifies the
                                   parent directory.
                                   For example, if the current directory is /usr/share, you go one level up to /usr by typing the
                                   following:
                                   cd . .






          162                              LOVELY PROFESSIONAL UNIVERSITY
   164   165   166   167   168   169   170   171   172   173   174