Click Technology Limited

Linux, Windows, Macs – it's all good!

See a file without comments..


Configuration files often come with a lot of commentary. Documentation is always good, but sometimes you just want the red meat. Here’s how to see a file without all the ‘#’ commentary.

grep ^[^#] /etc/someconfig.conf
posted under Linux Tips | No Comments »

How to download a YouTube video


If you want to download a YouTube video, here’s how. First install the youtube-dl binary and the associated codecs…

sudo apt-get install youtube-dl ffmpeg libavcodec-extra-53

Once it installs, get your YouTube URL and simply run the command..


to download the video. There are a load of other options you can use which are all shown thus..

youtube-dl --help

Conveniently, the youtube-dl command also does on-the-fly conversion of downloaded videos to just the .mp3 version for audio playback, thus…

youtube-dl -x --audio-format mp3

Where -x means ‘eXtract’. Again, there are a load of options here.

posted under Linux Tips | No Comments »

Display the fields in a MySQL table..


Simple command that you sometimes need. Obviously this runs from the mysql client prompt, so open a command line and type

mysql -u root -p

and then enter the root password for your mySQL database.

Then, switch to your database…

USE yourdatabasename;

An now, all you need is..

SHOW columns FROM your_table;


posted under Linux Tips | No Comments »

Your IP Address


You appear to be coming from the ip address below..

Reset user home directory permissions


Simple. Fire these three commands…

sudo chown -R bob:admin /home/bob
sudo find /home/bob -type f -print0 | xargs -0 chmod 0600
sudo find /home/bob -type d -print0 | xargs -0 chmod 0700
posted under Linux Tips | No Comments »

Backup and restore MySQL database quickly


Very simple. Use the following commands..

Backup to an external file.

On the *nix command line, just run..

mysqldump -u root -p database_name > /path/to/database_dump_file.sql

Punch in the password for root (in this case) and the backup is output to the file database_dump_file.sql. It’s ASCII so it can be edited if needed.

Restore from an external file..

mysql -u root -p database_name < /path/to/database_dump_file.sql

Typed the password and that's it, finished.

Need the database names quickly?

Log in to the database as ususal with the command at the *nix command line.

mysql -u root -p

And then issue the following at the prompt..

mysql> show databases;

and you get this....

| Database             |
| information_schema   |
| largedump            |
| dspam                |
| mysql                |
| performance_schema   |
| testdata             |
| testdata_1           |
| dataset_4            |
| dataset_2            |
9 rows in set (0.01 sec)
posted under Linux Tips | No Comments »

Ban a sender from sending you mail on Postfix


This is quite handy and easy to set up.

First, open up, the principal configuration file in Postfix. I use vim, but of course you can use whatever editor you like, e.g. vi, nano etc.

sudo vim /etc/postfix/

In your, add the following lines in the configuration

smtpd_sender_restrictions =
        check_sender_access hash:/etc/postfix/sender_access

Now, create a file to store the list of banned names.

sudo touch /etc/postfix/sender_access

and now edit it to add the banned names…

sudo vim /etc/postfix/sender_access

Add the banned addresses in the following format.. REJECT REJECT REJECT REJECT REJECT

Save the file. Now, create the hashed db file for this file..

sudo postmap /etc/postfix/sender_access

Now you should have a file in the /etc/postfix directory called /etc/postfix/sender_access.db

Now all you need to do is restart postfix.

sudo service postfix restart


posted under Linux Tips | No Comments »

What’s the command line to run Clamscan?


Here’s the command to run a complete scan but exclude the sys, proc, dev and lib directories.

sudo clamscan -r -i --exclude-dir='^/sys|^/proc|^/dev|^/lib' /
posted under Linux Tips | No Comments »

How do I downsize a Hi-Def movie?


In Debian / Ubuntu, use avconv.

avconv -i input.mp4 -b 64k -s hd720 -strict experimental output.mp4

This command uses avconv, where..

-i input.mp4 = the input file name
-b 64k = down sample the audio channel to 64k – should be fine.
-s hd720 = reduce the video from hd1020 to the 720 format
-strict experimental = Allows mp4 output
output.mp4 = the output file.

If you haven’t got avconv installed, use

sudo apt-get install avconv

and follow instructions.

posted under Linux Tips | No Comments »

How do I quickly process photos for upload to the internet?


In Linux, the easiest way to process images is using imagemagick. It is a command line program you can use to manipulate images very quickly. With it, you can scale images, adjust proportions, add watermarks and alot lot more.

These days, with photos from your camera tpyically of the order of 1.2 – 2.5MB in size, uploading them to the internet in bulk is the stuff of dreams, so better to scale them all down and then upload. Here’s how.

Step 1. Install imagemagick.

Open a terminal window using CTRL + ALT + T

Now, install imagemagik..

sudo apt-get install imagemagik

Now let’s try some examples…

First off, copy the photos you want to modify to a new folder, so you have the originals intact, otheriwse you will modify the originals. Bad idea.

We’ll call this folder /home/darth/pics in these examples.

Reduce the photo called hoth.jpg by 50%

mogrify -resize 50% /home/darth/pics/hoth.jpg

Scale the image to be 1024 pixels wide and whatever number of pixels high, scaled in proportion…

mogrify -resize 1024x /home/darth/pics/hoth.jpg

Scale the image to be 500 pixels high and whatever number of pixels wide, scaled in proportion…

mogrify -resize x500 /home/darth/pics/hoth.jpg

Strip the image of all exif data, so remove make and model of camera, GPS data, flash, shutter and aperture speed, etc. etc.

mogrify -strip /home/darth/pics/hoth.jpg

Do the whole freakin’ folder! (Rotate the photos as required, reize them to be 1024 pixels across the top and do that for all jpegs in the folders and subfolders in /home/darth/pics/deathstar

mogrify --auto-orient -strip -resize 1024x /home/darth/pics/deathstar/*/*.JPG

There are a bajillion more possibilities and commands and options in the suite. Check it out.

posted under Linux Tips | No Comments »
« Older Entries