Archive for the 'General' Category

SBDavid

Viewing file statistics

stat - display file or file system status

The stat command provides a complete rundown of the status of a file on the filesystem:

With no option, `stat’ reports all information about the given files. But it also can be used to report the information of the file systems the given files are located on. If the files are links, `stat’ can also give information about the files the links point to.

root@dell:~# stat hdd
File: `hdd’
Size: 384 Blocks: 8 IO Block: 4096 regular file
Device: 802h/2050d Inode: 1358293 Links: 1
Access: (0644/-rw-r–r–) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2010-01-10 17:00:07.000000000 +0530
Modify: 2009-08-01 09:08:16.000000000 +0530
Change: 2009-08-01 09:08:16.000000000 +0530

The results from the stat command show just about everything you’d want to know about the file being examined, even down the major and minor device numbers of the device where the file is being stored.

SBDavid

The core GNU utilities

The core GNU utilities.

The GNU project was mainly designed for Unix system administrators to have a Unix-like environment available. This focus resulted in the project porting many common Unix system command line utilities. The core bundle of utilities supplied for Linux systems is called the coreutils package.

The GNU coreutils package consists of three parts:

Utilities for handling files
Utilities for manipulating text
Utilities for managing processes

$ apt-cache search coreutils
bsdmainutils - collection of more utilities from FreeBSD
coreutils - The GNU core utilities

These three main groups of utilities each contain several utility programs that are invaluable to the Linux system administrator and programmer.

SBDavid

Major and Minor device number

major and minor device number

Linux creates special files, called nodes, for each device on the system. All communication with the device is performed through the device node. Each node has a unique number pair that identifies it to the Linux kernel. The number pair includes a major and a minor device number. Similar devices are grouped into the same major device number. The minor device number is used to identify a specific device within the major device group. This is an example of a few device files on a Linux server:

root@dell:/dev# ls -al sda* ttyS*
brw-rw—- 1 root disk 8, 0 Feb 8 07:12 sda
brw-rw—- 1 root disk 8, 1 Feb 8 07:12 sda1
brw-rw—- 1 root disk 8, 2 Feb 8 07:12 sda2
crw-rw—- 1 root dialout 4, 64 Feb 8 07:12 ttyS0
crw-rw—- 1 root dialout 4, 65 Feb 8 07:12 ttyS1
crw-rw—- 1 root dialout 4, 66 Feb 8 07:12 ttyS2
crw-rw—- 1 root dialout 4, 67 Feb 8 07:12 ttyS3

The fifth column is the major device node number. Notice that all of the sda devices have the same major device node, 8, while all of the ttyS devices use 4. The sixth column is the minor device node number. Each device within a major number has its own unique minor device node number.

The first column indicates the permissions for the device file. The first character of the permissions indicates the type of file. Notice that the SCSI hard drive files are all marked as block (b) device, while the COM port device files are marked as character (c) devices.

SBDavid

Hardware devices as special files

The Linux system identifies hardware devices as special files, called device files. There are three
different classifications of device files:

? Character
? Block
? Network

Character device files are for devices that can only handle data one character at a time. Most types
of modems and terminals are created as character files. Block files are for devices that can handle
data in large blocks at a time, such as disk drives.

The network file types are used for devices that use packets to send and receive data. This includes network cards and a special loopback device that allows the Linux system to communicate with itself using common network programming protocols.

SBDavid

/etc/inittab parent of all processes

Init is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab.

Some Linux implementations contain a table of processes to start automatically on bootup. On Linux systems this table is usually located in the special file /etc/inittab.

The Linux operating system uses an init system that utilizes run levels. A run level can be used to
direct the init process to run only certain types of processes, as defined in the /etc/inittab file. There are five init run levels in the Linux operating system.

At run level 1, only the basic system processes are started, along with one console terminal process. This is called single user mode. Single user mode is most often used for emergency filesystem maintenance when something is broken. Obviously, in this mode only one person (usually the
administrator) can log in to the system to manipulate data.

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

« Prev - Next »