Basic UNIX Commands  Typing Pwd Will Display a List of Directories Separated by a Forward Slash (/)

Basic UNIX Commands  Typing Pwd Will Display a List of Directories Separated by a Forward Slash (/)

pwd - ‘print working directory’ Basic UNIX Commands Typing pwd will display a list of directories separated by a forward slash (/). This is a pwd pathname. The first slash refers to the root ls directory, then each subdirectory is listed, and the last item is the name of the cd directory you are currently in (your working .. directory). man $ pwd /home/jsmith pwd - Practice ls - ‘list’ What is the pathname of your current The command_name ls alone will list directory? the names of the files in the current (or working) directory. /home/userid Example: $ ls UNIX_class /home/stevecox ls - ‘list’ ls - Practice ls [operand] will list the names of How many files and subdirectories are in the files in the specific directory asked for. your current directory? $ ls $ ls /home (UNIX_class) & (misc. files) ajkurtz htripath klabarre How many files and subdirectories are in cdulude jfieber mbswan /home/userid/UNIX_class ? herring katy stevecox $ ls /home/userid/UNIX_class 5 (Shakespeare, Wildcards, dir1, dir2, equine) 1 cd - ‘change directory’ cd - ‘change directory’ When you use ls, you are just looking The command_name cd alone will at the directories, you have not actually always move you to your personal ‘moved’ (you stay at the same pwd). home directory (on /home). The command_name cd will let you move your current directory to a new $ cd location. $ cd cd - ‘change directory’ cd - ‘change directory’ cd [operand] will move you (your If the directory you wish to move to is a current directory) to the specific directory subdirectory of your current directory, asked for. then you only need to type a pathname starting from where you are. $ cd UNIX_class $ cd UNIX_class/dir2/cats This is called a relative pathname. cd - ‘change directory’ Pathnames - Example But, if the directory you wish to move to If you are in jsmith, is not a subdirectory of your current and you want to go directory, then you need to type a to dir1 pathname starting from the root (/). $ cd /var/adm/log This is called an absolute pathname. Some texts will refer to this as a “full” pathname. The meaning is the same. 2 Pathnames - Example Pathnames - Example You only need a $ cd UNIX_class/dir1 relative pathname, because dir1 is ‘under’ you. Pathnames - Example Pathnames - Example If you are in jsmith, You need an and you want to go absolute pathname, to log because log is not ‘under’ you. Pathnames - Example Pathnames - Example $ cd /var/adm/log If you are in UNIX_class and you need to access grp_project, how would you get there? 3 Pathnames - Example Pathnames - Example $ cd /home/kadams/grp_project But, if you are in home and you need to access grp_project, how would you get there? Pathnames - Example References to your home directory $ cd kadams/grp_project When you login, UNIX always knows where your home directory is. There are several ways to return to the top of your home directory (/home/userid) References to your home directory References to your home directory ~ (tilde) symbol represents your home directory so: However, cd and cd ~ are redundant. $ cd ~ Therefore, the tilde is more useful when moving to a subdirectory under your will always return you to your home. home directory (when you are outside $ cd ~userid your home directory structure, i.e. will lookup the information for another user /home/otheruserid/docs). and find their home directory location and $ cd ~/UNIX_class/dir2 take you there if you are allowed. 4 References to your home directory .. - ‘parent directory’ As we mentioned earlier, the information stored Another way to reference your home in the UNIX system is hierarchical. directory is by another special character, the $ symbol. This is a At any time, the directory which is right above variable that contains your home you (closer to the root directory) is often called directory location. the ‘parent’ directory. $ cd $HOME .. is an [operand] which “signifies” the parent directory of your current directory. It will $ echo $HOME (will print your home directory) be used in place of an operand. .. - ‘parent directory’ .. - ‘parent directory’ Typing cd .. will move your working directory up one level, into the parent directory of where you were. $ cd .. • The parent directory of ‘man’ is ‘local,’ and the parent directory of ‘local’ is ‘usr.’ .. - ‘parent directory’ .. - ‘parent directory’ What is the pathname of your home Typing ls .. lists everything else in directory? your parent directory – files and /home/userid directories parallel with your working directory. What is the pathname of the parent directory of your home directory? $ ls .. /home 5 Example Example $ pwd Suppose ‘jsmith’ is your current directory. /home/jsmith Example Example $ ls $ ls .. mail docs temp sbaker jsmith stevecox Example .. - ‘parent directory’ You can also use ‘..’ to move ‘up, over, and down’ to a new directory somewhere else. Otherwise you would have to $ cd .. use an absolute pathname. Moves your current directory to home. 6 .. Example .. Example If you are in jsmith, and $ cd .. you need to access grp_project, At this point, you you could have moved up use ‘..’ to home .. Example .. Example $ cd ../kadams $ cd ../kadams/grp_project Now you have And now you are in moved down to grp_project kadams .. Example man - ‘manual’ $ cd ../../stevecox Can’t remember what a Now that you are command does? in grp_project, you can move to You can type: stevecox man command_name This will give you UNIX’s complete online manual. 7 man - ‘manual’ man - ‘manual’ Don’t just rely on the manual A manual page will usually include: though. This would be a very time-consuming way of Title: the page # and the name of the using UNIX, and also the system that the command is part of manual can be pretty difficult to understand. Name: usually the command and a brief description Note: use the space bar to move forward a page, and Synopsis: how to type the command, the ‘b’ key to move back a and an example of every option available. page man - ‘manual’ man - Practice Description: a few paragraphs (or Browse through man pwd pages) about the command and its Now browse through man cd options Notice how much larger the manual is See Also: lists names of related manual for (which can also do a lot more pages, if any cd than pwd can). Warnings and Bugs: if any are known You can type ‘q’ to leave man Files: a list of the files this command uses (for specific commands - like mail) man - ‘manual’ Review pwd - tells you where you currently are If you forget how man is laid out, - list the files & subdirectories of your you can always type man man ls current directory cd - changes your current directory man - displays the manual pages .. - signifies the parent directory of your current directory. It is NOT a command, it is an operand (argument). 8 Combining Commands Practice If you don’t remember the name of the What is the absolute pathname to directory you want to move to, then use cats? (in dir2) ls to see all the names of your working directory, then cd to the correct one. /home/userid/UNIX_class/dir2/cats Practice Practice How many files are in the Shakespeare What option is needed to list the files in directory? a directory, including those that are eight normally not listed (begins with a . )? $ ls UNIX_class/Shakespeare Practice The End… Check man ls Next… -a Lists all entries, including those that begin Shells I with a dot (.), which are normally not listed. 9.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    9 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us