Unix file and directory names are case sensitive, i.e., joe.txt and Joe.txt are two different files.Generally, you will spare yourself a lot of grief if you always use lowercase file and directory names, especially among your Web pages.
Your home directory is the directory you are sent to when you login to the Unix host. For most Webtyme users it is: /usr/your_login_name Or: /usr2/your_login_name
By entering "cd $home" at the Unix prompt, you'll be taken to your home directory.When we speak of a Web server's root directory, we are talking about the directory that contains the home page as well as other Web files and sub-directories. For most Webtyme users it is: /usr/your_login_name/public_html Or: /usr2/your_login_name/public_html
The Unix command ls will list the contents of a directory. If you enter "ls -alF" at the prompt, it will display a complete listing of files and directories and their corresponding persmissions.Here is an example of a display from "ls -alF" in the home directory of user "hank".
-rw-r--r-- 1 hank client 144 Oct 30 12:31 .profile drwx------ 2 hank client 512 Nov 9 13:54 Mail/ -rw-r--r-- 1 hank client 39 Feb 14 14:28 ed -rwxr-xr-x 1 hank client 159 Dec 21 12:01 egg.pl* drwx--x--x 19 hank other 1024 Apr 9 21:19 public_html/Using the ls "-l" option lists the contents in a long format.The first column shows the mode, "don" is the owner, client the group, next is the size in bytes, then the last modified date, and last, the file name.
Files that begin with a "." are hidden files, they only show up with ls when the "-a" option is used.
The "d" in the very first mode column of Mail denotes a directory.
Using the ls "-F" option adds the "/" at the end of directory names and a "*" at the end of executable files, like egg.pl in the example above.
So "ls -alF" asks for a long listing of the current directory that includes hidden files and denotes directories and executable files.
The mode of the file tells us the current status of the file's permissions. The permissions determine who is allowed to read, write to or execute a file.This is a mode with all the bits set: drwxrwxrwx
As mentioned above the "d" signifies that this is a direcory: d---------
The next three are the permissions for the owner, in this case user "don": -rwx------
The next three are the permissions for other members of the group: ----rwx---
The last three are the permissions for the all other users: -------rwx
Group's will generally not be used and these permissions can be the same as those for all other users.
Here is our example directory again:
-rw-r--r-- 1 hank client 144 Oct 30 12:31 .profile drwx------ 2 hank client 512 Nov 9 13:54 Mail/ -rw-r--r-- 1 hank client 39 Feb 14 14:28 ed -rwxr-xr-x 1 hank client 159 Dec 21 12:01 egg.pl* drwx--x--x 19 hank other 1024 Apr 9 21:19 public_html/The first file, .profile, is readable and writeable by the owner, but only readable by others. This means that other users cannot edit, append or replace this file.
The directory Mail is readable, writeable and executable by the owner. A directory must be set to executable in order to see it's contents. In this case, no one but the owner is allowed to see the contents of Mail.
The directory public_html is where the Web pages reside and this MUST be executable by everyone.
When files and directories are created, they have the default permissions. Usually -rw-r--r-- for files and drwxr-xr-x for directories.You need to use the Unix command chmod to change permissions.
The easiest usage is "chmod ### filename". Where "###" are three numbers, each representing the permissions for user, group and all others respectively.
These numbers are determined by adding 4 for readable, 2 for writeable and 1 for executable.
Therefore, "chmod 777 filename" makes the file readable, writeable and executable by owner, group and everyone else.
And "chmod 744 filename" makes the file readable, writeable and executable by owner, but just readable by group and everyone else.
Here are the chmod commands that would set our example files to their permissions:
-rw-r--r-- .profile "chmod 644 .profile" drwx------ Mail/ "chmod 700 Mail" -rw-r--r-- ed "chmod 644 ed" -rwxr-xr-x egg.pl* "chmod 755 egg.pl" drwx--x--x public_html/ "chmod 711 public_html"
See Also: Unix commands