Your first step in changing ownership and permissions is to find out who owns which files. You'll need this information to find out if you can make changes to the permissions.
To Find Out Who Owns What:
At the shell prompt, type cd to return to your home directory.
Enter ls -l to see the long listing of the files in the current directory. (See Code Listing 5.1.)
Code Listing 5.1. Many systems use only a few group names to allow easy file sharing and collaboration.
The left column contains ten characters, the last nine of which specify permissions for each file:
xmission> cd /home/users/e/ejray xmission> ls -l total 60 drwx-x-x 2 ejray users 512 Jul 21 13:32 Complete/ drwx-x-x 2 ejray users 512 Jun 24 09:23 Completed/ drwx-x-x 2 ejray users 512 Sep 15 1997 Mail/ drwx-x-x 2 ejray users 512 Jun 24 09:35 NewProject/ drwx-x-x 2 ejray users 512 Sep 15 1997 News/ drwx-x-x 2 ejray users 512 Sep 15 1997 access/ -rw---- 1 ejray users 163 Jul 22 07:28 bogus2 drwxrwx-x 2 ejray www 512 Jul 24 04:44 chat.conf/ -rw---- 1 ejray users 853 Sep 13 1997 dead.letter -rw---- 1 ejray users 14286 Jun 28 12:40 files lrwxrwxrwx 1 ejray users 27 Sep 15 1997 ftp -> /home/ftp/pub/users -rw---- 1 ejray users 36 Jul 24 12:09 limerick drwx-x-x 2 ejray users 512 Jun 8 13:32 mail/ drwxr-s-x 15 ejray www 2560 Jul 10 10:30 public_html/ drwx-x-x 2 ejray users 512 Jul 22 08:23 puppy/ drwx-x-x 2 ejray users 512 Jul 24 04:44 temp/ -rw---- 1 ejray users 0 Jul 19 13:24 testme
The two columns in the middle indicate the file's owner (in all likelihood your userid, for this example) and the group membership for the file. In Code Listing 5.1, ejray is the owner of all the files. Most of the files are associated with the users group, while just a few directories are associated with the www group.
r means read permission, w means write permission, and x means execute permission.
The first set of rwx is for the user, the second set is for the group, and the last set is for other.
A dash (-) instead of a letter indicates that the user/group/other does not have that level of permission. For example, rwx--- would mean that the user has read, write, and execute permission, while group and other have no permissions at all.
On this system, files that individual users create are associated with the user's group, while files destined for the Web have www group associations. On other systems, the default group for files might be a group with the same name as the userid, as shown in Code Listing 5.2.
Code Listing 5.2. Sometimes the group name and user name are the same, depending on how the system was set up.
[ejr@hobbes permissions]$ ls -l total 152 -rw-rw-r- 1 ejr ejr 128889 Jul 24 14:33 sage.sayings -rw-rw-r- 1 ejr ejr 23890 Jul 24 14:33 sayings [ejr@hobbes permissions]$
ls -l /etc
You can also use the ls -l command on a system directory, such as /etc. Here, you'll see that most of the files are owned by root, possibly with a variety of different group memberships (see Figure 5.1).
Figure 5.1. Most of the files in /etc are owned by root.
Sometimes you'll see references to world-readable or world permissions. This is the same as other. "Other" just refers to anyone who is not you or not in the group.
You might also hear of s or SetUID permissions, which indicate that the program or file can run with the effective userid of the file's owner (usually root). For example, /usr/bin/passwd has s permissions because you can run passwd to change your password, but the command needs to run as root to actually modify the password database.
You might also see a t at the end of the list of permissions, which indicates that the sticky bit is set. Setting the "sticky bit" means primarily that, in a shared directory, you can delete only your own files (and not accidentally delete files belonging to others).