How do I find out more information about block devices?

last updated in Categories

You need to use blkid command to find out more information about block devices. It is a command-line utility to display block device attributes such as :
* Device name
* Its type
* Metadata

Typical entry looks as follows:
/dev/hdb5: UUID=”1c255a8d-9e55-4a23-9910-54d89a6369cc” SEC_TYPE=”ext2″ TYPE=”ext3″

To display information about all block devices simply type command (login as a root user):

# blkid


/dev/hdb5: UUID="1c255a8d-9e55-4a23-9910-54d89a6369cc" SEC_TYPE="ext2" TYPE="ext3"
/dev/hdb3: LABEL="RockSolidStorage" UUID="2dc96c9a-d214-4c3c-8c8c-295aec0ac314" SEC_TYPE="ext2" TYPE="ext3"
/dev/hdb1: LABEL="/" UUID="7a965fb9-bf9e-4ed5-8a01-321386b843d9" SEC_TYPE="ext2" TYPE="ext3"
/dev/cdrom: LABEL="AHSAN2000" TYPE="iso9660"
/dev/hda1: LABEL="/1" UUID="25498633-a626-49b0-88dc-ac33cabec7aa" SEC_TYPE="ext2" TYPE="ext3"
/dev/hdb2: TYPE="swap"
/dev/sda: UUID="f8999dde-d28f-4ae9-8d25-e9d6544e3698" SEC_TYPE="ext2" TYPE="ext3"

How do I find out more information about ext3 or ext2 file system?

last updated in Categories

You need to use a command called dumpe2fs. It displays lots of useful information about your ext2 or ext3 file system. General syntax is as follows:
dumpe2fs /dev/device

It displays following type of information:

  1. Filesystem volume name
  2. Last mounted on
  3. Filesystem features: has_journal ext_attr filetype needs_recovery sparse_super
  4. Default mount options
  5. Filesystem state
  6. Filesystem OS type
  7. Information about blocks etc

For example, display information about /dev/hdb1

$ dumpe2fs /dev/hdb1


Filesystem volume name:   /
Last mounted on:          
Filesystem UUID:          7a965fb9-bf9e-4ed5-8a01-321386b843d9
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr filetype needs_recovery sparse_super
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              2443200
Block count:              4883752
Reserved block count:     244187
Free blocks:              677028
Free inodes:              2063116
First block:              0
Block size:               4096
Fragment size:            4096
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16288
Inode blocks per group:   509
Last mount time:          Thu Mar 16 23:25:43 2006
Last write time:          Thu Mar 16 23:25:43 2006
Mount count:              20
Maximum mount count:      30
Last checked:             Sun Mar 12 01:16:43 2006
Check interval:           0 ()
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
First orphan inode:       782426
Journal backup:           inode blocks
Group 0: (Blocks 0-32767)
 Primary superblock at 0, Group descriptors at 1-2
 Block bitmap at 3 (+3), Inode bitmap at 4 (+4)
 Inode table at 5-513 (+5)
 93 free blocks, 15966 free inodes, 8 directories
 Free blocks: 8844-8855, 9099-9126, 9129-9137, 9139-9142, 9146-9151, 9154-9155, 9158-9165, 9170, 9172, 9174-9176, 9178-9179
, 9182-9189, 9191, 9193, 9196-9197, 9200-9204
 Free inodes: 114, 126-164, 172, 362-547, 549-589, 591-16288
Group 1: (Blocks 32768-65535)
 Backup superblock at 32768, Group descriptors at 32769-32770
 Block bitmap at 32771 (+3), Inode bitmap at 32772 (+4)
 Inode table at 32773-33281 (+5)
 6250 free blocks, 13747 free inodes, 143 directories
 Free blocks: 38912-38919, 56874-57138, 57141-57343,

Scripting: How do I process accounting file /var/account/pact?

last updated in Categories

The file /var/account/pacct can not be used directly as it does not store accounting data in clear text format. Each time a process terminates a record for this process is appended to the accounting file.

In order to use this file to generate customize report from perl or shell script you need to convert this file in text format. You need to use dump-acct command which print an acct/pacct file in human-readable format.

# dump-acct /var/account/pacct

All fields are separated by vertical line. Fields are: command, user time, system time, effective time, uid, gid, memory, io, time. To print username and command you can use awk command in pipe as follows:

# dump-acct /var/account/pacct | awk -F’|’ ‘{ print $1 ” = ” $5 }’

Please note that to print an utmp file in human-readable format use command dump-utmp as follows:

# dump-utmp /var/log/wtmp

How do I list files inside compressed tar ball (gzip’d tar’d) archive?

last updated in Categories

Tar command provides the option to list files inside compressed tar ball. However mtools includes command called lz which gunzips and shows a listing of a gzip’d tar’d archive without extracting files.

For example, display listing of file called backup.tar.gz type command:

$ lz backup.tar.gz

As you see lz provides a listing of a gzip’d tar’d archive, that is a tar archive compressed with the gzip command. It is not strictly necessary on Debian GNU/Linux (or other Linux/BSD/Solaris oses), because the GNU tar(1) program provides the same capability with the command:

$ tar -tzf backup.tar.gz