320: Infrastructure Competencies

Creating and Manipulating Unix Directories


Webspace Root

Your login directory (the one you end up in when you use ssh to connect) is one thing, and your webspace root (or web root directory) is another. Your web root is a subdirectory of your login directory. Files and directories which are not "in" or "below" your web root directory are not visible to web browsers (people accessing your site from the Web).

Your default web root directory was set by the system administrator when they installed the webserver software on your server. In most cases this is a subdirectory under your login directory named "public_html", but on gibson.rit.edu it is named "www" instead.

You need to make sure that your default web root directory exists on gibson.rit.edu, and that is what we are going to do next.

This competency module is designed to allow you to demonstrate that you know how to manipulate files and directories on a remote server securely.

Instructions


Log on to the Server

Use ssh to log on to the server like this:

  ssh username@gibson.rit.edu

(replacing username with your DCE username, which is usually three letters followed by four digits)

[ ] Logged on using ssh

Check for or Create Web Root

Check to see if you already have a web root directory by issuing the command:

  ls -la

Look in the display which results for a directory named "www" and in all lower-case letters (yes, upper- vs lower-case does matter). You can tell if something is a directory by looking at the far-left side of the display: if you see a d as the first character of that line then it is a directory, but if you see a as the first character of that line then it is a file. Here is an example (with non-essential stuff removed):

  jeffs@sylvester [ 1 ] ssh jxsast@gibson.rit.edu
  jxsast@gibson.rit.edu's password: 
  jxsast@gibson [101] ls -la
  [snip]
  -rw-r--r--   1 jxsast   faculty       61 Feb 21  2004 springtime.txt
  drwxrwxr-x   2 jxsast   faculty     8192 Dec 17  2003 tmp
  drwxr-xr-x   4 jxsast   faculty     8192 Jan  5  2004 www
  jxsast@gibson [102]

Note how the listing for "www" starts with the letter "d" on the far left. That indicates it is a directory. Notice how the listing for "springtime.txt" starts with a – on the far left. That indicates it is a file.

If you do not see a "www" directory listed, then you need to create one. Issue the following command to create it:

  mkdir www

[ ] Verified www directory exists or created it

Then check to make sure it was created and what permissions it has by issuing the ls -la command again. It should have rwx permissions for the user who owns it (that is you), and r-x permissions for the group who owns it and for "other" (everybody else). The easy way to give these permissions is by issuing the following two commands:

  chmod u+rwx www
  chmod go+rx www

The first command adds read, write, and execute permissions for user. The second command adds read and execute permissions for group and other. Check it again with the ls -la www command. It should look like this now:

  drwxr-xr-x   4 yourDCEusername   yourGroup     8192 Jan  5  2004 www

(replacing "yourDCEusername" with your real username, and replacing "yourGroup" with your real group)

What if someone has permissions you do not want them to have? For example, what if "other" has write permissions, and you want to remove them? you would issue the following command to remove write permissions from group and other:

  chmod go-w www

[ ] Set correct permissions for www directory

Create a Directory for Class Websites

You need to create a directory named "imm" below your www directory. use the cd command to change directories into "www". Now create a directory in there called "imm" using the mkdir command, and insure it has the right permissions (rwx for you, rx for group and other) using the chmod command.

[ ] Created imm directory

[ ] Set correct permissions for imm directory

Create Directories for Class Projects and Media

You need to create five (5) subdirectories under your www/imm directory:

  1. media
  2. project01
  3. project02
  4. project03
  5. project04

[ ] Created all 5 directories

And now you need to set the permissions the same as above: rwx for you and rx for everybody else

[ ] Set correct permissions for all five directories

Moving and Copying Files

You will often need to either copy files and directories from one place to another, or move files from one place to another. The cp command is for copying files and directories (copying leaves the original in place), and the mv command is for moving files and directories (moving does not leave the original in place).

Moving Files and Directories

Use pico or some other editor to create a file called "foo.txt" in the project01 directory. Show it to the TA or Lab Assistant, and then use the mv command to move it to your project02 directory with just one command.

[ ] Create foo.txt in www/imm/project01

[ ] Moved foo.txt to www/imm/project02 using one command

Remember that "." refers to the current directory, and that ".." refers to the parent of the current directory

Copying Files and Directories

Now use the cd command to move from the current directory to www/imm/project02 with one command.

[ ] Changed to www/imm/project02 using one command

Now use the cp command to put a copy of "foo.txt" in your www/imm/project03 directory

[ ] Copied foo.txt to www/imm/project03 using one command

Valid HTML 4.01 Strict Valid CSS! Cynthia Tested! unique visitor counter