Email web hosting - CHAPTER 14 UNDERSTANDING LINUX FILES AND USERS
CHAPTER 14 UNDERSTANDING LINUX FILES AND USERS 225 Table 14-2. File Type Codes Code File Type p Named pipe (a file that acts as a conduit for data between two programs) s Socket (a file designed to send and receive data over a network) c Character device (a hardware device driver, usually found in /dev) b Block device (a hardware device driver, usually found in /dev) As you might remember from Windows, programs are stored as files on your hard disk, just like standard data files. On Linux, program files need to be explicitly marked as being executable. This is indicated in the permission listing by an x. Therefore, if there s no x in a file s permissions, it s a good bet that the file in question isn t a program or script (although this isn t always true for various technical reasons). To make matters a little more confusing, if the entry in the list of files is a directory (indicated by a d), then the rules are different. In this case, an x indicates that the user can access that directory. If there s no x, then the user s attempts to browse to that directory will be met with an access denied message. File permissions can be difficult to understand, so let s look at a few real-world examples. These examples assume that you re logged in to Linux as the user keir. LESS COMMON FILE TYPES Instead of the x in the list of permissions for a directory, you might sometimes see a t. This means that the only people who can delete or alter a file in that directory are the users who created the file in the first place. This is a useful option to have in some circumstances. You might sometimes see a set of permissions like rws. The s stands for setuid. Like x, it indicates that the file is executable, except, in this case, it means that the file will be run with the permissions of the person who owns it, rather than the user who is executing it. In other words, if user frank tries to run a program owned by keir that has the execute permission set as s, that program will be run as if keir were running it. This is very useful, because it can make programs that require root powers usable by ordinary users, although this brings with it obvious security risks. Typical Data File Permissions Here s the first example: -rw-rw—- 2 keir keir 1450 2004-07-07 09:19 myfile2 You see immediately that this file is owned by user keir because that username appears directly after the permissions. You also see that this user is a member of the group keir.