[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest
Chapter 1 - Basic Administration


1.1 Reinstalling a wiped out GRUB

Sometimes, specially if an operating system other than GNU/Linux is installed, the Grub bootloader can be wiped out and the booting process broken. In order to fix this, we will first assume that we have the new version Grub2 installed. Afterwards we explain how to proceed for the older Grub versions.


1.1.1 Grub2 case.

Updated on January 19th, 2012.

The first step is to prepare or find a rescue Live-CD (or bootable Live-USB) so we can start our system. We should know which is the partition of the hard drive that is mounted as root partition in /. We will assume in this example that the HD where the system is installed is /dev/sda and the root partition is sda7. If we do not know this information we can retrieve it using fdisk and mount. Once the Live-CD has booted, we require to open a rescue session in the booting advanced options. We will be prompted for the root partition and we the rescue disk will open a shell with the given root partition mounted.

It is important the if the /var directory is in a partition by itself (e.g. sda8) it is also mounted as follows

      
     # mount /dev/sda7 /var

We now proceed to run dpkg-reconfigure grub-pc, and Grub2 will be reconfigured and the problem fixed.

In some cases it may be necessary to reinstall Grub in a system running with a live CD. In this case you should first mount the root partition and then install Grub using grub-install

      
     sudo grub-install /dev/sda --root-directory=/mnt
     sudo reboot

In case that the boot menu may not be the same than the previous one, after rebooting you can update it

      
     sudo update-grub

This last order is the command you need to run when you make changes in the Grub2 configuration. In this version the configuration file is not anymore in the /boot directory but in /etc: /etc/grub.cfg and /etc/grub.d/*.


1.1.2 Old Grub case.

In order to recover the old Grub version we proceed as in the previous case, booting the computer from a Live-CD or Live-USB and opening a terminal. In this terminal we launch Grub

      
     $ sudo grub

Once in the Grub application we define the root filesystem with the command root partition. Remember that root syntax for disk and partitions is hddisk,partition, and it starts counting from zero. If, as in the previous case, we assume in this example that the HD where the system is installed is /dev/sda and the root partition is sda7. Once the root partition is defined we install grub in the disk whose MBR is going to be used (sda in this case) and we quit.

      
     root (hd0,6)
     setup (hd0)
     quit

We can now reboot the computer normally. In order to recover the previous menu it could be necessary to, after rebooting, execute

      
     sudo update-grub

1.1.3 References

  1. http://sites.google.com/site/easylinuxtipsproject/grub#TOC-The-new-Grub-2-present-in-Ubuntu-9.

  1. http://sites.google.com/site/easylinuxtipsproject/oldgrub


1.2 Problem with journalizing

There could be a problem with the journalizing if an ext3 filesystem refuses to be mounted. In the following we suppose that we are mounting an ext3 filesystem associated to /dev/sdb2 in mount-point /media/usb_disk/.

      
     $ mount /media/usb_disk/
     mount: wrong fs type, bad option, bad superblock on /dev/sdb2,
            missing codepage or other error
            In some cases useful info is found in syslog - try
            dmesg | tail  or so

And in the dmesg file you will find something like

     JBD: no valid journal superblock found
     EXT3-fs: error loading journal.

In order to solve this problem first check if the filesystem can be mounted as ext2

     # mount -t ext2 /dev/sdb2 /mnt/
     # ls -a
     .  ..  lost+found  misc

If, as in the example, it works, unmount it and recreate the journal:

     # tune2fs -O ^has_journal /dev/sdb2
     tune2fs 1.37 (21-Mar-2005)
     
     # tune2fs  -j /dev/sdb2 
     tune2fs 1.37 (21-Mar-2005)
     Creating journal inode: done
     This filesystem will be automatically checked every 22 mounts or
     180 days, whichever comes first.  Use tune2fs -c or -i to override.

And now you can regularly mount the ext3 filesystem.


1.3 Labels in ext2 and ext3 units

Updated on November 21st, 2016.

The use of labels is a convenient way to handle disk units, specially for usb units that can be plugged in and removed. Instead of taking care of the dynamically associated device name the label can unambiguously identify the unit.

The command used to display and change the label name for ext2 and ext3 filesystems is e2label. The syntax of the command is such that to change or define a label named newlabel for unit device, the order issued is e2label device newlabel. For example

      
     # e2label /dev/sdb2 usb_disk

To display the label name the command is used with the device name as an argument.

      
     # e2label /dev/sdb2
     usb_disk

To define the corresponding fstab entry the following line is added to the file /etc/fstab

     LABEL=usb_disk /media/usb_disk  ext3    user,noauto     0       0

Note that the last option should be zero for removable media because if this is not the case, the booting process will be affected if the disk is not plugged in. The corresponding mount point should be defined:

     # mkdir /media/usb_disk

Now you can regularly mount the ext3 filesystem.

     $ mount /media/usb_disk

In the case of vfat partitions the equivalent command is dosfslabel, provided in the Debian package dosfstools. For example, to check and change the label of a vfat partition:

     # dosfslabel /dev/sdc1 
     LABEL
     # dosfslabel /dev/sdc1 DATA_CPB
     # dosfslabel /dev/sdc1 
     DATA_CPB

1.4 Open a xconsole as normal user

First the existence and permissions of the file /dev/xconsole has to be checked

      
     ls -l /dev/xconsole 
     prw-r-----  1 root adm 0 2006-05-02 12:40 /dev/xconsole

The user who is going to open the xconsole in his window manager (e.g. bob) has to be added to the adm group.

     adduser bob adm
     Adding user `bob' to group `adm' ...
     Done.

The xconsole program can be now normally launched

     xconsole -file /dev/xconsole

1.5 Resetting the root password

The first and simplest option is to boot in single-user mode. To do so, if the bootloader is GRUB stop the booting process and edit the line where the kernel is selected adding 1 at the end of the line. The system should boot to a root prompt and the password can be changed using the passwd command.

Another possibility is to boot using a rescue disk and once that you are at the command prompt mount the system's root directory if it has not been already mounted. For example, let's assume that the system's root partition is /dev/sda1 and will be mounted in /mnt/sysrootdir

      
     mkdir /mnt/sysrootdir
     mount /dev/sda1 /mnt/sysrootdir

Then, after switching to the system's root directory with chroot, reset the password.

     chroot /mnt/sysrootdir
     passwd

1.5.1 References

  1. Tech tip in http://www.linuxjournal.com/issue/180


1.6 Configure exim to use SMTP-TLS

The following instructions explain in a short and direct way the minimal steps necessary to include SMTP-TLS support in exim to connect with a smarthost node relaying mail. The data provided are appropriate for connecting with the server mailgw.uhu.es and for a box with Debian Lenny.

The necessary steps are the following

  1. Install packages exim4-base, exim4-config, and exim4-daemon-light.

         [root@localhost ~]# apt-get install exim4-base exim4-config \
         exim4-daemon-light
    
  1. If during the exim4 installation no question is asked or if the packages are already installed in the computer, reconfigure the mail agent:

         dpkg-reconfigure exim4-config
    

    The following answers apply to configure a box in CLGEM-UHU:

    1. mail sent by smarthost; received via SMTP or fetchmail

    1. local mail name boxname.dfa.uhu.es

    1. IP-addresses to listen on for incoming SMTP connections: 127.0.0.1

    1. Other destinations for which mail is accepted: [Blank]

    1. Machines to relay mail for: [Blank]

    1. IP address or host name of the outgoing smarthost: mailgw.uhu.es

    1. Hide local mail name in outgoing mail? Yes

    1. Visible domain name for local users: [Blank]

    1. Keep number of DNS-queries minimal (Dial-on-Demand)? No

    1. Delivery method for local mail: mbox format in /var/mail/

    1. Split configuration into small files? Yes

  1. The next step is the generation of the necessary keys.

         # cd /etc/exim4/ 
         # openssl req -x509 -newkey rsa:1024 -keyout rsa.key -out rsa.cert \
         -days 9999 -nodes
         # openssl dhparam -out dh.key 1024
    
  1. Enable TLS in exim's configuration editing the file

    /etc/exim4/conf.d/main/03_exim4-config_tlsoptions

    and adding the following lines

          
         tls_certificate = /etc/exim4/rsa.cert
         tls_privatekey = /etc/exim4/rsa.key
         tls_dhparam = /etc/exim4/dh.key
    
  1. Edit the user authentication info on file /etc/exim4/passwd.client[1]. For example, for user coco.elmo.dfaie with LDAP password frdg098r

          
         # password file used when the local exim is authenticating to a remote
         # host as a client.
         #
         # see exim4_passwd_client(5) for more documentation
         #
         # Example:
         ### target.mail.server.example:login:password
         mailgw.uhu.es:coco.elmo.dfaie:frdg098r
    
  1. Restart the exim's daemon.

          
         # /etc/init.d/exim4 restart
    

1.6.1 References

  1. http://www.amk.ca/diary/2003/03/enabling_smtptls_with_exim.html


1.7 Copying CUPS configuration from one server to another

The simplest way to copy the CUPS configuration from one server to another is the following:

  1. Stop CUPS on the target system.

          
         target# /etc/init.d/cups stop
    
  1. Rename or backup the existing configuration directory

          
         target# mv /etc/cups /etc/cups.orig
    
  1. Copy the /etc/cups directory from the source system to the destination system.

          
         target# scp -r source:/etc/cups /etc/cups
    
  1. Copy any modified model files from the source system to the destination system. These files should be in /usr/share/cups/model.

          
         target# scp -r source:/usr/share/cups/model /usr/share/cups/model
    
  1. On the target server edit the file /etc/cups/cupsd.conf and check if the hostname or IP address of your source system is present. If so, change it to the target server hostname or IP. Check that hostnames are defined properly in the /etc/hosts file of the target system.

  1. If any custom groups or accounts are used on the old system to manage CUPS recreate them on the new system.

  1. Restart cups in the target system and test it.


1.7.1 References

  1. Tech tip in My Scripts and Tips


1.8 Mapping network interfaces to a fixed name.

As modules on the booting process or during the system's activity are not loaded always in the same order, it is difficult to get the network devices named in a constant way. This can be achieved using the package ifrename. This software maps the interfaces to a fixed name based on the MAC address (for example). You just need to add the file /etc/iftab:

      
     # Mapping NICs to fixed names
     ether0  driver 8139too mac XX:XX:XX:XX:XX:XX
     wifi0  driver ipw2200 mac XX:XX:XX:XX:XX:XX

Another way to get the same result especially prone to Debian systems is to include an addition of a udev rule. In order to do so, create the file /etc/udev/rules.d/net.local.rules, and populate it with the following:

      
         KERNEL=="eth*", SYSFS{address}=="00:01:80:50:dc:f2", NAME="wired"
         KERNEL=="eth*", SYSFS{address}=="00:0d:61:a1:20:15", NAME="wireless"

changing the MAC's addresses and NAME's accordingly.


1.9 Using labels to mount disk partitions

Using the possibility of labelling the disk partitions it is useful for avoiding ambiguities and errors mounting them. This is valid for ext2, ext3, and ext4 filesystems. To name usbdisk0 the second partition of a disk which is currently /dev/sdb we should do as follows[2]

      
     # e2label /dev/sdb2 usbdisk0

There are other tools to label partitions for different filesystems.

  1. ext2 ext3 ext4: e2label

  1. FAT16 FAT32: mtools

  1. jfs: jfstune

  1. NTFS: ntfsprogs

Then, once the partition is labelled, we create the mount point, e.g. mkdir /media/usb_disk_0, and we can add a line in /etc/fstab like the following

      
     LABEL=usbdisk0       /media/usb_disk_0 ext3    exec,user,noauto  0       0

When we use the command mount /media/usb_disk_0 the previously labelled partition will be mounted.


1.10 Using find and xargs

Updated on January 12th, 2016.

The combination of the utilities find and xargs is a powerful tool if you need to apply a program or repeat a task with several files.

As an example let's imagine that we have a directory with many LaTeX files, and some of them are letters, named as lett_name.tex and we should transform some of them into pdf files. A simple perl oneliner that can do the task of transforming a tex file into a pdf file is the following.

      
     perl -e '(my $name= $ARGV[0])=~s/\.tex//; system "latex $name;dvipdf $name"' file.tex

How to select the LaTeX files with different and flexible criteria and apply this program to all of them? A possible answer is to combine the powerful find and xargs programs.

Let's suppose that we want to transform to pdf format all the files having names starting as lett_. Then we can execute

      
     $ find . -name "lett_*.tex" -print 
     ./lett_diput_Huelva.tex
     ./lett_Hospital_IE.tex
     ./lett_CEPSA.tex
     ./lett_del_JA_Huelva.tex
     ./lett_audiencia_Huelva.tex
     ./lett_subdel_gob_Huelva.tex
     ./lett_INNOV.tex
     ./lett_ayto_Huelva.tex
     ./lett_Hospital_JRJ.tex
     ./lett_ayto_Palos.tex

This command finds all the files starting with lett_ and finishing as .tex and print its names. The option -iname makes a case insensitive search. Other interesting options are -amin n and -atime n where n is the number of minutes or hours that have passed since the last time the file was accessed. If the number is negative the effect is the contrary and look for files accessed prior to this time.

The program xargs can be combined with find. This program in its simplest form takes lines of input and apply programs to them. The simplest use is xargs -I {} run_command {}. In this form xargs read lines from the standard input and apply to each of them the command run_command substituting {} by the input line. Instead of the standard input the option -a filename permits xargs to get its input from a file rather that the standard input. We can combine the two command as follows

      
     $ find . -iname "lett*.tex" -print | xargs -I {} perl -e '(my $name= $ARGV[0])=~s/\.tex//; system "latex $name;dvipdf $name"' {}

In multiprocessor computers we can use the interesting option -P n, which makes xargs to run n number of commands in parallel.

Another interesting option of find is -newer filename. With this option the program displays the names of the files that are more recent than the file filename. Using this in combination with xargs we can for example, transfer using scp all the files in a directory that are more recent that a given file. If we want to upload to a server called destination.org all files in a directory that are more recent than a file called fulltext.pdf we shoud execute

      
     $ find ./* -newer fulltext.pdf -print | xargs -I {} scp {} user@destination.org:FilesPath

Another possible example, let's think that you have several directories and you want to copy files that fulfill some condition to a directory. For example, you want to copy all files having names ending as _presentation.pdf to the directory /media/user/3908-E1A4/. You can achieve this goal with the following pipe:

      
     $ find . -name "*_presentation.pdf" | xargs -I {} cp {} /media/user/3908-E1A4/

The following case is a practical example that shows how useful is the combination of pipes in bash, making also use of the xargs command.

Let's assume that we are copying into a directory a backup of the home folders of several users. Then, by mistake, instead of the directory of a user called tigu, we copied the contents of his directory to the backup directory, wreaking some havoc and transforming

     user1 user2 user3  ...   tigu

into

     user1 user2 user3  ...   tigu and all tigu files and directories

A quick solution, avoiding the selection and deletion by hand of each of the misplaced files and directories, consists in the combination with pipes of several commands

     $ find . -maxdepth 1 -user tigu | grep -v tigu | xargs rm -r

The first command output is a list (non-recursive) of all files and directories in the current directory (assuming that the current directory is where the backup takes place) belonging to user tigu.

The first pipe pipes the result of this search to the grep command, where the directory named tigu is explicitly excluded. This is done to prevent the command from erasing the original user home directory.

Finally the output of grep is piped to a combination of xargs and rm that removes the files. For more details in the use of xargs see the references below.

Several commands can be launched by xargs. For example, let's assume that we want to check the differences between files in two different directories, and we want to know the file it is being tested each time. The way to accomplish this, combining an echo statement with the diff statement using xargs is the following

     $ ls -1 *f90 | xargs -I % sh -c 'echo %; diff % /users/home/laura/prototipo_1.0/fortran/1D/1body/pseudostates/src/%;' | less

In this case we are also using a different character as a dummy variable for xargs with the option -I %.

A last example of several pipes and xargs is the following, where we are reconstructing using rdiff-backup the accounts of a series of users, excepting user laura, from a directory /home_backup/username in a node called backup_server to the directory /home in the node server

      ssh root@backup_server ls -1 /home_backup | grep -v laura | xargs -I % sh -c "rdiff-backup -v4 --restore-as-of now  root@backup_server::/home_backup/% /home/%"

1.10.1 References

  1. http://www.linuxjournal.com/article/10643


1.11 Preparing a USB bootable Linux installation device (Fast way).

Updated on October 6th, 2014.

We need a USB disk that is at least 256 MB in size with a FAT16 partition. Normally the sticks come with a preconfigured single FAT16 partition that is valid. If it is necessary to format the disk you can find instructions in Preparing a USB bootable Debian installation device., Section 1.12. Take also into account that all data in the stick will be erased. Plug in and mount the dist. Let's assume that the USB disk corresponds to the /dev/sdb device.

      
     $ mount
     /dev/sdb1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,uid=1001,shortname=winnt)

Download the Debian image. Take into account that the image should fit into the stick.

      
     $ wget -c http://cdimage.debian.org/debian-cd/6.0.1a/i386/iso-cd/debian-6.0.1a-i386-netinst.iso
     --2011-05-03 13:37:50--  http://cdimage.debian.org/debian-cd/6.0.1a/i386/iso-cd/debian-6.0.1a-i386-netinst.iso
     Resolving cdimage.debian.org... 130.239.18.173, 130.239.18.163, 2001:6b0:e:2018::163, ...
     .
     .
     .
     .
     Saving to: `debian-6.0.1a-i386-netinst.iso'
     
     100%[============================================================>] 198,064,128 1.54M/s   in 98s     
     
     2011-05-03 13:39:35 (1.92 MB/s) - `debian-6.0.1a-i386-netinst.iso' saved [198064128/198064128]

The CD or DVD image you choose should be written directly to the USB stick, overwriting its current contents with the command dd if=file of=device bs=4M; sync. If the pendrive device is /dev/sdb and the iso image path is /media/MSDOS/FSTS/ubuntu-14.04.1-desktop-amd64.iso the command should be

      
     # dd if=/media/MSDOS/FSTS/ubuntu-14.04.1-desktop-amd64.iso of=/dev/sdb bs=4M; sync
     245+1 records in
     245+1 records out
     1028653056 bytes (1.0 GB) copied, 22.5565 s, 45.6 MB/s

And the stick is ready.


1.11.1 References

  1. http://www.debian.org/releases/stable/i386/ch04s03.html.en


1.12 Preparing a USB bootable Debian installation device.

The first step is the creation of a FAT16 partition and filesystem in the USB disk. Suppose that the USB disk corresponds to the /dev/sdb device. Then, as root we format and include the filesystem.

      
     # fdisk /dev/sdb
     
     
     Disk /dev/sdb: 1 GB, 1997649920 bytes
     62 heads, 62 sectors/track, 1015 cylinders
     Units = cylinders of 3844 * 512 = 1968128 bytes
     
        Device Boot      Start         End      Blocks   Id  System 
     /dev/sdb1   *           1        1015     1950799    6  FAT16
     
     
     # mkdosfs /dev/sdb1
     mkdosfs 3.0.1 (23 Nov 2008)

We now proceed to install a bootloader, as syslinux, grub, or lilo. We include syslinux[3]

      
     # syslinux /dev/sdb1
     #

We now add the installer image, mounting the stick and copying the files vmlinuz (kernel binary) and initrd.gz (initial ramdisk image) to the stick. Both files can be found under the directory /debian/dists/lenny/main/installer-i386/current/images/hd-media/ of the distribution.

      
     # mount /dev/sdb1 /mnt
     # ls /mnt
     ldlinux.sys
     # 
     # cd /mnt
     /mnt# wget http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/vmlinuz
     --2010-03-12 16:16:23--  http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/vmlinuz
     Resolving http.us.debian.org... 149.20.20.135, 204.152.191.39, 35.9.37.225, ...
     Connecting to http.us.debian.org|149.20.20.135|:80... connected.
     HTTP request sent, awaiting response... 200 OK
     Length: 1468976 (1.4M) [text/plain]
     Saving to: `vmlinuz'
     
     100%[======================================>] 1,468,976    624K/s   in 2.3s    
     
     2010-03-12 16:16:26 (624 KB/s) - `vmlinuz' saved [1468976/1468976]
     
     deckard:/mnt# wget http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/initrd.gz
     --2010-03-12 16:16:37--  http://http.us.debian.org/debian/dists/lenny/main/installer-i386/current/images/hd-media/initrd.gz
     Resolving http.us.debian.org... 128.30.2.36, 149.20.20.135, 204.152.191.39, ...
     Connecting to http.us.debian.org|128.30.2.36|:80... connected.
     HTTP request sent, awaiting response... 200 OK
     Length: 5183930 (4.9M) [application/x-gzip]
     Saving to: `initrd.gz'
     
     100%[======================================>] 5,183,930   1.42M/s   in 3.5s    
     
     2010-03-12 16:16:40 (1.42 MB/s) - `initrd.gz' saved [5183930/5183930]

Now we should create a syslinux.cfg configuration file, which at a bare minimum should contain the following two lines:

      
     default vmlinuz
     append initrd=initrd.gz

We finally copy a Debian ISO image (businesscard, netinst or full CD image; be sure to select one that fits) onto the stick and unmount the USB memory stick.


1.12.1 References

  1. http://www.debian.org/releases/stable/i386/ch04s03.html.en


1.13 Upgrading Flashplayer in Debian Lenny using backports.

We start adding Debian Backports[4] to /etc/apt/sources.list. Be warned: once backports is active he resulting system can't be considered plain "stable" anymore.

      
     # backports Added by Currix 28/04/10
     deb http://www.backports.org/debian lenny-backports main contrib non-free

You then proceed to run apt-get update. There would probably be an error due to the lack of backports.org archive's key.

      
     # apt-get update
     
     ...
     
     Reading package lists... Done
     W: GPG error: http://www.backports.org lenny-backports Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EA8E8B2116BA136C
     W: You may want to run apt-get update to correct these problems

In order to correct this we can now install the public key from backports.org.

      
     # apt-get install debian-backports-keyring
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     The following packages were automatically installed and are no longer required:
       libsilc-1.1-2 libhesiod0 libzephyr3
     Use 'apt-get autoremove' to remove them.
     The following NEW packages will be installed:
       debian-backports-keyring
     0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
     Need to get 3362B of archives.
     After this operation, 49.2kB of additional disk space will be used.
     WARNING: The following packages cannot be authenticated!
       debian-backports-keyring
     Install these packages without verification [y/N]? y
     Get:1 http://www.backports.org lenny-backports/main debian-backports-keyring 2009.02.20 [3362B]
     Fetched 3362B in 0s (29.2kB/s)
     Selecting previously deselected package debian-backports-keyring.
     (Reading database ... 219559 files and directories currently installed.)
     Unpacking debian-backports-keyring (from .../debian-backports-keyring_2009.02.20_all.deb) ...
     Setting up debian-backports-keyring (2009.02.20) ...
     OK

We can now run apt-get update without any warning or error. Backport packages are deactivated by default (i.e. the packages are pinned to 1 by using NotAutomatic: yes in the Release files, just as in experimental). If you want to install a package from backports run:

      
     apt-get -t lenny-backports install package

or

      
     aptitude -t lenny-backports install package

In order to update to Flash Player 10 first you should install the package flashplugin-nonfree

      
     # apt-get -t lenny-backports install flashplugin-nonfree
     
        .
        .
        .
     
     2010-04-28 09:46:20 (450 KB/s) - `./install_flash_player_10_linux.tar.gz' saved [4050435/4050435]
     
     #

Then update the Flash Player with the command

      
     # /usr/sbin/update-flashplugin-nonfree --install
     #

To check if the plugin has been recognized by iceweasel type

      
     about:plugins

in the browser address line. If there are previous versions of the plugin installed they can interfere. Uninstall them removing from ~/.mozilla/plugins the corresponding file.


1.13.1 References

  1. http://backports.org/dokuwiki/doku.php?id=instructions

  1. http://wiki.debian.org/FlashPlayer

  1. http://plugindoc.mozdev.org/


1.14 Passive network exploration with p0f.

This utility uses passive techniques to try to guess the what machines exist on a network and properties of these computers. By default the application only listens to packets addressed to the machine executing the application

      
     # p0f 
     p0f - passive os fingerprinting utility, version 2.0.8
     (C) M. Zalewski <lcamtuf@dione.cc>, W. Stearns <wstearns@pobox.com>
     p0f: listening (SYN) on 'eth0', 262 sigs (14 generic, cksum 0F1F5CA2), rule: 'all'.

To look at all the packets, not only the packets addressed to the machine where p0f is running, the interface should be in promiscuous mode, using the -p option. Be aware that this can cause a large capture data rate.

Using the -s option, the application can work with tcpdump data logs. The -w option allows to save network traffic data in tcpdump format.

Other interesting options are -M to activate the masquerade detection algorithm to try to identify hosts behind a NAT, and -l to format the output in a one-line style that is easier to grep.


1.15 Preparing a bootable flashdisk with Billix.

We start downloading billix from its sourceforge page. The link can be found in References, Section 1.15.1. In the present example the downloaded file name is billix-0.27.tar.gz. We need a usb flashdisk of a minimum size of 256 MB and with a FAT or FAT32 filesystem. In the present example is the device /dev/sdb1 mounted in /media/disk.

      
     $ mount | grep disk
     /dev/sdb1 on /media/disk type vfat (rw,nosuid,nodev,uhelper=hal,shortname=winnt,uid=1001)

The downloaded file is untarred in the flashdisk

      
     $ cd /media/disk
     /media/disk$ tar xzf ~/Downloads/billix-0.27.tar.gz

The second step is the installation of the MBR (Master Boot Record) in the flahsdisk. [5] This has to be executed as superuser and the syntax is install-mbr -p1 device and it is important to select the correct device, as this can wreak havoc if executed in an incorrect device.

      
     # install-mbr -p1 /dev/sdb

We can now install the bootsector within the first partition running syslinux -s device/partition. Again this is a potentially dangerous operation and should never be performed in a wrong partition. Superuser privileges are not necessary to perform this operation.

      
     /media/disk$ syslinux -s /dev/sdb1

The bootable flash disk is now ready and can be used as nice help for the system administrator. If there is spare space in the flash disk can be used normally for file storing.


1.15.1 References

  1. Billix project homepage


1.16 Recovering a console that is unusable.

Sometimes it is convenient to clean the display of a text console, something that can be done using the shell command clean. For more extreme cases, when the console has gone totally berserk, e.g. after displaying binary characters, the initial state can be recovered using the command reset. It is possible that you will not be able to see the command while you type, but after its execution the console should return to a saner state.


1.17 Simple configuration of sudo

A very quick and dirty configuration of sudo in order to allow a user, e.g. tuxie, to execute programs with superuser privileges can be done adding one line to the sudoers file:

      
     # echo "tuxie  ALL=(ALL) ALL" >> /etc/sudoers

A more detailed configuration is required in a sensitive environment.


1.18 Check the groups to which a user belongs.

In order to check to what groups a user, e.g. tuxie, belongs the command groups can be used:

      
     $ groups tuxie
     tuxie adm dialout cdrom floppy audio video plugdev

1.19 Check the available system locale options and establish a default one.

In order to check what locale options are compiled and available in a Debian system the user should execute.

      
     $ locale -a
     C
     en_IE
     en_IE@euro
     en_IE.iso88591
     en_IE.iso885915@euro
     en_IE.utf8
     en_US
     en_US.iso88591
     es_ES
     es_ES@euro
     es_ES.iso88591
     es_ES.iso885915@euro
     es_ES.utf8
     POSIX
     spanish

The system's default locale in Debian systems is found in the /etc/default/locale file.

      
     $ cat /etc/default/locale 
     LANG=en_IE.UTF-8

The locale setting when executing a program can be changed on the fly

      
     $  LANG=en_IE.utf8 date
     Wed Oct 27 11:54:44 CEST 2010
     $  LANG=es_ES.utf8 date
     mié oct 27 11:54:52 CEST 2010
     $

It is recommended to use always a utf-8 locale as a standard. And to define it only setting the $LANG variable, and not a complicate set of $LC_* variables. To define the default local for the system use the dpkg-reconfigure locales command.


1.20 Change the encoding of given files.

To change the encoding of a file is very useful the application iconv. This application transforms a file from a given coding system to the default system encoding or to a different encoding. The different available encoding schemes can be shown with the option -l or --list

      
     $ iconv -l
     The following list contain all the coded character sets known.  This does
     not necessarily mean that all combinations of these names can be used for
     the FROM and TO command line parameters.  One coded character set can be
     listed with several different names (aliases).
     
       437, 500, 500V1, 850, 851, 852, 855, 856, 857, 860, 861, 862, 863, 864, 865,
       866, 866NAV, 869, 874, 904, 1026, 1046, 1047, 8859_1, 8859_2, 8859_3, 8859_4,
       8859_5, 8859_6, 8859_7, 8859_8, 8859_9, 10646-1:1993, 10646-1:1993/UCS4,
     
       ...
     
       ISO-2022-JP-2, ISO-2022-JP-3, ISO-2022-JP, ISO-2022-KR, ISO-8859-1,
       ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-5, ISO-8859-6, ISO-8859-7,
       ISO-8859-8, ISO-8859-9, ISO-8859-9E, ISO-8859-10, ISO-8859-11, ISO-8859-13,
       ISO-8859-14, ISO-8859-15, ISO-8859-16, ISO-10646, ISO-10646/UCS2,
       ISO-10646/UCS4, ISO-10646/UTF-8, ISO-10646/UTF8, ISO-CELTIC, ISO-IR-4,
     
       ...
     
       UNICODEBIG, UNICODELITTLE, US-ASCII, US, UTF-7, UTF-8, UTF-16, UTF-16BE,
       UTF-16LE, UTF-32, UTF-32BE, UTF-32LE, UTF7, UTF8, UTF16, UTF16BE, UTF16LE,
       UTF32, UTF32BE, UTF32LE, VISCII, WCHAR_T, WIN-SAMI-2, WINBALTRIM,
       WINDOWS-31J, WINDOWS-874, WINDOWS-936, WINDOWS-1250, WINDOWS-1251,
       WINDOWS-1252, WINDOWS-1253, WINDOWS-1254, WINDOWS-1255, WINDOWS-1256,
       WINDOWS-1257, WINDOWS-1258, WINSAMI2, WS2, YU

For example, if the default encoding is UTF-8 and we want to transform an ISO-8859-1 file named example to this encoding we should run

      
     $ file non_standard_ISO 
     non_standard_ISO: ISO-8859 text
     $ file non_standard_ISO 
     non_standard_ISO: ISO-8859 text
     curro@deckard:~/temp$ iconv -f ISO-8859-1 non_standard_ISO 
     ñññññññ
     áááá
     ééé
     íí
     ó
     ú

If no output file name is given with the option -o the result is displayed in the standard output. Thus, to save the file as non_standard_UTF we can execute

      
     $ iconv -f ISO-8859-1 non_standard_ISO -o non_standard_UTF
     curro@deckard:~/temp$ file non_standard_UTF 
     non_standard_UTF: UTF-8 Unicode text

We can also transform to an encoding that is not the system's default one with the option -t

      
     $ iconv -f ISO-8859-1 -t UNICODE non_standard_ISO -o non_standard_UNI
     $ file non_standard_UNI 
     non_standard_UNI: Little-endian UTF-16 Unicode character data

1.21 Problem with the wireless and nm

Sometimes, specially after having tweaked with the network manually, the NetworkManager applet does not appear any more, or when it appears it informs that it does not manage the wireless networks.

In order to fix this, ensure that the file /etc/network/interfaces is like the following, commenting any other thing previously added:

      
     # This file describes the network interfaces available on your system
     # and how to activate them. For more information, see interfaces(5).
     
     # The loopback network interface
     auto lo
     iface lo inet loopback

and make sure to change the option false to true in the file /etc/NetworkManager/NetworkManager.conf

      
     [ifupdown]
     managed=true

With this changes, restarting the network should be all you need to solve the problem.


1.22 Updating Debian

From Wheezy to Jessie. Updated on January 19, 2011.

From Stretch to Buster. Updated on July 18, 2019.

A sensible previous step is to backup some files and directories

      
     # tar czf ~/tmp/etc.tgz /etc &
     # tar czf ~/tmp/var_lib_dpkg.tgz /var/lib/dpkg/ &
     # tar czf ~/tmp/var_lib_apt.tgz /var/lib/apt/ &
     # dpkg --get-selections "*" > ~/tmp/selections.txt 
     # tar czf ~/tmp/var_lib_aptitude_pkgstates.tgz /var/lib/aptitude

In order to gain an extra safety margin when upgrading remotely, we suggest that you run upgrade processes in the virtual console provided by screen, which enables safe reconnection and ensures the upgrade process is not interrupted even if the remote connection process fails.

      
     #  
     # screen
     # screen -ls
     There is a screen on:
             10305.pts-0.deck     (22/12/15 14:28:45)     (Attached)
     1 Socket in /var/run/screen/S-root.

To have a smooth and flawless upgrade, review actions pending in package manager launching aptitude and press g (Go). If it shows any actions, you should review them and either fix them or implement the suggested actions. If no actions are suggested you will be presented with a message saying No packages are scheduled to be installed, removed, or upgraded. In case you have configured APT pinning it should also be changed to point to packages in the new version. In case you do not know what pinning is do not worry and follow on.

Regardless of the method used for upgrading, it is recommended that you check the status of all packages first, and verify that all packages are in an upgradable state. The following command will show any packages which have a status of Half-Installed or Failed-Config, and those with any error status.

      
     # dpkg --audit
     The following packages are missing the md5sums control file in the
     database, they need to be reinstalled:
      p0f                  Passive OS fingerprinting tool
      libdb4.5             Berkeley v4.5 Database Libraries [runtime]
      dhcp3-common         ISC DHCP common files (transitional package)

Reinstall packages with some issues. Transitional packages and other packages in the Obsolete Section often can be removed once reinstalled.

      
     # 
     # aptitude reinstall p0f
     The following packages will be REINSTALLED:
       p0f 
     0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
     Need to get 71.0 kB of archives. After unpacking 0 B will be used.
     Get: 1 http://ftp.de.debian.org/debian/ wheezy/main p0f i386 2.0.8-2 [71.0 kB]
     Fetched 71.0 kB in 0s (122 kB/s)
     dpkg: warning: parsing file '/var/lib/dpkg/available' near line 447064 package 'cnews':
      error in Version string 'cr.g7-40.4': version number does not start with digit
     dpkg: warning: parsing file '/var/lib/dpkg/available' near line 600967 package 'epic4':
      'Conflicts' field, reference to 'epic4-help': error in version: version number does not start with digit
     (Reading database ... 397695 files and directories currently installed.)
     Preparing to replace p0f 2.0.8-2 (using .../archives/p0f_2.0.8-2_i386.deb) ...
     Unpacking replacement p0f ...
     Processing triggers for man-db ...
     Setting up p0f (2.0.8-2) ...
     #
     # aptitude reinstall libdb4.5
     The following packages will be REINSTALLED:
       libdb4.5 
     0 packages upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
     Need to get 0 B of archives. After unpacking 0 B will be used.
     E: I wasn't able to locate a file for the libdb4.5 package. This might mean you need to manually fix this package.
     E: I wasn't able to locate a file for the libdb4.5 package. This might mean you need to manually fix this package.
     E: Internal error: couldn't generate list of packages to download

Check packages on hold

      
     # aptitude search "~ahold" 
     No packages on hold

Run apt-get full-upgrade which will perform a major version upgrade an may remove some redundant or non-needed packages

      
     # apt-get full-upgrade
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     Calculating upgrade... Done
     The following packages were automatically installed and are no longer required:
       linux-image-4.9.0-4-amd64 linux-image-4.9.0-5-amd64
       linux-image-4.9.0-6-amd64 linux-image-4.9.0-7-amd64
     Use 'apt autoremove' to remove them.
     0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Run apt autoremove to remove automatically installed dependencies no further needed. Notice that we are using the new implementation apt instead of apt-get. In case this is not woprking in your system reverts to apt-get. To check the differences between the two check references.

      
     # apt autoremove
     Reading package lists... Done
     Building dependency tree
     Reading state information... Done
     The following packages will be REMOVED:
       linux-image-4.9.0-4-amd64 linux-image-4.9.0-5-amd64
       linux-image-4.9.0-6-amd64 linux-image-4.9.0-7-amd64
     0 upgraded, 0 newly installed, 4 to remove and 0 not upgraded.
     After this operation, 765 MB disk space will be freed.
     Do you want to continue? [Y/n]
     (Reading database ... 433814 files and directories currently installed.)
     Removing linux-image-4.9.0-4-amd64 (4.9.65-3+deb9u1) ...
     /etc/kernel/postrm.d/initramfs-tools:
     update-initramfs: Deleting /boot/initrd.img-4.9.0-4-amd64
     /etc/kernel/postrm.d/zz-update-grub:
     Generating grub configuration file ...
     Found background image: /usr/share/images/desktop-base/desktop-grub.png
     Found linux image: /boot/vmlinuz-4.9.0-9-amd64
     Found initrd image: /boot/initrd.img-4.9.0-9-amd64
     Found linux image: /boot/vmlinuz-4.9.0-8-amd64
     Found initrd image: /boot/initrd.img-4.9.0-8-amd64
     Found linux image: /boot/vmlinuz-4.9.0-7-amd64
     Found initrd image: /boot/initrd.img-4.9.0-7-amd64
     Found linux image: /boot/vmlinuz-4.9.0-6-amd64
     Found initrd image: /boot/initrd.img-4.9.0-6-amd64
     Found linux image: /boot/vmlinuz-4.9.0-5-amd64
     Found initrd image: /boot/initrd.img-4.9.0-5-amd64
     Found linux image: /boot/vmlinuz-4.9.0-3-amd64
     Found initrd image: /boot/initrd.img-4.9.0-3-amd64
     .
     .
     .
     Removing linux-image-4.9.0-7-amd64 (4.9.110-3+deb9u2) ...
     /etc/kernel/postrm.d/initramfs-tools:
     update-initramfs: Deleting /boot/initrd.img-4.9.0-7-amd64
     /etc/kernel/postrm.d/zz-update-grub:
     Generating grub configuration file ...
     Found background image: /usr/share/images/desktop-base/desktop-grub.png
     Found linux image: /boot/vmlinuz-4.9.0-9-amd64
     Found initrd image: /boot/initrd.img-4.9.0-9-amd64
     Found linux image: /boot/vmlinuz-4.9.0-8-amd64
     Found initrd image: /boot/initrd.img-4.9.0-8-amd64
     Found linux image: /boot/vmlinuz-4.9.0-3-amd64
     Found initrd image: /boot/initrd.img-4.9.0-3-amd64
     Adding boot menu entry for EFI firmware configuration
     done

Edit /etc/apt/sources.list replacing stretch by buster (previously wheezy by jessie)

      
     /etc/apt# cat sources.list
     # 
     
     # deb cdrom:[Official Debian GNU/Linux Live 9.1.0 xfce 2017-07-23T01:37]/ buster main
     
     #deb cdrom:[Official Debian GNU/Linux Live 9.1.0 xfce 2017-07-23T01:37]/ buster main
     
     deb http://ftp.es.debian.org/debian/ buster main non-free contrib
     deb-src http://ftp.es.debian.org/debian/ buster main non-free contrib
     
     deb http://security.debian.org/debian-security buster/updates main contrib non-free
     deb-src http://security.debian.org/debian-security buster/updates main contrib non-free
     
     # buster-updates, previously known as 'volatile'
     deb http://ftp.es.debian.org/debian/ buster-updates main contrib non-free
     deb-src http://ftp.es.debian.org/debian/ buster-updates main contrib non-free

Upgrade packages using the package management tool apt (or apt-get, see references). In previous releases, aptitude was recommended for this purpose, but recent versions of apt provide equivalent functionality and also have shown to more consistently give the desired upgrade results. Use /usr/bin/script program to record a transcript of the upgrade session. Then if a problem occurs, you will have a log of what happened that could provide exact information in a bug report. To start the recording, type:

      
     # script -t 2>~/upgrade-busterstep.time -a ~/upgrade-busterstep.script
     Script started, file is /root/upgrade-busterstep.script
     #

Update package list

      
     # apt update

Check if you have enough space for the update

      
     # apt -o APT::Get::Trivial-Only=true dist-upgrade
     ....
       xserver-xorg-video-fbdev xserver-xorg-video-geode xserver-xorg-video-intel xserver-xorg-video-mach64 xserver-xorg-video-mga
       xserver-xorg-video-neomagic xserver-xorg-video-nouveau xserver-xorg-video-openchrome xserver-xorg-video-r128
       xserver-xorg-video-radeon xserver-xorg-video-savage xserver-xorg-video-siliconmotion xserver-xorg-video-sisusb
       xserver-xorg-video-tdfx xserver-xorg-video-trident xserver-xorg-video-vesa xserver-xorg-video-vmware xsltproc xterm xtrans-dev xvfb
       xz-utils yelp yelp-xsl zenity zenity-common zip zlib1g zlib1g-dev
     2095 upgraded, 820 newly installed, 54 to remove and 0 not upgraded.
     Need to get 3,135 MB of archives.
     After this operation, 1,645 MB of additional disk space will be used.
     E: You don't have enough free space in /var/cache/apt/archives/.

In cases like the present one, when you do not have enough space in var, create a temporary /var/cache/apt/archives directory

      
     # cp -ax /var/cache/apt/archives/ /home/
     # ls /home/archives/
     lock  partial
     #  mount --bind /home/archives /var/cache/apt/archives
     # mount | grep arch
     /dev/sda6 on /var/cache/apt/archives type ext3 (rw,relatime,errors=continue,user_xattr,barrier=1,data=ordered)

Proceed to a minimal system upgrade to overcome deleting a large number of packages and some possible inconsistencies, and then a full upgrade. To do this run first apt upgrade (apt-get upgrade in previous versions) followed by apt fullupgrade (apt-get dist-upgrade). In case the error message indicates so, like in the following example, run apt-get -f install

      
     # apt upgrade
     root@modesto:~# apt upgrade
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     Calculating upgrade... Done
     Some packages could not be installed. This may mean that you have
     requested an impossible situation or if you are using the unstable
     distribution that some required packages have not yet been created
     or been moved out of Incoming.
     The following information may help to resolve the situation:
     
     The following packages have unmet dependencies:
      inetutils-ping : Conflicts: ping
     E: Broken packages

This error can be overcome removing the package interutils-ping

      
     # apt remove inetutils-ping
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     The following packages will be REMOVED:
       inetutils-ping
     0 upgraded, 0 newly installed, 1 to remove and 2179 not upgraded.
     After this operation, 345 kB disk space will be freed.
     Do you want to continue? [Y/n] 
     (Reading database ... 416910 files and directories currently installed.)
     Removing inetutils-ping (2:1.9.4-2+b1) ...
     Processing triggers for man-db (2.7.6.1-2) ...
     ...

During the update there was an error, the load spiked up and had to open a console and reattch to the screen session, stop and kill the process, remove the lock files and run dpkg --configure -a with the final output.

      
     W: Possible missing firmware /lib/firmware/i915/bxt_dmc_ver1_07.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/skl_dmc_ver1_27.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/kbl_dmc_ver1_04.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/cnl_dmc_ver1_07.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/glk_dmc_ver1_04.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/kbl_guc_ver9_39.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/bxt_guc_ver9_29.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/skl_guc_ver9_33.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/kbl_huc_ver02_00_1810.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/bxt_huc_ver01_07_1398.bin for module i915
     W: Possible missing firmware /lib/firmware/i915/skl_huc_ver01_07_1398.bin for module i915
     Processing triggers for systemd (241-5) ...
     Processing triggers for sgml-base (1.29) ...
     Errors were encountered while processing:
      man-db
      x11-apps
      yelp
      mate-user-guide
      gnome-user-docs
      gnome-user-guide
     #

I now retry to apt upgrade

      
     # apt upgrade
     Reading package lists... Done#########################################################################################################################################################################......................................]
     Building dependency tree       
     Reading state information... Done
     Calculating upgrade... Done
     The following packages were automatically installed and are no longer required:
       bdf2psf dmz-cursor-theme docbook-xml galculator gcj-6-jre-lib gfortran-6 gir1.2-gconf-2.0 gir1.2-gnomekeyring-1.0 gir1.2-mate-panel gir1.2-matepanelapplet-4.0 gnome-user-docs gnome-user-guide gvfs-bin iputils-arping isympy
       isympy-common libbind9-140 libblas-common libcdio-cdda1 libcdio-paranoia1 libcdio13 libdns162 libexempi3 libfcitx-gclient0 libfcitx-qt0 libfile-copy-recursive-perl libfile-slurp-tiny-perl libgcj-bc libgcj-common libgcj17
       libgcr-3-common libgfortran-6-dev libgstreamer-plugins-bad1.0-0 libgtksourceview2.0-0 libgtksourceview2.0-common libgutenprint2 libical2 libisc160 libisccc140 libisccfg140 libjim0.76 liblouis12 liblouisutdml7 liblwres141 libnm-glib4
       libnm-util2 libntfs-3g871 libpackage-deprecationmanager-perl libpango1.0-0 libpangox-1.0-0 libqrencode3 librarian0 libruby2.3 libsac-java-gcj libsane-extras libsane-extras-common libsodium18 libsuitesparseconfig4 libsynctex1
       libunbound2 libunique-3.0-0 libxfont1 linux-headers-4.9.0-8-amd64 linux-headers-4.9.0-8-common linux-image-4.9.0-8-amd64 python-antlr python-pyasn1 rarian-compat ruby2.3 tcpd vlc-plugin-notify vlc-plugin-samba
       vlc-plugin-video-splitter vlc-plugin-visualization xfce4-mount-plugin
     Use 'apt autoremove' to remove them.
     The following packages have been kept back:
       anthy auctex biber cups cups-client cups-core-drivers cups-daemon cups-filters cups-filters-core-drivers default-jre default-jre-headless dkms dspdfviewer emacs emacs24 emacsen-common evince evince-common exfalso fcitx-frontend-qt5
       fcitx-modules g++ gimp gimp-data gir1.2-evince-3.0 gnome-orca gnome-themes-standard gnustep-base-common gnustep-base-runtime goldendict grace grub-common grub-efi-amd64 grub-efi-amd64-bin grub2-common gstreamer1.0-libav hplip
       hplip-data hplip-gui imagemagick-6.q16 inkscape libapt-pkg-perl libautovivification-perl libcairo-perl libclass-c3-xs-perl libcups2 libcupsimage2 libdate-simple-perl libdatetime-perl libdevel-caller-perl libdevel-lexalias-perl
       libencode-eucjpms-perl libencode-hanextra-perl libencode-jis2k-perl libevdocument3-4 libevview3-3 libfcgi-perl libfcitx-qt5-1 libffmpegthumbnailer4v5 libgimp2.0 libgl1-mesa-dri libglib-perl libgtk2-perl libhpmud0 libhtml-parser-perl
       libimage-magick-q16-perl libio-socket-ssl-perl liblist-moreutils-perl liblocale-gettext-perl libnet-dbus-perl libnet-ssleay-perl libopenmpt-modplug1 libopenmpt0 libpackage-stash-xs-perl libpadwalker-perl libpango-perl
       libparams-classify-perl libparams-util-perl libparams-validate-perl libparams-validationcompiler-perl libpoppler-qt5-1 libpython-dev libpython-stdlib libpython2.7 libpython2.7-dev libpython2.7-minimal libpython2.7-stdlib
       libpython3-stdlib libqt4-dbus libqt4-designer libqt4-help libqt4-network libqt4-opengl libqt4-qt3support libqt4-script libqt4-sql libqt4-sql-mysql libqt4-svg libqt4-xml libqt4-xmlpatterns libqt5core5a libqt5dbus5 libqt5designer5
       libqt5gui5 libqt5help5 libqt5network5 libqt5opengl5 libqt5printsupport5 libqt5sql5 libqt5sql5-sqlite libqt5svg5 libqt5test5 libqt5widgets5 libqt5x11extras5 libqt5xml5 libqtcore4 libqtdbus4 libqtgui4 libreoffice
       libreoffice-avmedia-backend-gstreamer libreoffice-base libreoffice-base-core libreoffice-base-drivers libreoffice-calc libreoffice-common libreoffice-core libreoffice-draw libreoffice-gtk2 libreoffice-gtk3 libreoffice-help-ca
       libreoffice-help-cs libreoffice-help-da libreoffice-help-de libreoffice-help-dz libreoffice-help-el libreoffice-help-en-gb libreoffice-help-en-us libreoffice-help-es libreoffice-help-et libreoffice-help-eu libreoffice-help-fi
       libreoffice-help-fr libreoffice-help-gl libreoffice-help-hi libreoffice-help-hu libreoffice-help-it libreoffice-help-ja libreoffice-help-km libreoffice-help-ko libreoffice-help-nl libreoffice-help-pl libreoffice-help-pt
       libreoffice-help-ru libreoffice-help-sk libreoffice-help-sl libreoffice-help-sv libreoffice-help-zh-cn libreoffice-help-zh-tw libreoffice-impress libreoffice-java-common libreoffice-l10n-ar libreoffice-l10n-ast libreoffice-l10n-be
       libreoffice-l10n-bg libreoffice-l10n-bn libreoffice-l10n-bs libreoffice-l10n-ca libreoffice-l10n-cs libreoffice-l10n-cy libreoffice-l10n-da libreoffice-l10n-de libreoffice-l10n-dz libreoffice-l10n-el libreoffice-l10n-en-gb
       libreoffice-l10n-en-za libreoffice-l10n-eo libreoffice-l10n-es libreoffice-l10n-et libreoffice-l10n-eu libreoffice-l10n-fa libreoffice-l10n-fi libreoffice-l10n-fr libreoffice-l10n-ga libreoffice-l10n-gl libreoffice-l10n-gu
       libreoffice-l10n-he libreoffice-l10n-hi libreoffice-l10n-hr libreoffice-l10n-hu libreoffice-l10n-id libreoffice-l10n-is libreoffice-l10n-it libreoffice-l10n-ja libreoffice-l10n-ka libreoffice-l10n-km libreoffice-l10n-ko
       libreoffice-l10n-lt libreoffice-l10n-lv libreoffice-l10n-mk libreoffice-l10n-ml libreoffice-l10n-mr libreoffice-l10n-nb libreoffice-l10n-ne libreoffice-l10n-nl libreoffice-l10n-nn libreoffice-l10n-pa-in libreoffice-l10n-pl
       libreoffice-l10n-pt libreoffice-l10n-pt-br libreoffice-l10n-ro libreoffice-l10n-ru libreoffice-l10n-si libreoffice-l10n-sk libreoffice-l10n-sl libreoffice-l10n-sr libreoffice-l10n-sv libreoffice-l10n-ta libreoffice-l10n-te
       libreoffice-l10n-th libreoffice-l10n-tr libreoffice-l10n-ug libreoffice-l10n-uk libreoffice-l10n-vi libreoffice-l10n-xh libreoffice-l10n-zh-cn libreoffice-l10n-zh-tw libreoffice-math libreoffice-ogltrans libreoffice-pdfimport
       libreoffice-report-builder libreoffice-report-builder-bin libreoffice-script-provider-bsh libreoffice-script-provider-js libreoffice-script-provider-python libreoffice-sdbc-hsqldb libreoffice-sdbc-postgresql libreoffice-style-tango
       libreoffice-writer libsane-hpaio libscalar-list-utils-perl libsnmp30 libsort-key-perl libspecio-perl libstdc++6 libsub-identify-perl libsub-name-perl libtbb2 libtext-bibtex-perl libtext-charwidth-perl libtext-csv-xs-perl
       libtext-iconv-perl libuim-custom2 libuim-scm0 libuim8 libunicode-collate-perl libunicode-linebreak-perl libvariable-magic-perl libvlc-bin libvlc5 libvoikko1 libxml-libxml-perl libxml-libxslt-perl libxml-parser-perl
       lightdm-gtk-greeter lm-sensors meld mozc-server mozc-utils-gui perl perl-base perl-doc printer-driver-hpcups printer-driver-postscript-hp prosper python python-cvxopt python-dev python-glade2 python-gtk2 python-jupyter-core
       python-matplotlib python-minimal python-numexpr python-numpy python-pandas python-pandas-lib python-pyqt5 python-pyqt5.qtsvg python-scipy python-sip python-statsmodels python-statsmodels-lib python-tables python-tables-data
       python-tables-lib python2.7 python2.7-dev python2.7-minimal python3 python3-brlapi python3-cairo python3-cups python3-dbus python3-dbus.mainloop.pyqt5 python3-gi python3-libvoikko python3-minimal python3-pil python3-pyqt5
       python3-renderpm python3-reportlab python3-reportlab-accel python3-sip python3-smbc python3-uno qdbus qt5-gtk-platformtheme quodlibet rename task-albanian-desktop task-amharic task-amharic-desktop task-arabic task-arabic-desktop
       task-asturian task-asturian-desktop task-basque task-basque-desktop task-belarusian task-belarusian-desktop task-bengali task-bengali-desktop task-bosnian task-bosnian-desktop task-brazilian-portuguese
       task-brazilian-portuguese-desktop task-british-desktop task-bulgarian task-bulgarian-desktop task-catalan task-catalan-desktop task-chinese-s task-chinese-s-desktop task-chinese-t task-chinese-t-desktop task-croatian
       task-croatian-desktop task-cyrillic task-cyrillic-desktop task-czech task-czech-desktop task-danish task-danish-desktop task-desktop task-dutch task-dutch-desktop task-dzongkha-desktop task-english task-esperanto
       task-esperanto-desktop task-estonian task-estonian-desktop task-finnish task-finnish-desktop task-french task-french-desktop task-galician task-galician-desktop task-georgian-desktop task-german task-german-desktop task-greek
       task-greek-desktop task-gujarati task-gujarati-desktop task-hebrew task-hebrew-desktop task-hindi task-hindi-desktop task-hungarian task-hungarian-desktop task-icelandic task-icelandic-desktop task-indonesian-desktop task-irish
       task-irish-desktop task-italian task-italian-desktop task-japanese task-japanese-desktop task-kannada-desktop task-kazakh task-kazakh-desktop task-khmer task-khmer-desktop task-korean task-korean-desktop task-kurdish
       task-kurdish-desktop task-laptop task-latvian task-latvian-desktop task-lithuanian task-lithuanian-desktop task-macedonian task-macedonian-desktop task-malayalam task-malayalam-desktop task-marathi task-marathi-desktop
       task-mate-desktop task-nepali-desktop task-northern-sami task-northern-sami-desktop task-norwegian task-norwegian-desktop task-persian task-persian-desktop task-polish task-polish-desktop task-portuguese task-portuguese-desktop
       task-punjabi task-punjabi-desktop task-romanian task-romanian-desktop task-russian task-russian-desktop task-serbian task-serbian-desktop task-sinhala-desktop task-slovak task-slovak-desktop task-slovenian task-slovenian-desktop
       task-south-african-english-desktop task-spanish task-spanish-desktop task-swedish task-swedish-desktop task-tagalog task-tamil task-tamil-desktop task-telugu task-telugu-desktop task-thai task-thai-desktop task-turkish
       task-turkish-desktop task-ukrainian task-ukrainian-desktop task-uyghur-desktop task-vietnamese-desktop task-welsh task-welsh-desktop task-xfce-desktop task-xhosa-desktop tasksel tasksel-data texinfo texlive texlive-base
       texlive-bibtex-extra texlive-extra-utils texlive-font-utils texlive-fonts-extra texlive-fonts-extra-doc texlive-fonts-recommended texlive-fonts-recommended-doc texlive-generic-extra texlive-generic-recommended texlive-lang-spanish
       texlive-latex-base texlive-latex-base-doc texlive-latex-extra texlive-latex-extra-doc texlive-latex-recommended texlive-latex-recommended-doc texlive-pictures texlive-pictures-doc texlive-pstricks texlive-pstricks-doc
       texlive-publishers texlive-publishers-doc texlive-science texlive-science-doc thunar thunar-data uim uim-anthy uim-fep uim-gtk2.0 uim-gtk3 uim-mozc uim-qt5 uim-xim unar uno-libs3 ure vlc vlc-bin vlc-data vlc-l10n vlc-plugin-base
       vlc-plugin-qt vlc-plugin-skins2 vlc-plugin-video-output xfce4-sensors-plugin xserver-xorg-core xserver-xorg-video-amdgpu xserver-xorg-video-ati xserver-xorg-video-fbdev xserver-xorg-video-intel xserver-xorg-video-nouveau
       xserver-xorg-video-qxl xserver-xorg-video-radeon xserver-xorg-video-vesa xserver-xorg-video-vmware
     0 upgraded, 0 newly installed, 0 to remove and 518 not upgraded.
     6 not fully installed or removed.
     After this operation, 0 B of additional disk space will be used.
     Do you want to continue? [Y/n] 
     Setting up man-db (2.8.5-2) ...
     Updating database of manual pages ...
     man-db.service is a disabled or a static unit, not starting it.
     Setting up x11-apps (7.7+7) ...
     Setting up yelp (3.31.90-1) ...
     Setting up mate-user-guide (1.20.2-1) ...
     Setting up gnome-user-docs (3.30.2-1) ...
     Setting up gnome-user-guide (3.30.2-1) ...
     Processing triggers for menu (2.1.47+b1) ...

Success... Now I run apt full-upgrade and got a similar problem. The GUI froze and had to switch to the console, and reload the screen. There I removed again the lock files /var/lib/dpkg/lock and /var/lib/dpkg/lock-frontend and the run apt --fix-broken install

      
     # apt --fix-broken install
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     Correcting dependencies... Done
     The following packages were automatically installed and are no longer required:
     aspell-de-alt bdf2psf debian-zh-faq-s dh-python dmz-cursor-theme doc-debian-fr doc-linux-fr-text doc-linux-pl doc-linux-pl-html docbook-xml emacs24 fonts-adf-accanthis fonts-adf-gillius fonts-adf-universalis fonts-cabin fonts-comfortaa
     .
     .
     .
     Processing triggers for mime-support (3.62) ...
     Processing triggers for man-db (2.8.5-2) ...
     Processing triggers for auctex (11.91-2) ...

Success... Now run apt full-upgrade

      
     # apt full-upgrade
     Reading package lists... Done
     Building dependency tree... 
     Reading state information... Done
     Calculating upgrade... Done
     The following packages were automatically installed and are no longer required:
       aspell-de-alt bdf2psf debian-zh-faq-s dh-python dmz-cursor-theme doc-debian-fr doc-linux-fr-text doc-linux-pl doc-linux-pl-html docbook-xml emacs24 fonts-adf-accanthis fonts-adf-gillius fonts-adf-universalis fonts-cabin fonts-comfortaa
       fonts-croscore fonts-ebgaramond fonts-ebgaramond-extra fonts-freefont-otf fonts-gfs-artemisia fonts-gfs-complutum fonts-gfs-didot fonts-gfs-neohellenic fonts-gfs-olga fonts-gfs-solomos fonts-junicode fonts-lobster fonts-lobstertwo
       fonts-oflb-asana-math fonts-roboto-hinted fonts-roboto-unhinted fonts-sil-gentiumplus fonts-sil-gentiumplus-compact fortune-zh galculator gcj-6-jre-lib gfortran-6 gir1.2-gconf-2.0 gir1.2-mate-panel gir1.2-matepanelapplet-4.0 gnome-orca
       gnome-themes-standard gnome-user-docs gnome-user-guide gvfs-bin iputils-arping isympy isympy-common libaribb24-0 libass5 libavfilter6 libavformat57 libavresample3 libbasicusageenvironment1 libbind9-140 libblas-common libbluray1
     libboost-date-time1.62.0 libboost-filesystem1.62.0 libboost-iostreams1.62.0 libboost-program-options1.62.0 libboost-system1.62.0 libcddb2 libcdio-cdda1 libcdio-paranoia1 libcdio13 libchewing3 libchewing3-data libdc1394-22 libdca0
     .
     .
     .
     Processing triggers for shared-mime-info (1.10-1) ...
     Processing triggers for install-info (6.5.0.dfsg.1-4+b1) ...
     Processing triggers for menu (2.1.47+b1) ...
     Processing triggers for desktop-file-utils (0.23-4) ...
     Processing triggers for libvlc-bin:amd64 (3.0.7-1) ...

Repeat apt full-upgrade until it results in no errors.

Edit files in folder /etc/apt/sources.list.d/ like dropbox.list, base.list, google-chrome.list, or skype-stable.list in case they exist and change the Debian release version to Buster, e.g.

      
     # cat dropbox.list 
     deb [arch=i386,amd64] http://linux.dropbox.com/debian buster main

Rerun apt update and apt upgrade until no more errors are found. If required run apt autoremove

      
     # apt update
     Hit:1 http://deb.debian.org/debian buster InRelease
     Hit:2 http://ftp.es.debian.org/debian buster InRelease                                                           
     Hit:3 http://security.debian.org/debian-security buster/updates InRelease                                        
     Ign:4 http://dl.google.com/linux/chrome/deb stable InRelease                                                           
     Hit:5 http://ftp.es.debian.org/debian buster-updates InRelease                                                         
     Hit:6 http://dl.google.com/linux/chrome/deb stable Release           
     Hit:7 https://repo.skype.com/deb stable InRelease
     Reading package lists... Done
     Building dependency tree       
     Reading state information... Done
     All packages are up to date.

Once finisished with no more errors umount the temporary archives directory and you can use aptitude for package management.

      
     # umount /var/cache/apt/archives/
     
       
     And That's all....

1.22.1 References

  1. Debian Jessie Release Notes

  1. apt vs apt-get in Linux Magazine


1.23 Error in file /var/lib/dpkg/status

Added on May 21, 2011.

The arrival of Squeeze has brought the "illegalization" of the underscore as a valid character in the /var/lib/dpkg/status file and this cause some havoc if there are some packages having this character in its name

     warning, in file '/var/lib/dpkg/status' near line 6627 package 'virtualbox':
      error in Version string '1.3.6_Debian_etch': invalid character in version number
     warning, in file '/var/lib/dpkg/status' near line 6628 package 'virtualbox':
      error in Config-Version string '1.3.6_Debian_etch': invalid character in version number

The solution is to clean this packages from the list and from the available packages info. In this particular case the package was not installed but still caused the problem.

     sudo dpkg --clear-avail
     sudo aptitude purge virtualbox

1.24 How to record terminal sessions using ttyrec

Added on September 2nd, 2011.

The recording of terminal sessions can be of utility, specially for teaching purposes. A nice tool to obtain this recordings is the ttyrec program.

We will briefly show the way to record your terminal sessions. The first step is to install the ttyrec package (in Debian)

     # apt-get install ttyrec
     Reading package lists... Done
     Building dependency tree... Done
     The following NEW packages will be installed:
       ttyrec
     0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
     Need to get 30.9kB of archives.
     After unpacking 131kB of additional disk space will be used.
     Get:1 http://archive.debian.org etch/main ttyrec 1.0.6-1 [30.9kB]
     Fetched 30.9kB in 1s (21.0kB/s)
     Selecting previously deselected package ttyrec.
     (Reading database ... 103998 files and directories currently installed.)
     Unpacking ttyrec (from .../ttyrec_1.0.6-1_i386.deb) ...
     Setting up ttyrec (1.0.6-1) ...
     #

Then a second step is to open a terminal window with a 80x25 size where ttyrec will be executed.

Prior to the execution it is useful to create an initialization file to start ttyrec with the appropriate settings. This is not mandatory, but can be interesting. A sample file is the following:

     # input file for starting a bash session using ttyrec
     # by Currix TM.
     #
     # vt100 setting
     export TERM=vt100
     # 
     # change prompt
     export PS1="$ "
     #
     # Remove trailing CTRL-C from comments
     bind 'set echo-control-characters off'

If the name of this file is .inputrc_ttyrec the program ttyrec should be invoked as

     ttyrec -e 'bash --rcfile .inputrc_ttyrec'

In the references for this chapter (References, Section 1.24.1) a link to a recorded session is found. There it is shown how for example a vi session can be included or how comments are made by typing CTRL-c at the end of each comment line.

The default output of ttyrec is a file named ttyrecord. To save the output in a different file the filename should be included at the end of the ttyrec program invocation. The output file can be played back using the program ttyplay, included in the ttyrec package. A sample file can be downloaded and played

     wget http://www.uhu.es/gem/clinux/descargas/ttyrecord
     ttyplay ttyrecord

The speed of the playback can be increased with the + key or slowed with -.

An interesting site to find terminal recordings is Playterm, whose URL can be found in the references section.


1.24.1 References

  1. ttyrec homepage

  1. ttyrecord file sample

  1. Playterm homepage


1.25 Using Bash to count the number of files in a directory

Added on September 6th, 2011.

The number of files in a directory, or in general, the number of files displayed by the command ls can be counted using a pipe and the command wc

     $ ls -1 1*gif 
     115810.strip.print.gif
     115811.strip.print.gif
     115813.strip.print.gif
     116637.strip.print.gif
     116639.strip.print.gif
     116642.strip.print.gif
     117321.strip.print.gif
     117324.strip.print.gif
     118015.strip.print.gif
     $ ls -1 1*gif | wc -l
     9

Some alternatives with Perl oneliners can be found in Interesting perl oneliners, Section 5.2


1.26 Getting detailed information about your hardware

Added on November 30th, 2011.

The command lshw lists a (very) detailed information about your hardware. The Debian package has the same name. This program should be executed as superuser.

     deckard
         description: All In One
         product: iMac8,1
         vendor: Apple Inc.
         version: 1.0
     .
     .
     . Very long output here...
     .
     .
       *-network DISABLED
            description: Ethernet interface
            physical id: 1
            logical name: vboxnet0
            serial: 0a:00:27:00:00:00
            capabilities: ethernet physical
            configuration: broadcast=yes multicast=yes

To get an abridged output with the essential info the program can be run with the option -short.


1.27 Adding your servers load to the screen hardstatus line

Added on December 1st, 2011.

It is possible to configure screen to display the cpu load or other information of interest in the hardstatus line. In this case we use Perl and ssh. We prepare a short Perl script that takes as arguments an argument related to the output format and a server ip. The considered output formats are green (cpu load < 1.0), yellow (3.0 > cpu load >= 1.0), and red (cpu load >= 3.0). The Perl code is called perl_load

     #!/usr/bin/perl
     #
     use strict;
     use warnings;
     use 5.010;
     #
     # by Currix TM
     #
     my $code =  "$ARGV[0]";
     my $hostname = "$ARGV[1]";
     #
     chomp(my $output = `ssh $hostname cat /proc/loadavg`);
     my @load = ($1,$2,$3) if ($output =~ /^(\d+\.\d+)\s+(\d+\.\d+)\s+(\d+\.\d+)\s+\d.*$/);
     #
     given($code) {
       when ("red") {
         if ($load[0] >= 3.0) {
           $output = $hostname.": ".$load[0];
         } else {
           $output = '';
         }
       }
       when ("orange") {
         if ($load[0] >= 1.0 && $load[0] < 3.0) {
           $output = $hostname.": ".$load[0];
         } else {
           $output = '';
         }
       }
       when ("green") {
         if ($load[0] < 1.0) {
           $output = $hostname.": ".$load[0];
         } else {
           $output = '';
         }
       }
       default {
         $output = "wrong option";
       }
     }
     print "$output";

The script output is the server name and the cpu load average for the past minute if the load is in the interval defined by the format output.

The inclusion of this script in the .screenrc is accomplished using backticks. For more information on this point and color formatting check the screen man page. An example .screenrc is given below

      
     shell -$SHELL
     #
     backtick 101 31 31 /home/username/bin/perl_load red server_name_or_IP
     backtick 102 61 61 /home/username/bin/perl_load orange server_name_or_IP
     backtick 103 91 91 /home/username/bin/perl_load green server_name_or_IP
     #
     hardstatus alwayslastline
     hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B}%Y-%m-%d %{W}%c  | %{+b R}%101`%{+b Y}%102`%{+b G}%103`  %{g}]'
     
     # Default screens
     screen -t mutt          0       mutt 
     screen -t server	1       
     screen -t box_1	        2       ssh username@rbox_1
     screen -t box_2 	3       ssh username@box_2

1.28 Making a backup of a Gmail account.

Added on December 7th, 2011.

We describe a way of backing up a Gmail mail account making use of IMAP and the getmail program. We assume that the copies want to be made in different mbox files for different periods of time. For example, a backup copy on a yearly basis.

The first step consist in enabling IMAP access in the settings section of the Gmail account to be backed up and the creation of a set of labels in the Gmail account grouping the messages that will be backed up. This can be accomplished using a search with before and after. For example, we can search for mail that matches the search before:2007/10/01 AND after:2007/09/01, which will include conversations for September 2007, and group the result of the search under the label mail_sept_2007.

The second step is the installation of the getmail4 package, a mail agent program far simpler to configure than fetchmail.

     $ sudo aptitude install getmail4

The next step is the more complicated one and implies the configuration of the getmail program. In order to do so a .getmail directory should be created, with restricted permissions, and a config file getmail.gmail edited

      
     $ mkdir .getmail
     $ chmod og-xr .getmail/

This is a sample getmail.gmail

      
     $ cat getmail/getmail.gmail
     [retriever]
     type = SimpleIMAPSSLRetriever
     server = imap.gmail.com
     username = XXXXX@gmail.com
     password = XXXXXXXXXXXX
     mailboxes = ("mail_sept_2007",)
     
     [destination]
     type = Mboxrd
     path = DESTINATION_PATH/mail-sept_2007.mbox
     
     [options]
     # print messages about each action (verbose = 2)
     # Other options:
     # 0 prints only warnings and errors
     # 1 prints messages about retrieving and deleting messages only
     verbose = 2
     message_log = ~/.getmail/gmail.log

This file should also have read permissions only for the user owning it. Messages in this example are saved with Mbox format. For other alternatives check references. The Mbox file has to be created before backing up.

      
     $ touch DESTINATION_PATH/mail-sept_2007.mbox

The last step is to proceed to download the mail

      
     $ getmail -r getmail.gmail 
     getmail version 4.20.0
     Copyright (C) 1998-2009 Charles Cazabon.  Licensed under the GNU GPL version 2.
     SimpleIMAPSSLRetriever:currix@gmail.com@imap.gmail.com:993:
     .
     . Lots of output here...
     .
       1200 messages (596565682 bytes) retrieved, 0 skipped
     Summary:
     Retrieved 1200 messages (596565682 bytes) from SimpleIMAPSSLRetriever:XXXX@gmail.com@imap.gmail.com:993

The resulting Mbox files can be easily accessed with Mutt or other mail reader program.


1.28.1 References

  1. Matt Cutts Blog

  1. Peng.u.i.n Blog


1.29 Redirecting STDERR to SDTOUT

Added on Febuary 3rd, 2012.

Sometimes you need to redirect the standard error output, STDERR, merging it with the standard output, STDOUT. This is needed, for example, when you have a long error output from a program compilation and you want to pipe it to less to peruse the compiler info. This can be done using the standard bash redirection tools as 2>&1. If we want to check the error output of a compilation this can be done as follows

     $ make all 2>&1 | less

Instead, if instead you want to merge STDOUT into STDERR this is accomplished as 1>&2.


1.30 Listing and extracting files from a deb package file.

Added on August 11th, 2012.

The deb extension marks Debian software package format. This standard is also used in other distributions that are based on Debian (e.g. Ubuntu or Knoppix).

The dpkg program is the low level package manager for Debian and with this command you can list and extract the files containd in a package, as shown below.

We use as an example the ovpc package. Once we download the file, to display the contents of a debian package the required option is dpkg -c

      
     $ dpkg -c ovpc_1.06.94-3_i386.deb
     dr-xr-xr-x root/root         0 2010-02-25 10:54 ./
     dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/
     dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/
     dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/lib/
     dr-xr-xr-x root/root         0 2010-02-25 10:48 ./ovpc/pkg/lib/header/
     -r-xr-xr-x root/root       130 2009-10-29 17:06 ./ovpc/pkg/lib/header/libov.so
     .
     .
     .
     
     -r-xr-xr-x root/root       131 2009-10-29 17:06 ./ovpc/pkg/etc/conf
     dr-xr-xr-x root/root         0 2010-02-25 10:54 ./ovpc/pkg/etc/conf/log.conf

You can use dpkg -x to extract the files from a deb package as shown below.

      
     $ dpkg -x  ovpc_1.06.94-3_i386.deb /tmp/ov
     $ ls /tmp/ov
     ovpc

But there is also an alternative way of proceeding. As deb files are ar archives, containing three files: debian-binary, control.tar.gz, and data.tar.gz. We can use the ar and tar commands to extract and view the files from the deb package.

First, extract the content of the deb archive file using ar.

      
     $ ar -vx ovpc_1.06.94-3_i386.deb
     x - debian-binary
     x - control.tar.gz
     x - data.tar.gz
     $

Next, extract the content of data.tar.gz file as follows.

     $ tar -xvzf data.tar.gz
     ./
     ./ovpc/
     ./ovpc/pkg/
     ./ovpc/pkg/lib/
     ./ovpc/pkg/lib/header/
     ./ovpc/pkg/lib/header/libov.so
     .
     .
     ./ovpc/pkg/etc/conf
     ./ovpc/pkg/etc/conf/log.con

1.30.1 References

  1. TheGeekStuff


1.31 Using script to keep terminal output records.

Added on November 18th, 2012.

The script command saves in a file the output of the terminal where it has been executed. The basis command syntax is

      
     $ script [filename]

If no filename is given then the default filename is typescript. Be aware that script works best without making use of programs that manipulate the screen such that vi or less.

To exit script you can type CTRL-D or exit.

You can use the -a option to append the output to a file without overwriting it. An example of use of script is the following:

      
     $ script test_script
     Script started, file is test_script
     $ who
     bara    tty8         2012-11-17 13:57 (:0)
     bara    pts/1        2012-11-17 13:58 (:0.0)
     $ exit
     exit
     Script done, file is test_script
     $ ls -l test_script 
     -rw-r--r-- 1 bara rsrchrs 780 Nov 18 12:02 test_script
     $ cat test_script 
     Script started on Sun 18 Nov 2012 12:02:17 PM CET
     $ who
     bara    tty8         2012-11-17 13:57 (:0)
     bara    pts/1        2012-11-17 13:58 (:0.0)
     $ exit
     exit
     
     Script done on Sun 18 Nov 2012 12:02:33 PM CET
     $

Another interesting option is to share a session output between two users. This is very handy when explaining to someone a particular feature in the console. In order to do so the script output is sent to a fifo file and the flush option -t is added while the second user should have ssh access to the computer where script is run.

For example if user bara in computer prague wants to show her output to user alice in computer wland the necessary steps are the following:

On bara's side

      
     bara@prague$ mkfifo foo; script -f foo

The console now will be temporarily frozen until alice starts getting the output from the fifo file foo.

     alice@wland$ ssh alice@prague
     alice@prague's password: 
     WWelcome to Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-33-generic i686)
     
      * Documentation:  https://help.ubuntu.com/
     
     0 packages can be updated.
     0 updates are security updates.
     
     Last login: Sun Nov 18 10:50:37 2012 from platea.local
     alice@prague$ cat /home/bara/foo
     Script started on Sun 18 Nov 2012 11:21:29 AM CET
     bara@prague$

And from now on user bara can proceed to work on the terminal sharing the output with alice. Beware that the permissions in the fifo file and bara's home directory should allow alice to access the fifo.


1.32 Checking actual kernel compiling options.

Added on January 8th, 2013.

Sometimes it is necessary to check if the kernel of your computer has been compiled including a particular option. For example, let's check if the kernel has been compiled with the CONFIG_EFI_PARTITION option turned on (see Using parted to partition memory sticks or formatting HD partitions larger than 2 TB, Section 1.33).

      
     $ cd /boot/
     $ ls
     System.map-2.6.32-5-amd64  config-2.6.32-5-amd64  grub/  initrd.img-2.6.32-5-amd64  vmlinuz-2.6.32-5-amd64
     $ grep _EFI_ config-2.6.32-5-amd64 
     CONFIG_EFI_VARS=m
     CONFIG_EFI_PARTITION=y

1.33 Using parted to partition memory sticks or formatting HD partitions larger than 2 TB

Added on January 8th, 2013.

Updated on March 22nd, 2019.

Let's start with the larger than 2 TB partitions. The first step is to check whether your kernel has been compiled with the CONFIG_EFI_PARTITION option turned on (see Checking actual kernel compiling options., Section 1.32). If this is so, let's assume that the device assigned to the HD that will be partitioned is /dev/sdb, that it is a 2 TB HD and will be mounted in /large_disk. The fdisk program and its variants cannot be used because the new partition will be too large (larger than 1.5 TB). Be warned that fdisk and all its variants will not issue warnings but will create partitions not larger than 1.5 TB.

Be also warned that all the contents of the disk will be lost. Make the necessary backups in advance.

Let's assume that you've installed the parted program.

      
     # parted /dev/sdb
     GNU Parted 2.3
     Using /dev/sdb
     Welcome to GNU Parted! Type 'help' to view a list of commands.
     (parted)

You can print the actual partition scheme

      
     (parted) print
     Model: DELL PERC H700 (scsi)
     Disk /dev/sdb: 1933GB
     Sector size (logical/physical): 512B/512B
     Partition Table: msdos
     
     Number  Start   End     Size    Type     File system  Flags
      1      1049kB  1933GB  1933GB  primary  ext3
     
     (parted)

The next step is to remove the existing partition

      
     (parted) rm 1                                                             
     (parted) print                                                            
     Model: DELL PERC H700 (scsi)
     Disk /dev/sdb: 1933GB
     Sector size (logical/physical): 512B/512B
     Partition Table: msdos
     
     Number  Start  End  Size  Type  File system  Flags
     
     (parted)

Next, the disk is labeled as a gpt disk

     (parted) mklabel gpt                                                      
     Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
     Yes/No? Yes                                                               
     (parted) print                                                            
     Model: DELL PERC H700 (scsi)
     Disk /dev/sdb: 1933GB
     Sector size (logical/physical): 512B/512B
     Partition Table: gpt
     
     Number  Start  End  Size  File system  Name  Flags
     
     (parted)

Once the disk is relabeled, the new partition can be created and you can exit parted

     (parted) mkpart
     Partition name?  []? primary                                              
     File system type?  [ext2]?                                                
     Start? 0                                                                  
     End? -0                                                                   
     Warning: The resulting partition is not properly aligned for best performance.
     Ignore/Cancel? I                                                          
     (parted) print                                                            
     Model: DELL PERC H700 (scsi)
     Disk /dev/sdb: 1933GB
     Sector size (logical/physical): 512B/512B
     Partition Table: gpt
     
     Number  Start   End     Size    File system  Name     Flags
      1      17.4kB  1933GB  1933GB               primary
     
     (parted) quit                                                             
     Information: You may need to update /etc/fstab.

Create the filesystem in the usual way

     # mkfs.ext4 /dev/sdb1 
     mke2fs 1.41.12 (17-May-2010)
     Filesystem label=
     OS type: Linux
     Block size=4096 (log=2)
     Fragment size=4096 (log=2)
     Stride=0 blocks, Stripe width=0 blocks
     117964800 inodes, 471859191 blocks
     23592959 blocks (5.00%) reserved for the super user
     First data block=0
     Maximum filesystem blocks=4294967296
     14400 block groups
     32768 blocks per group, 32768 fragments per group
     8192 inodes per group
     Superblock backups stored on blocks: 
             32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
             4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
             102400000, 214990848
     Writing inode tables: done
     Creating journal (32768 blocks): done
     Writing superblocks and filesystem accounting information: done
     
     This filesystem will be automatically checked every 37 mounts or
     180 days, whichever comes first.  Use tune2fs -c or -i to override.

Finally check the partition UUID and edit accordingly the fstab file.

     # ls -l /dev/disk/by-uuid/
     total 0
     lrwxrwxrwx 1 root root 10 Sep 21 11:43 346dc157-f150-4a1e-8b83-bf4a50dc3cad -> ../../sda5
     lrwxrwxrwx 1 root root 10 Sep 26 13:00 43615088-9470-419c-9958-199b0bcbbbd6 -> ../../sdb1
     lrwxrwxrwx 1 root root 10 Sep 21 11:43 5fa63da1-1ff9-4fbf-93c2-4fcdef686892 -> ../../sda7
     lrwxrwxrwx 1 root root 10 Sep 21 11:43 93272bd4-51b2-4e8a-940d-f85d5fa1978d -> ../../sda6
     #

In our case the previous partition UUID in fstab needs to be replaced by the new value 43615088-9470-419c-9958-199b0bcbbbd6 and the filesystem type should be changed also changed if necessary. The corresponding fstab line should read as follows

     # cat /etc/fstab | grep large
     # /large_disk was on /dev/sdb1 during installation
     UUID=43615088-9470-419c-9958-199b0bcbbbd6 /large_disk     ext4    defaults        0       2

The final result is

     # df -h | grep large
     /dev/sdb1             1.8T  196M  1.7T   1% /large_disk

If necessary, reboot and check that the partition is correctly mounted.

This article was originally written for servers, but after having several times trouble with formatting and creating partitions in memory sticks I decided to update it and address some of the usual problems I face.


1.33.1 Message Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.

As I learned on the references, this was probably caused by writing an image to the disk using dd with the wrong blocksize. This happens to me with a memory stick. Once I umounted the partition and run parted I got

     root@modesto:~# parted /dev/sdc
     GNU Parted 3.2
     Using /dev/sdc
     Welcome to GNU Parted! Type 'help' to view a list of commands.
     (parted) print
     Warning: The driver descriptor says the physical block size is 2048 bytes, but
     Linux says it is 512 bytes.
     Ignore/Cancel? C
     Model: TOSHIBA TransMemory (scsi)
     Disk /dev/sdc: 7759MB
     Sector size (logical/physical): 512B/512B
     Partition Table: unknown
     Disk Flags: 
     (parted) quit                                                             
     root@modesto:~#

We should wipe out all info in the disk. Be extra careful and do not mix up the device label or you may end erasing all info in the wrong unit... So we check again the units using a command line parted with the option --list

     root@modesto:~# parted --list
     Model: ATA Micron 1100 SATA (scsi)
     Disk /dev/sda: 256GB
     Sector size (logical/physical): 512B/4096B
     Partition Table: gpt
     Disk Flags: 
     
     Number  Start   End    Size    File system     Name                  Flags
      1      1049kB  630MB  629MB   fat32           EFI system partition  boot, esp
      2      630MB   222GB  221GB   ext4            DEBIAN
      4      222GB   256GB  34.1GB  linux-swap(v1)
     
     
     Warning: The driver descriptor says the physical block size is 2048 bytes, but
     Linux says it is 512 bytes.
     Ignore/Cancel? I                                                          
     Model: TOSHIBA TransMemory (scsi)
     Disk /dev/sdb: 31.0GB
     Sector size (logical/physical): 2048B/512B
     Partition Table: mac
     Disk Flags: 
     
     Number  Start   End     Size    File system  Name   Flags
      1      2048B   6143B   4096B                Apple
      2      1925MB  1928MB  2392kB               EFI

So the wrong unit is /dev/sdb which truly has a 8GB size. Let's wiipe it out.

     root@modesto:~# wipefs --all /dev/sdb
     /dev/sdb: 5 bytes were erased at offset 0x00008001 (iso9660): 43 44 30 30 31
     /dev/sdb: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
     /dev/sdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
     /dev/sdb: 2 bytes were erased at offset 0x00000000 (mac): 45 52
     /dev/sdb: calling ioctl to re-read partition table: Success

And now let's create a new partition and filesystem with parted

     root@modesto:~# parted /dev/sdb
     GNU Parted 3.2
     Using /dev/sdb
     Welcome to GNU Parted! Type 'help' to view a list of commands.
     (parted) print                                                            
     Error: /dev/sdb: unrecognised disk label
     Model: TOSHIBA TransMemory (scsi)                                         
     Disk /dev/sdb: 7759MB
     Sector size (logical/physical): 512B/512B
     Partition Table: unknown
     Disk Flags: 
     (parted) mklabel gpt
     (parted) mkpart                                                           
     Partition name?  []? data                                                 
     File system type?  [ext2]? fat32                                          
     Start? 0                                                                  
     End? -1                                                                   
     Warning: The resulting partition is not properly aligned for best performance.
     Ignore/Cancel? I                                                          
     (parted) print                                                            
     Model: TOSHIBA TransMemory (scsi)
     Disk /dev/sdb: 7759MB
     Sector size (logical/physical): 512B/512B
     Partition Table: gpt
     Disk Flags: 
     
     Number  Start   End     Size    File system  Name  Flags
      1      17.4kB  7758MB  7758MB  fat32        data
     
     (parted) quit                                                             
     Information: You may need to update /etc/fstab.
     
     root@modesto:~# mkfs.vfat /dev/sdb1
     mkfs.fat 4.1 (2017-01-24)
     root@modesto:~#

TODO Get rid of The resulting partition is not properly aligned for best performance warning.


1.33.2 References

  1. Cyberciti

  1. USB Stick corrupted


1.34 Adding a partition to fstab by UUID

Added on January 31st, 2015.

Assume that you have reformatted your hard disk and created a new partition, maybe liberating some space from other operating system, and you want to add the new partition to your GNU/Linux system. In our case we suppose that the new partition is /dev/sda9 with an ext4 filesystem and we want to mount it in a /data directory. We then want to give access to a system's user, for instace, user curro to this partition.

The first step is check the partition UUID,

      
     $ ls -l /dev/disk/by-uuid/
     total 0
     lrwxrwxrwx 1 root root 10 Feb  1 20:17 2AF23ED0F23E9FCD -> ../../sda1
     lrwxrwxrwx 1 root root 10 Jan 31 20:43 2e6850cc-0bb9-4f36-b0a8-c167aa257dd6 -> ../../sda7
     lrwxrwxrwx 1 root root 10 Jan 31 20:43 55d1fe60-aed5-43c2-9c57-34cdea5accda -> ../../sda6
     lrwxrwxrwx 1 root root 10 Jan 31 20:43 578091f7-b057-481a-82b3-6db5a3b86bec -> ../../sda5
     lrwxrwxrwx 1 root root 10 Feb  1 20:17 5c1dccb0-e78a-48cc-a63d-95148a8f6cb5 -> ../../sda9
     lrwxrwxrwx 1 root root 10 Feb  1 20:16 5F1F-1069 -> ../../sdc1
     lrwxrwxrwx 1 root root 10 Feb  1 20:17 6E223D37223D059D -> ../../sda3
     lrwxrwxrwx 1 root root 10 Feb  1 20:16 9dbd2628-0353-4798-85e4-738b25d0cdd5 -> ../../sdc2
     lrwxrwxrwx 1 root root 10 Feb  1 20:17 c30b003f-11f6-430d-8c19-892d68b2c0cf -> ../../sda8
     lrwxrwxrwx 1 root root 10 Feb  1 20:17 EC7A41587A412126 -> ../../sda2

We then, as root, create the mount point, /data and add the following line to the /etc/fstab

      
     UUID=5c1dccb0-e78a-48cc-a63d-95148a8f6cb5       /data           ext4    defaults,user_xattr        0       2

Once the fstab file is saved, we can now mount the new partition

      
     # mount /data
     # mount | grep sda9
     /dev/sda9 on /data type ext4 (rw,relatime,data=ordered)

The last step is to give user curro access to this directory. This is done creating a directory and assigning the directory to this user

      
     # mkdir downloads_curro
     root@kimoshi:/data# chown curro:curro downloads_curro/

Then user curro can move the data in his folder Downloads to this new directory and link the old folder to the new one.

       $ mv Downloads/* /data/downloads_curro
       $ rmdir Downloads
       $ ln -fs /data/downloads_curro ./Downloads

1.35 Error ejecting a CD

Added on January 31st, 2015.

Sometimes when you eject a CD from the terminal the system displays the following error

      
     $ eject
     eject: unable to eject, last error: Inappropriate ioctl for device

The same error is obtained when we try to eject the CD as superuser

      
     # eject
     eject: unable to eject, last error: Inappropriate ioctl for device

The verbose output is

      
     # eject -v /dev/sr0
     eject: device name is `/dev/sr0'
     eject: expanded name is `/dev/sr0'
     eject: `/dev/sr0' is not mounted
     eject: `/dev/sr0' is not a mount point
     eject: `/dev/sr0' is not a multipartition device
     eject: trying to eject `/dev/sr0' using CD-ROM eject command
     eject: CD-ROM eject command failed
     eject: trying to eject `/dev/sr0' using SCSI commands
     eject: SCSI eject failed
     eject: trying to eject `/dev/sr0' using floppy eject command
     eject: floppy eject command failed
     eject: trying to eject `/dev/sr0' using tape offline command
     eject: tape offline command failed
     eject: unable to eject, last error: Inappropriate ioctl for device

The solution is, as root, use the -i off option and then eject the cd

      
     deckard:~# eject -i off /dev/cdrom 
     CD-Drive may be ejected with device button
     deckard:~# eject /dev/cdrom

An the CD is cleanly ejected. Happy end.


1.36 Killing an unresponsive X-windows

Added on April 2nd, 2016.

Assuming that we have a terminal or any XWindows application that is unresponsive and we do not know its associated PID we can kill it in the following way.

We first open a terminal and start the xwininfo program. It will ask us to select the window we are interested in, and once we click on it we will get info like the following:

      
     $ xwininfo 
     
     xwininfo: Please select the window about which you
               would like information by clicking the
               mouse in that window.
     
     xwininfo: Window id: 0x5c0006a "Printer Properties - 'HP-LaserJet-CP-1025nw' on localhost"
     
       Absolute upper-left X:  1422
       Absolute upper-left Y:  649
       Relative upper-left X:  1
       Relative upper-left Y:  28
       Width: 537
       Height: 336
       Depth: 32
       Visual: 0x7b
       Visual Class: TrueColor
       Border width: 0
       Class: InputOutput
       Colormap: 0x5c00049 (not installed)
       Bit Gravity State: NorthWestGravity
       Window Gravity State: NorthWestGravity
       Backing Store State: NotUseful
       Save Under State: no
       Map State: IsViewable
       Override Redirect State: no
       Corners:  +1422+649  -1327+649  -1327-95  +1422-95
       -geometry 537x336+1421-94

The important piece of data is the window id, in this case 0x5c0006a. We can now kill the window using the program xkill

      
     $ xkill -id 0x5c0006a
     xkill:  killing creator of resource 0x5c0006a

And the window is killed. RIP.


1.37 Enlarging the size of a tmp directory

Added on November 14th, 2016.

The situation is that we assume that your tmp directory is mounted in a partition and, as usually happens with good old servers, it gets full for a particular task. In this particular case it was cleaning a huge Inbox file. The first step is to reserve space for you new tmp directory in a filesystem where you have enough space. We reserve 3Gb in a file called tmp-dir in a directory called /vserver

      
     # dd if=/dev/zero of=/vserver/tmp-dir bs=1024M count=3
     3+0 records in
     3+0 records out
     3221225472 bytes (3.2 GB) copied, 62.3108 s, 51.7 MB/s
     # ls -l /vserver/tmp-dir 
     -rw-r--r-- 1 root root 3221225472 Nov 14 12:28 /vserver/tmp-dir

We then proceed to create a filesystem into the created filespace. You may be warned that the file is not a block device.

      
     # mke2fs -j /vserver/tmp-dir
     mke2fs 1.41.12 (17-May-2010)
     /vserver/tmp-dir is not a block special device.
     Proceed anyway? (y,n) y
     warning: Unable to get device geometry for /vserver/tmp-dir
     Filesystem label=
     OS type: Linux
     Block size=4096 (log=2)
     Fragment size=4096 (log=2)
     Stride=0 blocks, Stripe width=0 blocks
     196608 inodes, 786432 blocks
     39321 blocks (5.00%) reserved for the super user
     First data block=0
     Maximum filesystem blocks=805306368
     24 block groups
     32768 blocks per group, 32768 fragments per group
     8192 inodes per group
     Superblock backups stored on blocks: 
             32768, 98304, 163840, 229376, 294912
     
     Writing inode tables: done                            
     Creating journal (16384 blocks): done
     Writing superblocks and filesystem accounting information: done
     
     This filesystem will be automatically checked every 33 mounts or
     180 days, whichever comes first.  Use tune2fs -c or -i to override.

In order to copy the contents of the actual tmp directory and set the right permissions we mount the just created filesystem in a mount point, e.g. mnt and proceed

      
     # mount -t ext3 -o loop /vserver/tmp-dir /mnt
     # mount | grep mnt
     /dev/loop0 on /mnt type ext3 (rw)
     # cp -a /tmp/* /mnt/
     # chmod 1777 /mnt
     # umount /mnt

Next, we mount the created filesystem as the system's tmp directory

     # mount -t ext3 -o loop /vserver/tmp-dir /tmp
     # df -h | grep /tmp
     /dev/sda7             3.0G   69M  2.8G   3% /tmp
     /dev/loop0            3.0G   69M  2.8G   3% /tmp

Note that the file has been mounted on the same point as the old tmp, the block device /dev/sda7, but the size is the new size, 3GB. Once we carry out the tasks we needed the enlarged tmp directory for, we can umount and recover the initial state of the syste.

     # umount /dev/loop0
     # df -h | grep /tmp
     /dev/sda7             1.9G   35M  1.8G   2% /tmp

And that's all.


1.37.1 References

  1. YourHowto.Net


1.38 Checking if a package is installed in Debian

Added on March 18th, 2018.

We want to check for example whether a package is installed or not in a Debian system. For example, let's check if the package acl isinstalled. There are different ways of doing this.

One option implies dpkg

      
     $ dpkg -l acl
     Desired=Unknown/Install/Remove/Purge/Hold
     | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
     |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
     ||/ Name                           Version               Architecture       Description
     +++-===============================-=====================-==================-=============================
     ii  acl                             2.2.52-3+b1           amd64              Access control list utilities

The important piece of data are the two ii at the beginning of the line, showing that the package is installed. In case that the package were not installed, the line begins with u or p or the output would be as follows

      
     $ dpkg -l 2ping
     dpkg-query: no packages found matching 2ping

Another option uses the apt-cache policy application

     $ apt-cache policy acl
     acl:
       Installed: 2.2.52-3+b1
       Candidate: 2.2.52-3+b1
       Version table:
      *** 2.2.52-3+b1 500
             500 http://ftp.es.debian.org/debian stretch/main amd64 Packages
             500 http://deb.debian.org/debian stretch/main amd64 Packages
             100 /var/lib/dpkg/status

and

     $ apt-cache policy 2ping
     2ping:
       Installed: (none)
       Candidate: 3.2.1-1
       Version table:
          3.2.1-1 500
             500 http://ftp.es.debian.org/debian stretch/main amd64 Packages
             500 http://deb.debian.org/debian stretch/main amd64 Packages

[ previous ] [ Contents ] [ 1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 7 ] [ 8 ] [ 9 ] [ 10 ] [ 11 ] [ next ]


Some Mini-Howtos of Interest

Curro Perez-Bernal mailto:francisco.perez@dfaie.uhu.es