339
Chapter 21:
Introduction to Linux Systems Administration
The three identifying traits of a block device are that it has a major number, has a
minor number, and when viewed using the ls -l command, shows the first character of
the permissions to be a b. Here's an example:
[root@ford /root]# ls-l /dev/sda1
brw-rw----
1 root
disk
8,
1
2009-04-10
/dev/sda1
In this case, the b is at the beginning of the file's permissions, the 8 is the major
number, and the 1 is the minor number. The significance of the major number is that
it identifies which device driver the file represents. When the system accesses this file,
the minor number is passed to the device driver as a parameter to tell the driver which
device it is accessing. (For example, if there are two serial ports, they will share the
same device driver and thus the same major number, but each serial port will have a
unique minor number.)
The distinguishing characteristics of a character device are that its permissions start
with a c, and the device has a major and minor number. Here's an example:
[root@ford /root]# ls -l /dev/ttyS0
crw-------
1
root
tty
4,
64
May
5
1988
/dev/ttySo
You can tell that a file is a named pipe by the fact that the first character of its file
permissions is a p, as in the following example:
[root@ford /root]# ls-l mypipe
prw-r--r--
1 root
root
0
June
16
10:47
mypipe
chown: Change Ownership
The chown command allows you to change the ownership of a file to someone else.
Only the root user can change this ownership. (Normal users may not "give away" or
"steal" ownership of a file from another user.) The format of the command is as follows:
[root@ford /root]# chown [-R] username filename
where username is the user's login to which you want to change the ownership and
filename is the name of the file that will have its ownership changed. The filename may
be a directory as well.
The -R option applies when the specified filename is a directory name. It tells
the command to descend recursively through the directory tree and apply the new
ownership not only to the directory itself, but to all of the files and subdirectories
within it.
chgrp: Change Group
chgrp
is another command-line utility that allows you to change the group settings of
a file. The command works in much the same way as chown does. The format of the
command is as follows:
[root@ford /root]# chgrp [-R] groupname filename