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.

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.

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.

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.

Shared Memory Pages

Shared Memory Pages

To facilitate data sharing, you can create shared memory pages. Multiple processes can read and write to and from a common shared memory area. The kernel maintains and administers the shared memory areas and allows individual processes access to the shared area.

The special ipcs command allows you to view the current shared memory pages on the system. Here’s the output from a sample ipcs command.

root@dell:~# ipcs -u

—— Shared Memory Status ——–
segments allocated 6
pages allocated 576
pages resident 528
pages swapped 0
Swap performance: 0 attempts 0 successes

—— Semaphore Status ——–
used arrays = 0
allocated semaphores = 0

—— Messages: Status ——–
allocated queues = 0
used headers = 0
used space = 0 bytes

Each shared memory segment has an owner that created the segment. Each segment also has a standard Linux permissions setting that sets the availability of the segment for other users. The key value is used to allow other users to gain access to the shared memory segment.

-m shared memory segments

root@dell:~# ipcs -m

—— Shared Memory Segments ——–
key shmid owner perms bytes nattch status
0×00000000 327680 buddy 600 393216 2 dest
0×00000000 360449 buddy 600 393216 2 dest
0×00000000 262146 buddy 600 393216 2 dest
0×00000000 294915 buddy 600 393216 2 dest
0×00000000 393220 buddy 600 393216 2 dest
0×00000000 425989 buddy 600 393216 2 dest

Next »