home *** CD-ROM | disk | FTP | other *** search
/ A Beginner's Guide to the Internet / INTERNET.ISO / text / guides / help / ccmds.hlb < prev    next >
Encoding:
Text File  |  1994-07-11  |  10.6 KB  |  182 lines

  1. Common Unix Commands
  2.  
  3.     Now, we'd like to give you a brief introduction to some of the
  4. more commonly-used commands in the Unix system.  Most of these
  5. commands have to do with the file system, but there are a few that
  6. deal with other areas, such as other users on the system.
  7.  
  8. File System Commands
  9.  
  10.     There are a number of commands that allow you to view, copy,
  11. move, erase, and organize files on the Unix system.
  12.     The first command is ls, which is used to list the files that
  13. are in the current directory.  DOS's dir command is much the same as
  14. ls, but ls does offer some features that dir does not.  By itself, ls
  15. just lists the files in several rows and columns.  Several useful
  16. options can be given to ls to provide different output.  One option
  17. that we find to be very useful is the -F option.  This option appends
  18. symbols on to the end of certain files to indicate what type of file
  19. it is.  The most common symbols are: / for directories and * for
  20. executable files (programs).  Regular files do not have a symbol
  21. appended to their name.  Another option that is used quite a lot is
  22. the -l option, which produces a "long" display.  This format puts just
  23. one file on each line, and it provides more detailed information about
  24. each file, including its size, who owns it, and what permissions the
  25. file has.  Permissions determine who has what access to a file.  See
  26. the "chmod" command below for more information on permissions.  The
  27. last option that is of interest is the -a option, which displays ALL
  28. files.  In Unix, files whose names begin with a period are normally
  29. "hidden".  Configuration files and other such files that the user
  30. doesn't normally need to worry about are hidden in this way.  With the
  31. -a option, however, you can see these files as well as normal ones.
  32. For information on other options, such as sorting options, and
  33. information on how to use "wildcards" in your commands, see the manual
  34. page on ls (type "man ls").
  35.  
  36.     Next, we have three commands that deal with "directories".
  37. Directories, which you may be familiar with if you've done work in
  38. DOS, are a way of dividing up files into logical groups, which is
  39. useful in organizing files.  If we didn't have directories on this
  40. system, all of the thousands of files would be in one place.  Imagine
  41. the mess!  Fortunately, we've got things organized into directories.
  42. Directories are organized into a tree-like structure.  If you can
  43. imagine the trunk of a tree spliting into several branches, which then
  44. split into smaller branches, etc, then you can see how directories are
  45. set up.  The topmost directory in this structure, from which all other
  46. directories branch off, is called the "root" directory.  When you
  47. first start using this system, you are given one directory (called
  48. your "home" directory) that is given to you for your private use.
  49.     To move from one directory to another, you use the "cd"
  50. command.  To move into a directory that is within the current
  51. directory, just type "cd dir", where "dir" is the name of the
  52. directory you want to move into.  To move up one directory, type "cd
  53. ..".  And to move back to your home directory, type "cd ~".
  54.     You can also create directories within your home directory to
  55. help you organize your files.  For instance, you might want to create
  56. a directory to hold files that you "FTP" from other locations until
  57. you can download them.  The command to create directories is "mkdir".
  58. So, in our example, you would start in your home directory (which is
  59. where you will always be when you first login to the system), and type
  60. "mkdir ftp".  This will create a directory called "ftp" in your home
  61. directory.  Then, when you decide to retreive a file from a remote
  62. system, just type "cd ftp" to move into that directory, and then run
  63. the FTP program to get the file, which will be placed in the your ftp
  64. directory.  A companion command, called "rmdir", will delete an empty
  65. directory.  However, if there are files in the directory, rmdir will
  66. not delete the directory.  See the section on the "rm" command below
  67. for more information.
  68.  
  69.     Next is the "cp" command, which is pretty much the same as the
  70. DOS "copy" command.  Simply type "cp source destination", and cp will
  71. copy the first file to the second.  Often this is used to copy a file
  72. to a different location, although it can also be used to generate a
  73. copy of a file under a different name.
  74.     The "mv" command has some similarities to the DOS "rename"
  75. command, in that it can change the name of a file, but the mv command
  76. can also move a file to a different location.  Simply the "mv old
  77. new", and mv will either rename the file, or move it to the directory
  78. specified.
  79.     The "rm" command is much the same as the DOS "del" and "erase"
  80. commands, but with a few notable features that DOS's commands lack.
  81. Used without any options, rm will erase a file from the Unix file
  82. system.  Be careful, however, because this is quite permanent once it
  83. is done.  In recent years, DOS has given users the ability to
  84. "undelete" files shortly after they have been deleted.  This ability
  85. does not exist within the Unix system.  By default, the rm command is
  86. set up to confirm before deleting a file.  This is set using the -i
  87. option.  The rm command can also remove entire directory structures
  88. using the -r option.  While the rmdir will only remove an empty
  89. directory, the rm -r command will remove the entire directory,
  90. contents and all.  Be VERY careful with this command, as it can
  91. destroy a LOT of data very quickly and easily.
  92.  
  93.     The next command has to do with file permissions.  Permissions
  94. determine which accounts have what access to a file.  For each file,
  95. there are three different sets of three different permissions.  The
  96. three sets are called owner, group, and world.  Owner refers to the
  97. person to whom the file belongs, as displayed in a long file listing,
  98. group refers to the group of users associated with the file, as
  99. displayed in a long file listing, and world refers to everyone else on
  100. the system.  For each of these sets, there are three possible
  101. permissions: read, write, and execute.  Read means that set may read
  102. the file, display its contents, and even copy it, write means that
  103. set can modify the file, or even erase it, and execute means the file
  104. is a program that can be run by that set.  Execute is also set if the
  105. file is a directory, and gives members of that set certain abilities
  106. with regard to the files in that directory.
  107.     The command that is used to change these permissions is
  108. "chmod".  For information on how to use this command, check the manual
  109. page (type "man chmod" at the prompt).
  110.  
  111.     The next couple of commands could very well become your best
  112. friends as you learn to use Unix and the Internet.  They give you
  113. access to the online documentation for Unix, known as "manual pages".
  114. The first command, apropos, takes a string to search for as an
  115. argument.  It will then return a list of commands that match your
  116. search string, with a short description of each command.  The man
  117. command takes, as an argument, the name of a command, and displays the
  118. manual page for that command via a "pager".  See the section on
  119. more/less below for more information on pagers.  This is a good
  120. facility to get information about specific commands in the Unix
  121. system, and also to find commands that are related to certain topics.
  122.  
  123.  
  124.     Similar to DOS's "type" command, Unix has a command called
  125. "cat", which is used to dump the contents of a file to the screen.
  126. Most users will probably find themselves using one of the "pager"
  127. programs described below, as the cat program does not pause the
  128. display for the user to read the information.  However, the cat
  129. command is often useful at the beginning of a chain of commands to
  130. feed input to the rest of the chain.  To dump a file's contents to the
  131. screen with cat, simply type "cat file", where file is the name of the
  132. file you with to display.
  133.     The next two commands both serve the same purpose.  Both are
  134. "pagers".  A pager is a program that displays its input one screenful
  135. at a time, so that the information doesn't scroll past before you can
  136. read it.  In addition, both of these pagers have functions to move
  137. back a forth within the file being displayed, search for strings of
  138. text within the file, and other useful features.  The first of these
  139. commands is called "more" (named for the prompt it displays after each
  140. page of text) which should be sufficient for the needs of most users.
  141. The other command is "less" (a play on "more"), which has additional
  142. features not found in more, which may appeal to more advanced users.
  143. In both cases, you can simply type "more file" (or "less file") and
  144. the pager will start displaying the file.  Also, in either pager,
  145. pressing "h" at the prompt will display a short help file on the
  146. various commands each pager provides.
  147.  
  148.     The last two commands that we will present here are used to
  149. get information about other users who are online or who have accounts
  150. on this system or other systems on the Internet.  The first command is
  151. the "who" command.  If you type "who" at the prompt, it will dump a
  152. list of the users who are logged into the system at the moment, with
  153. information about when that user logged in, where they logged in from,
  154. and other information.  A similar command, "w", also gives you an idea
  155. of what each user is doing at the moment.
  156.     The "finger" command can also display a list of who is online
  157. at the moment, but is more useful when a user login name is given to
  158. it.  This will produce information about that login name, such as: the
  159. person's real name, when they last logged in or how long they've been
  160. logged in, and even some personalized information, if the user has
  161. chosen to provide this.  The personalized information is provided by
  162. editing the ".plan" file in the user's home directory.  You could
  163. provide some information about yourself, a witty quote, or whatever.
  164. Give it a try!  Finger can also be used to lookup users on other
  165. computers on the network.  Simply type the user's email address in
  166. addition to their login name (ie. bibach@earth.execpc.com), and the
  167. finger program will try to connect to the user's computer and return
  168. information about the user.  For more information on the various
  169. options available with the finger command, check out the manual page.
  170.  
  171. So, is that it?
  172.  
  173.     Not by a long shot.  Unix is a large and potentially complex
  174. operating system.  It is also a very powerful operating system, once
  175. you learn how to use it to its fullest potential.  If you are
  176. interested in finding out more about Unix, we suggest you get a good
  177. book on the subject.  Unix is becoming quite popular, and there are a
  178. number of good books on the subject.  Until then, you can check out
  179. all the help files we've provided, as well as the manual pages.  And,
  180. if all else fails, send mail to help, and we'll do what we can to help
  181. you out.  Good luck!
  182.