|
|
| Unix
is not typically a point and click, visual icon system like Macs and PC's.
Most UNIX systems are run by line commands. Nearly all Unix computers at
Princeton are connected to the Princeton campus network, and through it
to the Internet, an international network of networks. All of CIT's computers
use the same file server. This means that your files are always available
to you, whether you log in to arizona or sesamest, or a SPARCstation (but
you will need to explicitly move files on to and off of your departmental
machines). Unix provides extensive on-line help files in the form
of manual pages --"man pages" for short. The man command lets you read
detailed descriptions of each Unix command.
For instance, to
get help on the man command itself, type man man and press the Return key.
(You nearly always have to press Return to "enter" a command, that is send
it to the computer.) To get help on the cat command, you would enter man
cat. The manual pages for the command will be displayed one screen at a
time; to see the next screen, press the space bar. To go back one screen,
press the letter b key. If you just want to creep forward one line at a
time, press Return.
File and Directory StructuresFiles on Unix computers are organized into directories. A directory can contain files as well as other directories. Each directory, in turn, can contain files and directories. Unix associates a particular directory, called a home directory, with each user. Your home directory (or directories you create within it) is where you store your files. Whenever you log in, you start out in your home directory. Unless you specify otherwise, any files you create will be stored there.The directory in
which you are working is called the current directory. If you refer to
a filename without specifying a directory, Unix assumes you want to find
or put the file in the current directory. If you decide to work on a project,
say designing widgets, you may want to use the mkdir (make directory) command:
mkdir widgets to create a subdirectory within your home directory to hold
your widget work. You would move to it with the cd (change directory) command:
cd widgets.
Basic UNIX CommandslsThe ls command lists the contents of a directory. If you just enter ls, it will show you the contents of the current directory. If you have a subdirectory named foo in your current directoryand you enter ls foo, it will show you the contents of foo. pwd The pwd command (short for "print working directory") shows you the name of the current directory. If your userid is gwdoe and you are in the src subdirectory of your home directory, pwd might show you something like /auto/u/gwdoe/src. The /auto/u/ part is where your you something like /auto/u/gwdoe/src. The /auto/u/ part is where your home directory happens to be stored and you only need /u/... to get to it. (This may vary depending on what kind of computer you are using.) cd The cd command lets you change your current directory. If you enter cd src (and there is a directory called src in your current directory), you move down into the src directory and it becomes your current directory. To back up one level, you can type cd .. (read "c-d space dot dot"). The two periods are a notation for "parent directory of the current directory." One period is a notation for the current directory itself, but obviously in this case cd. isn't very useful. Typing cd without specifying a directory takes you to your home directory. mkdir The mkdir command allows you to make a new directory. For instance, if you are in directory food in your home directory, and you enter mkdir fruit, a new directory called fruit is created as a subdirectory of food. (The mkdir command doesn't change your current directory; if you want to move to fruit you have to explicitly say cd fruit after creating it.) rm The rm command allows you to erase ("remove") a file or files. If you want to erase the file foo in your current directory, you can say rm foo. The default initialization files you get with your account are set up to tell rm to ask for confirmation before erasing files, so unless you have modified them, you will be asked rm: remove foo? If you enter y, the file will be erased; if you have changed your mind you can enter n. rmdir The rm command allows you to remove files, but it doesn't work on directories. To remove a directory, first delete all of the files (and/or subdirectories) in it, and then use the rmdir command. Note that rmdir isn't set up to ask you for confirmation. (Since you can only remove directories that are empty, though, this isn't a real problem.) cp The cp command makes a new copy of a file. If you have a file that you call green and you enter cp green green.backup, you will create a new file called green.backup with the same contents as green. You can then edit each file separately. Note that if there is already a file called green.backup, it will be replaced and its old contents will be lost. mv The mv command lets you move or rename a file. If you have a file called friends and you enter mv friends enemies, the file is renamed to enemies. You can also use the mv command to move a file from one directory to another. If you have a file called friends and a directory called notes in your current directory, typing mv friends notes will move the file from the current directory into the directory notes. chmod The chmod command sets the permissions of a directory or a file on the UNIX server. To set the permission for a file xyz.fil to 644, enter "chmod 644 xyz.fil". When you are setting the permissions for multiple files, you can use the wild card "*". For example, if you want to set the permission of all of the files with the extension .html to 644, enter "chmod 644 *.html". You have to set permissions correctly in order to make files readable by other users. For more information use man command.
If you want to make your HTML documents world-readable, or accessible on the World Wide Web, you must set the permission of your directory and your files correctly. The WebFactory Courseware automatically creates a public_html directory in the user's account and sets these permissions if they do not already exist. First, the permission of your directory must be set. If you do not have a public_html directory, in which the HTML documents will be stored, you must execute: /usr/princeton/bin/wwwpublicon your Unix account. This command creates public_html directory in your home directory and set the permission correctly. The permission of your home directory must also be set to be world-readable. To set this permission, execute cd ..from your own home directory. Next, you have to make your HTML documents world-readable. To do so, the permission of the documents must be set to 644. In the public_html directory (or other directory in which the HTML documents are stored), execute chmod 644 *.htmlNote that the permission of the files created on Web Factory is set to 644 by default.
Shortcuts
for Typing Commands
For more InformationFor more information on UNIX, including UNIX text editors:Unix Computing - Quick Guide Introduction to Unix Computing at Princeton Getting Started with UNIX Unix Text Editors For more information about file structures, go to the NTTR file systems tutorial at http://www.princeton.edu/~aiteachs/nttr/files/ That's it for UNIX; let's move on to Telnet. |
|
|