Archive for February, 2010

SBDavid

The gzip utility

By far the most popular file compression utility in Linux is the gzip utility. The gzip package
is a creation of the GNU Project, in their attempt to create a free version of the original Unix
compress utility. This package includes the files.

gzip for compressing files
gzcat for displaying the contents of compressed text files
gunzip for uncompressing files

These utilities work the same way as the bzip2 utilities:

The gzip command compresses every file in the directory that matches the wildcard pattern.

SBDavid

The bzip2 utility

The bzip2 utility

The bzip2 utility is a relatively new compression package that is gaining popularity, especially
when compressing large binary files. The utilities in the bzip2 package are:

bzip2 for compressing files
bzcat for displaying the contents of compressed text files
bunzip2 for uncompressing compressed .bz2 files
bzip2recover for attempting to recover damaged compressed files

By default, the bzip2 command attempts to compress the original file, and replaces it with the
compressed file, using the same filename with a .bz2 extension:

$ bzip2 iptables
$ ls -l iptables*
-rw-r–r– 1 buddy buddy 1477 Dec 15 16:48 iptables.bz2
SBDavid

The GNU long parameters

The GNU long parameters

You can combine GNU long parameters with either Unix- or BSD-style parameters to really customize your display. One cool feature of GNU long parameters with the –forest parameter. It displays the hierarchical process information, but using ASCII characters to draw cute charts:

$ ps -ef –forest |grep apache2

root 3420 1 2 08:55 ? 00:00:00 /usr/sbin/apache2 -k start
www-data 3428 3420 0 08:55 ? 00:00:00 \_ /usr/sbin/apache2 -k start
www-data 3431 3420 0 08:55 ? 00:00:00 \_ /usr/sbin/apache2 -k start
www-data 3432 3420 0 08:55 ? 00:00:00 \_ /usr/sbin/apache2 -k start
www-data 3433 3420 0 08:55 ? 00:00:00 \_ /usr/sbin/apache2 -k start
www-data 3434 3420 0 08:55 ? 00:00:00 \_ /usr/sbin/apache2 -k start

SBDavid

Peeking at the processes

Peeking at the processes

This example uses two parameters, the -e parameter, which shows all of the processes running on the system, and the -f parameter, which expands the output to show a few useful columns of information:

UID: The user responsible for launching the process
PID: The process ID of the process
PPID: The PID of the parent process (if a process is started by another process)
C: Processor utilization over the lifetime of the process
STIME: The system time when the process started
TTY: The terminal device from which the process was launched

root@dell:/etc# ps -ef |less |head -n 1
UID PID PPID C STIME TTY TIME CMD
root@dell:/etc# ps -ef |less |grep -i terminal
jyothis 3889 3271 0 08:49 ? 00:00:07 xfce4-terminal
root 4261 3996 0 09:42 pts/0 00:00:00 grep -i terminal

TIME: The cumulative CPU time required to run the process
CMD: The name of the program that was started

Using cat command to number nonempty output lines

-b, –number-nonblank
number nonempty output lines

root@dell:/etc# cat -b inittab
1 # /etc/inittab: init(8) configuration.
2 # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $

3 # The default runlevel.
4 id:2:initdefault:

-n, –number
number all output lines

root@dell:/etc# cat -n inittab
1 # /etc/inittab: init(8) configuration.
2 # $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels Exp $
3
4 # The default runlevel.
5 id:2:initdefault:

« Prev - Next »