Finding out who owns what

Your first step in changing ownership and permissions is to find out who owns which files. You'll need this information to find out whether you can make changes to the permissions.

To find out who owns what:

1.
cd

At the shell prompt, type cd to return to your home directory.

2.
ls -l

Enter ls -l to see the long listing of the files in the current directory (see Code Listing 5.1).

The left column contains nine characters that specify permissions for each file:

Code Listing 5.1. Many systems use only a few group names to allow easy file sharing and collaboration.
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

  • 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.

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 of the files. Most of the files are associated with the users group, while just a few directories are associated with the www group.

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.

3.
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.


Tip

Sometimes you'll see references to world-readable or world permissions. This is the same as other. "Other" just refers to not you, not the group, but anyone else.


Tip

Note that the ftp directory line shown in Code Listing 5.1 is a little unusual. It's a link, as discussed in Chapter 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]$

Code Listing 5.3. You'll find tons of information in /etc/passwd, including your default group number.
[ejr@hobbes permissions]$ grep ejr
   /etc/passwd
ejr:aag2.UyC7yJWE:500:500:Eric J. 
   Ray:/home/ejr:/bin/bash
[ejr@hobbes permissions]$

Code Listing 5.4. The group file lists groups and additional members (as shown in the users group).
[ejr@hobbes permissions]$ cat /etc/group
kmem::9:
wheel::10:root,ejr
mail::12:mail
news::13:news
uucp::14:uucp
man::15:
games::20:
gopher::30:
dip::40:
ftp::50:
nobody::99:
users::100:ejr,deb,asr,awr
floppy:x:19:
pppusers:x:230:
popusers:x:231:
slipusers:x:232:
postgres:x:233:
ejr:x:500:
bash:x:501:
csh:x:502:
asr:x:503:
awr:x:504:
deb:x:505:
[ejr@hobbes permissions]$

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.78.106