Archive for the ‘Linux’ Category

Quick Tip: IPTables port forwarding in 1 Line

iptables -A PREROUTING -t nat -p tcp -i eth0 –dport 88 -j DNAT –to 192.168.1.2:22

Quick Tip: Erase a drive (insecurely) in 1 Line

sudo dd if=/dev/zero of=/dev/sdx bs=512 count=1
where sdx is the drive you want to zero (this is an INsecure wipe)

Linux: Replace WiCD with Network Manager

apt-get install -y network-manager-gnome

cat /etc/network/interfaces
cp /etc/network/interfaces{,.backup}
ls /etc/network/interfaces*
/etc/network/interfaces /etc/network/interfaces.backup
echo “Wanna buy a “{cat, dog, cow}”?”
cat /etc/network/interfaces
echo “auto lo” > /etc/network/interfaces
cat /etc/network/interfaces
echo “iface lo inet loopback” >> /etc/network/itnerfaces
cat /etc/network/interfaces
service network-manager start

nm-applet &

Linux: Add menu items to GNOME

These text files can be found in /usr/share/applications/.

Before you start making the text file for your own menu link, you need to either find an icon to use that’s already in the pixmaps folder, or make an icon & place it in the pixmaps folder yourself.
The pixmaps folder is the standard folder for holding the icons of programs & can be found at /usr/share/pixmaps/.
Icons need to be 48×48 pixels size wise & in the .png format.
Once you have your icon sorted out, you can start creating your link..
sudo gedit /usr/share/applications/nameofyourprogram.desktop
Make sure that the name of your programs all lower case letters only & you must add .desktop to the end of it..

Example: speedpad.desktop

Sec: How to Import and Verfiy GPG Keys

How to Generate PGP Keys

Run the following commands on your local workstation:

* Note: You will have to run the same command to initialize the directory (step 1) and to generate the key (step 2).

  1. Initialize the GPG Directory*

    gpg --gen-key 

    gpg (GnuPG) 1.0.6; Copyright (C) 2001 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: /home/keymaster/.gnupg: directory created
    gpg: /home/keymaster/.gnupg/options: new options file created
    gpg: you have to start GnuPG again, so it can read the new options file 

  2. Generate a Private Key*

    > gpg --gen-key 

    gpg (GnuPG) 1.0.6; Copyright (C) 2001 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: /home/keymaster/.gnupg/secring.gpg: keyring created
    gpg: /home/keymaster/.gnupg/pubring.gpg: keyring created
    Please select what kind of key you want:
    (1) DSA and ElGamal? (default)
    (2) DSA (sign only)
    (4) ElGamal? (sign and encrypt)
    Your selection? 1
    DSA keypair will have 1024 bits.
    About to generate a new ELG-E keypair.
    minimum keysize is 768 bits
    default keysize is 1024 bits
    highest suggested keysize is 2048 bits
    What keysize do you want? (1024) 4096
    you really need such a large keysize? y
    Requested keysize is 4096 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) 0
    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 Real Name, Comment and Email Address in this form:
    "Heinrich Heine (Der Dichter) "
    Real name: Your Real Name
    Email address: youremail@foo.upenn.edu
    You selected this USER-ID:
    "Your Real Name"
    Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o
    You need a Passphrase to protect your secret key.
    Enter passphrase: pickapassphrase
    Repeat passphrase: pickapassphrase
    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.
    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++. ...
    you may see
    ...
    Not enough random bytes available. Please do some other work to give
    the OS a chance to collect more entropy! (Need 290 more bytes)
    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.
    +++++++++++++++.+++++++++++++++.+++++++++++++++++++++++++.

  3. public and secret key created and signed.
  4. Generate and print a copy of your public key ID and fingerprint 

    >gpg --fingerprint 

    An an example of the fingerprint output, here is the output of the NMLUG Keymaster's fingerprint:

    pub 1024D/14931423 2003-02-13 New Mexico Linux User Group Keymaster
    Key fingerprint = 724D 2514 93EC 83D4 E5BC D534 C5BC C12C 1493 1423
    sub 2048g/42685AC7 2003-02-13

Sec: Import and Verify GPG

gpg –keyserver keys.mayfirst.org –recv-key 139A768E

gpg –list-sigs 139A768E

COPY PGP KEY
gpg –verify
Then paste it.
Control-d
sha1sum

Quick-Tip: Spoof Your MAC Addresses in Linux & OS X without 3rd Party Apps

This simple miracle doesn’t even require macchanger and can be run as a cron job with a randomized MAC address:

ifconfig en0 | grep ether <shows your  MAC>

sudo ifconfig en0 ether 00:e2:e3:e4:e5:e6
ifconfig en0 | grep ether
alternatively:
airport -z
sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport /usr/sbin/airport
sudo ifconfig en0 Wi-Fi aa:bb:cc:dd:ee:ff
or
sudo ifconfig en0 ether aa:bb:cc:dd:ee:ff

Quick Tip: Query InfiniDB on a Linux LAN/WAN

InfiniDB is a proprietary SQL-like DB. You can query it much like a MySQL DB on a Bash command line:

 

mysql -q -r -h 10.00.0.0-u root hsa_infinidb -e “SQL QUERY GOES HERE” >outfile.tsv
where db represents whatever your InfiniDB server is named an 10.00.0.0 represents the LAN/WAN IP address of your server/cluster.
An outfile is optional, but usually better than having your results print to the screen.

Quick Tip: How to Free Up Resources for Big Data Scripts in Linux by Checking Processes, Killing Duplicates, Tailing Log

ps -ef
sudo kill -2600 1982 999
tail -f myscript.log
Where “2600”, “1982”, and “999” represent the PPID’s you wish to kill, which you looked up with the ps -ef command.

Optionally filter the process list by changing the first command to:

ps -ef | grep -i keyword