Click Technology

Linux, Windows, Mac it's all good

Copy or backup MySQL tables

September23

This is a very simple and very effective procedure. Log on to your server and then log on to your database with the usual command..

mysql -u root -p

and enter your password.

Select your database using the command

USE your_database_name;

Then, use the following commands..

To copy the table and the data…

CREATE TABLE your_table_backup SELECT * FROM your_table;

To copy the table structure only, no data, use…

CREATE TABLE your_table_backup SELECT * FROM your_table LIMIT 0;

Nice.

posted under Linux Tips | No Comments »

See a file without comments..

September22

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

Golden.

posted under Linux Tips | No Comments »

How to download a YouTube video

September19

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..

youtube-dl http://www.youtube.com/watch?v=Z3W05t79ZWY

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 http://www.youtube.com/watch?v=Z3W05t79ZWY -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..

September18

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;

OR

SELECT COLUMN_NAME' FROM 'INFORMATION_SCHEMA'.'COLUMNS'
WHERE 'TABLE_SCHEMA'='YOUR_DATABASE'
AND 'TABLE_NAME'='YOUR_TABLE';

Nice.

posted under Linux Tips | No Comments »

Your IP Address

September17

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

3.144.230.82

Reset user home directory permissions

September15

Simple. Fire these commands to reset your user and also secure their gpg keys / files as well.  The user name will be substituted automatically.

sudo chown -R $USERNAME:$USERNAME /home/$USERNAME
sudo find ~ -type f -print0 | xargs -0 chmod 0640
sudo find ~ -type d -print0 | xargs -0 chmod 0750
sudo chmod 600 ~/.ssh/id_rsa
sudo chmod 740 ~/Desktop/*.desktop
sudo chmod 600 ~/.gnupg/*
sudo chmod 700 ~/.gnupg
posted under Linux Tips | No Comments »
« Older EntriesNewer Entries »

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.