Introduction

Introduction

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 components of the operating system, and thus it is very useful to have at least a cursory understanding of it.

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 name of the file, its size , the file's location on the device, the most recent access and update times , the file's (numeric) owner and group id s, access permissions , and a pointer to the first block of data the file contains.

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 next to each other; the data for a single file is usually scattered all around the file system. Of course, all of this scattering is invisible to the user, who sees only a single file.

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 potentially be used on your own files, but to use them on someone else's files, you need to have superuser privileges.

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), preserving permissions.

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.

symlinks

Scan a directory for symbolic links.

touch

Update access times or, potentially, create a file.

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net