University of Louisville -- dare to be great

Skip Navigation

Data Center Services
Home Page

Web Documentation

IT Home

Accounts

Services

Policies

Major Initiatives

News

Units

Contact

Unix for Web Publishers


File Systems

All Unix machines (including athena) store data much like regular PC and MAC operating systems. Both use files and directories containing files. The main differences are that people log on to athena over the network to browse its hard drives instead of sitting right in front of the machine, and that the hard drives are laid out differently. Everything in Unix starts at the root directory or slash (/'). This kind of equates to c:\ (on a PC) or the desktop (on the Macintosh). There are many directories off of this directory. Each directory has an owner and group to which it belongs. Most of the system level stuff belongs to a user called root. This is the system administrator account from which the Unix system is configured and maintained. The critical directories for web publishers to use are ~/www' and /www'. These are where group and individual pages are stashed. The tilde tells Unix that you are referring to your home directory (kind of like the root folder of your own personal hard drive). Any time you type "cd ~" athena will take you to your home directory (cd means change directory). Any time you type "cd /www" athena will take you to the folders which contain UofL's web site. If you have a departmental site that is found at http://www.louisville.edu/it/ktln, then "cd /www/it/ktln" would take you to the directories in which your site is housed. If you want to work on files addressed by http://www.louisville.edu/~userid01/test/files, and you are userid01, then "cd ~/www/test/files" will take you to the page you want to work on.

Key things to remember:
  • http://www.louisville.edu/blah/blahblah/ is really /www/blah/blahblah when logged into athena.
  • http://www.louisville.edu/~jcschmoe01/stuff/more_stuff is really ~jcschmoe01/www/stuff/more_stuff on athena or ~/www/stuff/more_stuff if you happen to be jcschmoe01.

Getting around in File Systems

The `cd' and `ls' commands are the keys to navigating Unix. The `cd' command enables one to change the current directory they are working on to another. The `ls' command tells you what's in the current directory. Typing `cd' by itself is always a quick way to get back to the home directory of your account. "cd [any_directory]" will change the directory to wherever you want to go (as long as it exists). Typing `ls' by itself will give a short listing of the stuff in the current directory. "ls -l" will give a longer listing including the type and permissions. This is important in understanding which things are files and which are directories. It is also important in understanding who can read and write to those files. Groups with multiple people editing their pages will have to learn a bit more about Unix permissions to ensure that they can edit their page while everyone else in the world cannot.

For example, if one logged in and typed "ls -l" the output might look like:
     drwx------   6 khhaga01 it    2048 Sep 16 12:36 Mail
     drwx------   2 khhaga01 it      96 Apr 22  1995 News
     drwxr-xr-x   6 khhaga01 it    3072 Sep 13 13:07 bin
     -rw-------   1 khhaga01 it    4111 Mar 17  1996 country.txt
     -rw-r--r--   1 khhaga01 it   24615 Apr  1 15:03 internet.txt
     drwx--x--x  18 khhaga01 it    5120 Sep  5 15:34 www
Looking at the listing above will show the basics behind navigating Unix.
     drwx--x--x  18 khhaga01 it    5120 Sep  5 15:34 www
     |\ /\ /\ /  |  \      / \/    \  / \          / \  /
     | |  |  |   |   owner   group size date changed  name
     | |  |  |   |
     | |  |  |   Number of directories within this file/directory
     | |  |  |
     | |  |  Everyone else's rights
     | |  |
     | |  Group's rights
     | |
     | Owner's rights
     |
     File type

Mail, News, and www all began the line with a "d". That means that they are directories. The items that begin with "-" (a dash) are simply files. The next nine characters of the line are the permissions. It is important to understand the basics of what they mean. The first three characters are for the owner of the file (in this case "khhaga01"), the next three are for the group ("it" in this case), and the last three for none of the above (neither "khhaga01" nor anyone in "it"). When a character is a dash, it means that that feature is turned off. For example, the Mail and News directories can only be read (hence the r), written to (the w), or executed (directories need this x to appear for anyone to be able to get into them) by khhaga01. This is good since I don't want anyone else reading my mail. The bin directory lets other people come in and read what's in there, while the www directory only lets people get in but not read. The www directory must look at least like the one above to serve web pages! Files in the www directory must look at least like the internet.txt file to be served as web pages! To change the stuff that appears when we do an "ls -l", we need to use the chmod command. Chmod has four parts to it when used:

      chmod [who][plus or minus][what] [where]

  • The who part can be:
    • u (user)
    • g (group)
    • o (other - neither user nor group)
    • a (all - everybody)
  • The plus or minus part can be + or -.
  • What can be:
    • r (read)
    • w (write)
    • x (execute)
  • Where means the files or directories you are working on.

Chmod for those using an FTP program

Chmod can also be run from most FTP clients to enable people to change file permissions without logging in to the Unix shell. This is done with binary numbers that can seem intimidating at first, but are easy to jot down or remember. The basic rule of thumb is that every file has three numbers for its permissions all seven or below. The first number is for user, the second for group, and the third for none of the above. The way the numbers are added is as follows:

     +------------------ 0400  read by owner 
     | +---------------- 0200  write by owner 
     | | +-------------- 0100  execute/search by owner
     | | | +------------ 0040  read by group 
     | | | | +---------- 0020  write by group 
     | | | | | +-------- 0010  execute/search by group
     | | | | | | +------ 0004  read by others 
     | | | | | | | +---- 0002  write by others 
     | | | | | | | | +-- 0001  execute/search by others
     | | | | | | | | |
     r w x r w x r w x

If one adds all of the numbers for user, all of the numbers for group, and all of the numbers for other, one comes up with 777. When a certain permission is to be left off, simply subtract that number. A better www directory permission would be:

      chmod 755 www 

That would remove write permissions for everyone but the owner.

Common Settings to remember:

      chmod 644 (FILE_NAME) -- will make a file world readable, owner writeable.
      chmod 744 (FILE_NAME) -- good for web pages with counters/footers/special stuff
      chmod 755 (DIRECTORY_NAME) -- makes a directory readable for everyone.
      chmod 711 (DIRECTORY_NAME) -- makes a directory usable for the web but not searchable.

Settings for those creating unit/departmental pages

      chmod 664 (FILE_NAME) -- makes a file world readable, user/group writeable.
      chmod 764 (FILE_NAME) -- Same as above, but also leaves room for includes.
      chmod 2775 (DIRECTORY_NAME) -- makes a directory for group write/edit and world read.
      chmod 2771 (DIRECTORY_NAME) -- same as above but other users cannot browse the contents of the directory.


MAC Users using FTP

Macintosh users using Fetch to FTP their files up to athena can set permissions by selecting the file on athena (in the Fetch window) and then selecting "Change Permissions" from the Remote menu in Fetch. Fetch will then present an array of select boxes from which the user can select the appropriate permissions. Logging in through the shell may still be necessary to set directory permissions for departmental/unit pages. This is only necessary when creating new directories, however.


The umask command

For those tired of changing the permissions on every single file uploaded to athena, the umask command can be handy. One's umask is magical number that is subtracted from 777 to set the permissions for all new files created. When one changes a umask, all new files have those new permissions. Typing umask by itself will reveal one's current umask. To change it, simply type:

      umask ###

Where ### is a string of numbers. Be careful with umask since one can prevent even a file's owner from being able to open it with a prohibitive umask like 777. A very common umask for those using athena just for web pages is 002. This will make all new directories rwxrwxr-x and all new files rw-rw-r--. Athena assumes that the user does not want all new files to be executable and strips that bit off.

WS_FTP (the ftp program in ULNET software) users can set their umask in the session settings for Athena. There are step by step instructions about this here.


MAC Users using FTP

Fetch allows users to set a umask at the beginning of the session. To do this, one should simply click on "Set Upload Permissions" in the remote menu before any files have been uploaded. This will give all uploaded files the same permissions for that session of Fetch. This can save time during large site updates.


Creating/editing files and making new directories

Once navigation, changing permissions, and getting listings seems to be tolerable, one can begin easily creating files and directories. The mkdir command creates a directory wherever you tell it to. The ee command will create a new file or open an existing file and let you edit it. Hitting [escape] in ee brings up the menu of commands and a means of exiting the program. If ee is no fun as an editor, pico, emacs, and vi are also available but are MUCH more cryptic than ee (pico is the easiest of the three). With any editor, simply type the editor's name and the filename and it will open the file for you.


©2006 University of Louisville. All rights reserved.

U of L Home | U of L A to Z | Contact