Top 10 Awesome Linux Screen Tricks

3) Triple monitoring in screen

tmpfile=$(mktemp) && echo -e 'startup_message offnscreen -t top  htopnsplitnfocusnscreen
-t nethogs nethogs  wlan0nsplitnfocusnscreen -t iotop iotop' > $tmpfile &&
sudo screen -c $tmpfile

This command starts screen with ‘htop’, ‘nethogs’ and ‘iotop’ in split-screen. You have to have these three commands (of course) and specify the interface for nethogs – mine is wlan0, I could have acquired the interface from the default route extending the command but this way is simpler.

htop is a wonderful top replacement with many interactive commands and configuration options. nethogs is a program which tells which processes are using the most bandwidth. iotop tells which processes are using the most I/O.

The command creates a temporary “screenrc” file which it uses for doing the triple-monitoring. You can see several examples of screenrc files here: http://www.softpanorama.org/Utilities/Screen/screenrc_examples.shtml

Create A File And Loop It As A Filesystem in Linux

$ dd if=/dev/zero of=/mnt/point1/file.img bs=1k count=1000
1000+0 records in
1000+0 records out
$ losetup /dev/loop1 /mnt/point1/file.img
$ mke2fs -c /dev/loop1 1000
mke2fs 1.35 (28-Feb-2004)
max_blocks 1024000, rsv_groups = 125, rsv_gdb = 3
Filesystem label=

$ mkdir /mnt/point2
$ mount -t ext2 /dev/loop1 /mnt/point2
$ ls /mnt/point2
lost+found
$ ls /mnt/point1
file.img lost+found