Part 1: System Structures
Introduction
Related Files
Commands
In the Linux environment, a file is defined by its
inode
. Although most users never have occasion to directly access the inode, it is one of the fundamental
The inode is a data structure that contains all the information the system needs to know about a particular file. This includes a unique identifying number (the
inode number
), the
In UNIX, everything that isn't a running process is a file. Actually, there are also files corresponding to processes (see the /proc filesystem), although the classic definition of file is distinct from an executing process. The various file types are listed in Table 2-1 . The first column of the table corresponds to the letter displayed when an ls -l command is run.
Also, note that the inode does not itself contain the file's data. Instead, it contains the addresses of the disk blocks that store the data. These blocks are probably not even
Table 2-1. File Types |
||
|
Code |
Type |
Description |
|
- |
regular file |
Traditional file containing data. |
|
b |
block special file |
Block input/output access device. |
|
c |
character special file |
Raw (character-based access) device. |
|
d |
directory |
A file whose purpose is to group other files. |
|
l |
symbolic link |
A pointer to another file. |
|
p |
named pipe |
first-in/first-out interprocess communication mechanism. |
|
s |
socket |
Interprocess communication mechanism associated with a port. |
Note that all of the commands listed next may
You will see the aforementioned properties appear in various ways throughout the following commands:
|
chgrp |
Change the group ownership of the file. |
|
chmod |
Change the mode (access permissions) of the file. |
|
chown |
Change the owner of the file. |
|
cksum |
Calculate the checksum of the file. |
|
cp |
Copy the file. |
|
dd |
Copy file and possibly fiddle with the format. |
|
file |
Determine file type. |
|
install |
Copy file(s),
|
|
ln |
Create a link to a file. |
|
lockfile |
Create a semaphore. |
|
ls |
List the contents of a directory. |
|
lsattr |
List the attributes of a file. |
|
mv |
Move a file. Note that in Linux, "moving" is equivalent to "renaming" as none of the other important file attributes (e.g., inode number, size, access time) are changed. |
|
pathchk |
Check filename for portability. |
|
rm |
Remove (delete) a file. |
|
stat |
Display the contents of the file's inode. |
|
sum |
Calculate a checksum. |
|
|
Scan a directory for symbolic links. |
|
touch |
Update access times or, potentially, create a file. |
|
/etc/passwd |
Contains the
|
|
/etc/
|
Contains the group names and ids referenced by the inode. |