Linux create your own GnuPG private and public key

GNU gpg is encryption and signing tool. The GNU Privacy Guard (GnuPG or GPG) is a free software replacement for the PGP suite of cryptographic software. GnuPG encrypts messages using asymmetric keypairs individually generated by GnuPG users. The resulting public keys can be exchanged with other users in a variety of ways, such as Internet key servers. They must always be exchanged carefully to prevent identity spoofing by corrupting public key ↔ ‘owner’ identity correspondences. It is also possible to add a cryptographic digital signature to a message, so the message integrity and sender can be verified, if a particular correspondence relied upon has not been corrupted.

How do I create my own GnuPG private and public key

  1. Login to your shell account
  2. Use gpg command to create the keys
  3. $ gpg --gen-key


    gpg (GnuPG) 1.4.1; Copyright (C) 2005 Free Software Foundation, Inc.
    This program comes with ABSOLUTELY NO WARRANTY.
    This is free software, and you are welcome to redistribute it
    under certain conditions. See the file COPYING for details.
    gpg: directory `/home/sheron/.gnupg' created
    gpg: new configuration file `/home/sheron/.gnupg/gpg.conf' created
    gpg: WARNING: options in `/home/sheron/.gnupg/gpg.conf' are not yet active during this run
    gpg: keyring `/home/sheron/.gnupg/secring.gpg' created
    gpg: keyring `/home/sheron/.gnupg/pubring.gpg' created
    Please select what kind of key you want:
       (1) DSA and Elgamal (default)
       (2) DSA (sign only)
       (5) RSA (sign only)
    Your selection? Press [Enter] Key
    DSA keypair will have 1024 bits.
    ELG-E keys may be between 1024 and 4096 bits long.
    What keysize do you want? (2048) Press [Enter] Key
    Requested keysize is 2048 bits
    Please specify how long the key should be valid.
             0 = key does not expire
            = key expires in n days
          w = key expires in n weeks
          m = key expires in n months
          y = key expires in n years
    Key is valid for? (0) Press [Enter] Key
    Key does not expire at all
    Is this correct? (y/N) y
    You need a user ID to identify your key; the software constructs the user ID
    from the Real Name, Comment and Email Address in this form:
        "Heinrich Heine (Der Dichter) "
    Real name: sheron
    Email address:
    Comment:[Enter] key
    You selected this USER-ID:
    Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
    You need a Passphrase to protect your secret key.
    Enter passphrase: [Enter password twice]
    We need to generate a lot of random bytes. It is a good idea to perform
    some other action (type on the keyboard, move the mouse, utilize the
    disks) during the prime generation; this gives the random number
    generator a better chance to gain enough entropy.
    gpg: /home/sheron/.gnupg/trustdb.gpg: trustdb created
    gpg: key 8E19F126 marked as ultimately trusted
    public and secret key created and signed.
    gpg: checking the trustdb
    gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
    gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
    pub   1024D/8E19F126 2007-02-10
          Key fingerprint = A7AF E25D 3E8D 6946 37CC  8CCE 12C4 8DC1 8E19 F126
    uid                  sheron 
    sub   2048g/032824B9 2007-02-10
  4. Now keys generated, you can list your own key using:
  5. $ gpg -K


    $ gpg --list-keys


    pub   1024D/CA7A8402 2007-02-10
    uid    sheron
    sub   2048g/0A7B4F93 2007-02-10

    Let us try to understand the line

    pub 1024D/CA7A8402 2007-02-10:

    pub : Public key
    1024D : The number of bits in the key
    CA7A8402 : The key ID
    2007-02-10 : The date of key creation
    sheron : The user real name
    <> :The email id

    Most important is the key ID i.e. CA7A8402.

    Make sure you use powerful passphrase to protect keys and not the easy one.

  6. To list secret key, type the command:
  7. $ gpg --list-secret-keys


    sec   1024D/CA7A8402 2007-02-10
    uid                 sheron
    ssb   2048g/0A7B4F93 2007-02-10

How to install firefox 4 in ubuntu using PPA

Go to Applications > Ubuntu Software Center from the top panel go to Edit > Software Sources and click the ‘Other Software’ tab.Press ‘Add’ button and then paste the following line


After adding the PPA you will be prompted to update your sources.

Once the update is done you can head to System > Administration > Update Manager to perform an upgrade.

Install firefox 4 using terminal

Go to Applications > Terminal in the terminal just enter the following commands

sudo add-apt-repository ppa:mozillateam/firefox-stable

sudo apt-get update

sudo apt-get upgrade

The Beginner’s Guide to Linux Disk Utilities

Knowing how to check the condition of your hard disk is useful to determine when to replace your hard disk. In today’s article, we will show you some Linux disk utilities to diagnose the health of your hard disk.

Image by Scoobay

S.M.A.R.T System

Most modern ATA and SCSI hard disks have a Self-Monitoring, Analysis, and Reporting Technology (SMART) system. SMART hard disks internally monitor their own health and performance.

The SMART tool assesses the condition of your hard disk based on: the throughput of the hard disk, the seek errors rate of the magnetic heads, and other attributes that your hard disk manufacturer built into their hard disk.

Most implementations of SMART systems allow users to perform self-tests to monitor the performance and reliability of their hard disks. The simplest way to perform a SMART system test with Ubuntu is using the ‘Disk Utility’ under the ‘System’ > ‘Administration’ menu.

The disk utility lets you see the model, serial number, firmware, and the overall health assessment of the hard disk, as well as whether a SMART system is enabled on the hard disk.

The ‘SMART data’ button lets you see the SMART features of your hard disk.

The ‘Run Self-test’ button lets you initiate a short,extended, or a conveyance self-test on the hard disk.

When you execute these tests, you’ll see a progress meter, letting you see how far through the test is and what the estimated time of completion is.

The ‘Attributed section’ lets you see the errors and self-test information.

File System Check

There some other tools, beside the Disk Utility GUI, that we can use to diagnose the health of our hard disk. The File System Check (FSCK), that only comes as a command line tool, is one of the tools that we often use to check the condition of our hard disk.

You can use the ‘Check Filesystem’ feature of the ‘Disk Utility’ to perform the same check,if you are not a command line geek like us.

Of course, there are some situations where we have to use the command line tool to check our file system. For example when we are using a headless system, when our Linux box fails to boot, or when we simply want to show off our command line Kungfu skills to our friends.

At first, the FSCK command line tool looks like something that only a computer geek can handle; But you will find that FSCK is a very easy tool to use. There is one thing to note before you run FSCK; You need to unmount the file system using the ‘umount’ command. Fixing a mounted file system with FSCK could end up creating more damage than the original problem.

sudo umount /dev/sdb

The FSCK command is pretty straightforward:

sudo fsck -t ext4 /dev/sdb 

This command checks an ext4 file system (/dev/sdb) for inconsistencies. You should replace /dev/sdb with your own partition. You can run the ‘fdisk’ command to find out your system partitions:

sudo fdisk -l

Scheduled File System Checks

If you’re using Ubuntu, you will notice that Ubuntu runs an FSCK session when you boot your system from time to time. If you find this scheduled check annoying, you can re-schedule the scan using the ‘tune2fs’ command. Here’s how it typically looks like:

The mount count parameter tells us that Ubuntu scans our hard disk after 33 disk mounts.

We can configure the mount count using the ‘-c’ option:

sudo tune2fs -c 35 /dev/sda1

This command will re-configure Ubuntu to scan our hard disk after 35 hard disk mounts when the system boots.

Note: change ‘/dev/sda1/’ with your own partition

Bad Blocks

A bad sector is a sector on a computer’s disk drive that cannot be used due to permanent damage (or an OS inability to successfully access it), such as physical damage to the disk surface.

There are two ways to detect bad sectors in Linux: you can use the Disk Utility GUI, or if you are a command line geek like us, you can use the badblocks command to check your hard disk for bad sectors:

sudo badblocks -v /dev/sdb1

Badblock will give us the number of bad sectors in our hard disk.

zainul@zainul-laptop:~$ sudo badblocks -v /dev/sdb1
Checking blocks 0 to 97683200
Checking for bad blocks (read-only test): 3134528 done, 3:27 elapsed
3134560 done, 8:33 elapsed
3134561 done, 10:15 elapsed
3134562 done, 11:57 elapsed
3134563 done, 13:39 elapsed
Pass completed, 5 bad blocks found.

You have two options when you see bad blocks. You can either look for a new hard disk, or mark these bad blocks as unusable hard disk sectors. This involves two steps:

First we have to write the location of the bad sectors into a flat file.

sudo badblocks /dev/sdb > /home/zainul/bad-blocks

After that, we need to feed the flat file into the FSCK command to mark these bad sectors as ‘unusable’ sectors.

sudo fsck -l bad-blocks /dev/sdb

FSCK, Badblocks, and Disk Utility are some of the disk utilities that we often use to scan our hard disks. Do share with the other fellow readers if you know other Linux disk utilities to scan hard disks.

LibreCAD: open source 2D CAD software

LibreCAD is a free open source 2D CAD drawing software, formerly known as CADuntu. It’s based on the community edition of QCad ported to Qt4 and works natively on OSX, Windows and Linux. And it can easily be installed in Ubuntu, getting a PPA for Lucid, Maverick and Natty.
LibreCAD: open source 2D CAD software
Install LibreCAD in Ubuntu:

For Ubuntu 10.04:

sudo add-apt-repository ppa:showard314/librecad
sudo apt-get update
sudo apt-get install librecad

For Ubuntu 10.10 and 11.04:

sudo add-apt-repository ppa:showard314/ppa
sudo apt-get update
sudo apt-get install librecad

Searching filesystem from command line

There are several commands available on the command line to locate files and folders on the file system. This article reviews three of them, viz whereis ,locate. find.

1) whereis
This command can search for  the binary, source, and manual page files for a comand

$ whereis  whereis
whereis: /usr/bin/whereis /usr/share/man/man1/whereis.1.gz

2) locate:   locate uses a database created by an updatedb to efficiently locate files. Works great, assuming your database is updated often enough to be reasonable upto date. Most boxes using locate have the updatedb occuring in cron.  On my ubuntu box, I got a long list of files when I tried to locate  command.   RTFM locate

$locate locate

3)  find: find is perhaps one of the most powerful commands there is.   However, find is slow compared to locate as it  recursively search the paths supplied to  it.

The syntax of find is specified like this.

find path-list expression

It may look rather cryptic. 
Even though the man page lists only three  parts for the command as above, 
for simplicity  we can imagine  that  find  syntax  is havng  four fields.               
1 2 3 4
find starting point find which files action on result

You can formulate your find command based on the above table. For example,
if you want to find all  avi files in a folder named movies

1 2 3 4
find movies -name “*.avi” -print
$find  movies   -name "*.avi"  -print

Here are some examples you can try

a) to find all directories on the system whose permissions of 777

$        find / \( -type d -a -perm -777 \)     -print

b) find all core files in home directories and remove them

$         find /home -name core -exec rm {}     \;


c) find all files owned by a particular user no matter whose home directory they are in:

$       find /home -user      -print

d) find all files that have been modified (or had their modification time changed) in the last 30 days:

$      find / -mtime -30 -print

e) find all tmp files older than 30 days and remove

$ find /dirpath \( -name \*.tmp -a -mtime     +30 \) -exec rm {} \;

The man page of find has several other option that you can try.