Creating Web Documents

A Unix Survival Kit

Common Unix Commands

Here are some examples of common Unix commands. For more information, visit Unix Station, including the Introduction to Unix course.

Type this at your Unix Prompt and hit the "Enter" or "Return" key on your keyboard What it does
pwd Tells you the location of your present working directory. Use this at any time to figure out "where you are" in your file system.
cd This changes your working directory to your home directory. Your home directory is the beginning directory where you have files you have on the computer. No matter where you are in the file system, you can enter this command to get back home.
ls This lists the names of the files and directories in your present working directory. Some Unix systems will use some visual cue to indicate which names are files and which are directories. A common convention is that files have an extension name. For example, an HTML file commonly has a file extension html, so that you could see that hello.html is a filename while www or portfolio are directory names.
cd www This changes your working directory to the subdirectory called www. If you do not have a subdirectory by this name in your present working directory, you will get an error. The name www is a popular name for the subdirectory for your Web space.
mkdir portfolio This makes a subdirectory called portfolio in your present working directory.
cd .. This changes your present working directory to be the parent directory of your present working directory. If you visualize all your directories in a tree relationship, this command moves you one directory level up.
vi myfile.html This starts up a session of the vi editor with the contents of the file myfile.html. If the file myfile.html doesn't already exist, this command creates it and allows you to begin entering content into it. The vi editor is commonly available on Unix systems and has its own command syntax. There are many other kinds of text editors that may be available on your Unix system, such as pico, emacs, and others. Your Unix system administrator should be able to provide you with documentation of these editors, or such documentation may be available right on your system.

Whatever editor you choose to use, you'll need to know how to: create a file, save a file, exit the editor, enter text, delete text, copy and paste text (both within the editor and from one window to another on your computer screen).

cp myfile.html yourfile.html This copies the contents of the file myfile.html into a new file called yourfile.html. If the file yourfile.html already exists, the system may (or may not, depending on how your system is set up) ask if you want to overwrite it.
mv myfile.html mybestfile.html This renames the file myfile.html to the name mybestfile.html. If mybestfile.html already exists, the system may (or may not depending on your system) ask if you want to overwrite it. If your system doesn't ask you, you've destroyed the previous contents of mybestfile.html.
rm myfile.html This removes the file myfile.html from the system. In Unix, there is rarely the concept of a "trash bin" where you can go to recover files that you accidentally removed.
rmdir portfolio This removes the directory called portfolio. If the directory is not empty, your system may tell you it is not empty. If so, you need to change your present working directory to portfolio, then remove the files in it.
cat myfile.html This shows the contents of the file myfile.html without having to enter a text editor to view those contents. The term comes from the word concatenate.

A Sample Unix Session

$ pwd
$ ls
access-log@  hold/        mail/        pass*        store/
anonftp@     htsdata/     maillists/   sitepop_pwd  www@
bin/         infobots/    mbox         stage/  
$ cd www
/www$ cd html
/www/html$ cd tutor
/www/html/tutor$ ls
asg1.html       grading.html    index.html      standards.html
asg2.html       hello.html      meta.html       startup.html
asg3.html       hypertext.html  portfolio.html  style.html
basic.html      images.html     qa.html         style2.html
/www/html/tutor$ vi hypertext.html 
/www/html/tutor$ cd
$ pwd
$ cd www
/www$ vi december.css
/www$ cd html/demo
/www/html/demo$ pwd
/www/html/demo$ cd portfolio
portfolio: No such file or directory
/www/html/demo$ mkdir portfolio
/www/html/demo$ cd portfolio
/www/html/demo/portfolio$ vi si.html
/www/html/demo/portfolio$ vi si.css
/www/html/demo/portfolio$ vi units.html
/www/html/demo/portfolio$ vi prefixes.html
/www/html/demo/portfolio$ date
Fri Dec  1 10:32:22 CST 2000
/www/html/demo/portfolio$ vi links.html
/www/html/demo/portfolio$ vi use.html
/www/html/demo/portfolio$ vi si.css
/www/html/demo/portfolio$ exit

Unix Reference

Check with the Web site of your computer support organization. They are likely to have online a reference manual that describes how to use the operating system you have on your computer. There are many versions of Unix as well as various operating systems that are "Unix-like."

Save this page to any social bookmarking site! Share · search Search · star Market
2022-02-10 · · Terms © December Communications, Inc.