![]() |
![]() |
Here are some of the basic UNIX commands that you need to work with html using your mainframe account and the pico editor. The examples are provided in generic form and are followed by a specific example you could use. What you type is rendered in a monospaced font.
You type:
pico filename.extensionpico test.html
To save a file without quitting, you type:
^O
Then you will see:
Filename to write: test.html
Press return and you will save the document without quitting
To save a file and quit, you type:
^X
Then you will see:
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) (y/n)?
Type Y, press return and you will save the document and quit
You type:
mkdir directoryname
mkdir Images
Depending on where you create this directory, you may have to set file permissions to make the directory and its contents world-readable. To do this, see chmod below (#9).
You can do this by saving with ^O or ^X and renaming the file when you get to either of the following command lines:
Filename to write: test.html
Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) (y/n)?
You can also rename a file with the mv command. You type
mv oldfilename.ext newfilename.ext
mv test.html mypage.html
This command treats the newfilename.ext element as a destination (a directory or subdirectory). If the destination can't be found, the file is renamed. If the destination can be found, the file is moved.
To move a file (mypage.html) into a directory (home), you also use the mv command.
You type:
mv filename.extension directory
mv mypage.html home
If you have to move a file from one directory to another, you have to use themv command to move the file up and down the directory structure one level at a time.
To move a file to the next highest directory, you use ../, you type (if you are only moving up one directory the / is optional):
mv filename.extension ../
mv mypage.html ../
You can also move a file up more than one directory at a time by stringing together the appropriate number of ../ elements. For example, to move a file up two directories, you would type:
mv filename.extension ../../
mv mypage.html ../../
Finally, to move a file up two levels and then down one into another directory, you would use the ../ and the name of the directory where you'd like to place the file. For example, to move a file up two levels and then down into a file called "Images," you'd type:
mv filename.extension ../../Newdirectory
mv mypage.html ../../Images
The cp command creates a copy of a file, preserving the original and making an identical copy in the same directory. You set the name for the new file.
If you already have a file with the new name, cp will overwrite and destroy the duplicate. For this reason, it's safest to always add -i after the cp command which will ask for your approval before it destroys existing files.
To use the cp command to create a copy of a file, you type:
cp -i oldfilename newfilename
So, to use the cp command to create a copy of testfile.html called testfile1.html, you type:
cp -i testfile.html testfile1.html
You have to set the proper file permissions so that your files can be viewed on the web. You must do this for all text (.html) files as well as for all other files in your www directors (image, audio, video,...).
The generic UNIX command used to set permissions is:
chmod
Here are some of the options you have for setting permissions:
| Owner-level | Group-level | Other-level |
|---|---|---|
| 400 read by owner | 040 read by group | 004 read by others |
| 200 write by owner | 020 write by group | 002 write by others |
| 100 execute by owner | 010 execute by group | 001 execute by others |
To set permissions, you decide on the level of access and sum them. This number is used with the chmod command.
For example, to give read privileges to all, and write and execute privileges to the owner only for a file, you would sum:
400+200+100+040+004 = 744
At the UNIX prompt, enter:
chmod 744 filename.extension
Some other frequently-used examples are:
777 - anyone can do anything (read, write, or execute)
755 - you can do anything; others can only read and execute
711 - you can do anything; others can only execute
644 - you can read and write; others can only read
If you create a new file called test.html in a directory called Test, which is in your www directory, you can read and edit it, but no one else can see it. The permissions look like this (along with the commands that let you view file permissions):
% cd Test % ls -l total -rw------- 1 hrosenba 4001 10 Sep 10 23:00 test.html
To set the proper permissions for any file, you use the chmod command along with a number that represents an appropriate level of access. For example,if you use 644, you can read and write, and everyone else can read it. You type:
chmod 644 test.html
To see the file permissions for test.html, you would type:
ls -l
Then you would see:
total 2 -rw-r--r-- 1 hrosenba 4001 10 Sep 10 23:00 test.html
Notice how the permissions have changed.
You also have to set proper permissions for directories, so that the files that you store in them can be viewed on the web. Although the permissions will look different, the procedure is the same.
If you create a directory called Test, you would type:
mkdir Test
The permissions look like this:
ls -l total 2 drwx------ 2 hrosenba 4001 96 Sep 11 12:19 Test
To set the proper permissions, you type:
chmod 755 directorynamechmod 755 Test
To see the permissions for the directory, you would type:
ls -l
Then you see:
total 2 drwxr-xr-x 2 hrosenba 4001 96 Sep 11 12:19 Test
Again, notice how the permissions have changed.
| Demo Page Navigation: |
DemoPage contents | About HTML | UNIX help | HTML tags | Lists | Links | Images |
|---|---|---|---|---|---|---|---|
| Imagemapping | Tables | Forms | Frames | Javascript | CSS (style sheets) | XML |
| Page by Howard Rosenbaum | |
| Find me at hrosenba@indiana.edu | http://www.slis.indiana.edu/hrosenba/www/Demo/UNIX.html |