home *** CD-ROM | disk | FTP | other *** search
- Common Unix Commands
-
- Now, we'd like to give you a brief introduction to some of the
- more commonly-used commands in the Unix system. Most of these
- commands have to do with the file system, but there are a few that
- deal with other areas, such as other users on the system.
-
- File System Commands
-
- There are a number of commands that allow you to view, copy,
- move, erase, and organize files on the Unix system.
- The first command is ls, which is used to list the files that
- are in the current directory. DOS's dir command is much the same as
- ls, but ls does offer some features that dir does not. By itself, ls
- just lists the files in several rows and columns. Several useful
- options can be given to ls to provide different output. One option
- that we find to be very useful is the -F option. This option appends
- symbols on to the end of certain files to indicate what type of file
- it is. The most common symbols are: / for directories and * for
- executable files (programs). Regular files do not have a symbol
- appended to their name. Another option that is used quite a lot is
- the -l option, which produces a "long" display. This format puts just
- one file on each line, and it provides more detailed information about
- each file, including its size, who owns it, and what permissions the
- file has. Permissions determine who has what access to a file. See
- the "chmod" command below for more information on permissions. The
- last option that is of interest is the -a option, which displays ALL
- files. In Unix, files whose names begin with a period are normally
- "hidden". Configuration files and other such files that the user
- doesn't normally need to worry about are hidden in this way. With the
- -a option, however, you can see these files as well as normal ones.
- For information on other options, such as sorting options, and
- information on how to use "wildcards" in your commands, see the manual
- page on ls (type "man ls").
-
- Next, we have three commands that deal with "directories".
- Directories, which you may be familiar with if you've done work in
- DOS, are a way of dividing up files into logical groups, which is
- useful in organizing files. If we didn't have directories on this
- system, all of the thousands of files would be in one place. Imagine
- the mess! Fortunately, we've got things organized into directories.
- Directories are organized into a tree-like structure. If you can
- imagine the trunk of a tree spliting into several branches, which then
- split into smaller branches, etc, then you can see how directories are
- set up. The topmost directory in this structure, from which all other
- directories branch off, is called the "root" directory. When you
- first start using this system, you are given one directory (called
- your "home" directory) that is given to you for your private use.
- To move from one directory to another, you use the "cd"
- command. To move into a directory that is within the current
- directory, just type "cd dir", where "dir" is the name of the
- directory you want to move into. To move up one directory, type "cd
- ..". And to move back to your home directory, type "cd ~".
- You can also create directories within your home directory to
- help you organize your files. For instance, you might want to create
- a directory to hold files that you "FTP" from other locations until
- you can download them. The command to create directories is "mkdir".
- So, in our example, you would start in your home directory (which is
- where you will always be when you first login to the system), and type
- "mkdir ftp". This will create a directory called "ftp" in your home
- directory. Then, when you decide to retreive a file from a remote
- system, just type "cd ftp" to move into that directory, and then run
- the FTP program to get the file, which will be placed in the your ftp
- directory. A companion command, called "rmdir", will delete an empty
- directory. However, if there are files in the directory, rmdir will
- not delete the directory. See the section on the "rm" command below
- for more information.
-
- Next is the "cp" command, which is pretty much the same as the
- DOS "copy" command. Simply type "cp source destination", and cp will
- copy the first file to the second. Often this is used to copy a file
- to a different location, although it can also be used to generate a
- copy of a file under a different name.
- The "mv" command has some similarities to the DOS "rename"
- command, in that it can change the name of a file, but the mv command
- can also move a file to a different location. Simply the "mv old
- new", and mv will either rename the file, or move it to the directory
- specified.
- The "rm" command is much the same as the DOS "del" and "erase"
- commands, but with a few notable features that DOS's commands lack.
- Used without any options, rm will erase a file from the Unix file
- system. Be careful, however, because this is quite permanent once it
- is done. In recent years, DOS has given users the ability to
- "undelete" files shortly after they have been deleted. This ability
- does not exist within the Unix system. By default, the rm command is
- set up to confirm before deleting a file. This is set using the -i
- option. The rm command can also remove entire directory structures
- using the -r option. While the rmdir will only remove an empty
- directory, the rm -r command will remove the entire directory,
- contents and all. Be VERY careful with this command, as it can
- destroy a LOT of data very quickly and easily.
-
- The next command has to do with file permissions. Permissions
- determine which accounts have what access to a file. For each file,
- there are three different sets of three different permissions. The
- three sets are called owner, group, and world. Owner refers to the
- person to whom the file belongs, as displayed in a long file listing,
- group refers to the group of users associated with the file, as
- displayed in a long file listing, and world refers to everyone else on
- the system. For each of these sets, there are three possible
- permissions: read, write, and execute. Read means that set may read
- the file, display its contents, and even copy it, write means that
- set can modify the file, or even erase it, and execute means the file
- is a program that can be run by that set. Execute is also set if the
- file is a directory, and gives members of that set certain abilities
- with regard to the files in that directory.
- The command that is used to change these permissions is
- "chmod". For information on how to use this command, check the manual
- page (type "man chmod" at the prompt).
-
- The next couple of commands could very well become your best
- friends as you learn to use Unix and the Internet. They give you
- access to the online documentation for Unix, known as "manual pages".
- The first command, apropos, takes a string to search for as an
- argument. It will then return a list of commands that match your
- search string, with a short description of each command. The man
- command takes, as an argument, the name of a command, and displays the
- manual page for that command via a "pager". See the section on
- more/less below for more information on pagers. This is a good
- facility to get information about specific commands in the Unix
- system, and also to find commands that are related to certain topics.
-
-
- Similar to DOS's "type" command, Unix has a command called
- "cat", which is used to dump the contents of a file to the screen.
- Most users will probably find themselves using one of the "pager"
- programs described below, as the cat program does not pause the
- display for the user to read the information. However, the cat
- command is often useful at the beginning of a chain of commands to
- feed input to the rest of the chain. To dump a file's contents to the
- screen with cat, simply type "cat file", where file is the name of the
- file you with to display.
- The next two commands both serve the same purpose. Both are
- "pagers". A pager is a program that displays its input one screenful
- at a time, so that the information doesn't scroll past before you can
- read it. In addition, both of these pagers have functions to move
- back a forth within the file being displayed, search for strings of
- text within the file, and other useful features. The first of these
- commands is called "more" (named for the prompt it displays after each
- page of text) which should be sufficient for the needs of most users.
- The other command is "less" (a play on "more"), which has additional
- features not found in more, which may appeal to more advanced users.
- In both cases, you can simply type "more file" (or "less file") and
- the pager will start displaying the file. Also, in either pager,
- pressing "h" at the prompt will display a short help file on the
- various commands each pager provides.
-
- The last two commands that we will present here are used to
- get information about other users who are online or who have accounts
- on this system or other systems on the Internet. The first command is
- the "who" command. If you type "who" at the prompt, it will dump a
- list of the users who are logged into the system at the moment, with
- information about when that user logged in, where they logged in from,
- and other information. A similar command, "w", also gives you an idea
- of what each user is doing at the moment.
- The "finger" command can also display a list of who is online
- at the moment, but is more useful when a user login name is given to
- it. This will produce information about that login name, such as: the
- person's real name, when they last logged in or how long they've been
- logged in, and even some personalized information, if the user has
- chosen to provide this. The personalized information is provided by
- editing the ".plan" file in the user's home directory. You could
- provide some information about yourself, a witty quote, or whatever.
- Give it a try! Finger can also be used to lookup users on other
- computers on the network. Simply type the user's email address in
- addition to their login name (ie. bibach@earth.execpc.com), and the
- finger program will try to connect to the user's computer and return
- information about the user. For more information on the various
- options available with the finger command, check out the manual page.
-
- So, is that it?
-
- Not by a long shot. Unix is a large and potentially complex
- operating system. It is also a very powerful operating system, once
- you learn how to use it to its fullest potential. If you are
- interested in finding out more about Unix, we suggest you get a good
- book on the subject. Unix is becoming quite popular, and there are a
- number of good books on the subject. Until then, you can check out
- all the help files we've provided, as well as the manual pages. And,
- if all else fails, send mail to help, and we'll do what we can to help
- you out. Good luck!
-