Query to list top 10 largest tables in MySQL DB

mysql> SELECT concat(table_schema,'.',table_name) table_name,concat(round(data_length/(1024*1024),2),'M') data_length FROM information_schema.TABLES ORDER BY data_length DESC LIMIT 10;

lftp connection : Access failed: 521 Data connections must be encrypted

If during an lftp session you get the error message:

get: Access failed: 521 Data connections must be encrypted. (xxx.tar.gz)

You will need to set this variable:

lftp username@host.com:/> set ftp:ssl-protect-data true

Grep text in PDF’s using pdftotext

If you ever need to grep some specific tags in a bunch of pdf files, you can use the following one liner, e.g:

for FILE in $(find /home/user/Desktop/downloads/ -name "*.pdf" 2>/dev/null -mtime -1 \! -type d -exec ls {} \;); do pdftotext $FILE - | grep -o 'BZ [0-9]\{5\}';done

Cannot open shared object file

I get the following error when executing a binary file:
error while loading shared libraries: libcrypto.so.4: cannot open shared object file: No such file or directory

This error is likely to occur either because you have not properly defined your $LD_LIBRARY_PATH or the file is simply missing.

To debug try the following:

ldd {binary_file}

or to get more verbose information:

export LD_DEBUG=libs;{binary_file}

for more options:

export LD_DEBUG=help;{binary_file}

Encrypt/Decrypt a file using openssl

Encrypt the file:
openssl des3 -salt -in file.txt -out encrypted_file.txt

Decrypt the file:

openssl des3 -d -salt -in encrypted_file.txt -out decrypted_file.txt

Last.fm from the command line

If you are a command line addict, you can download shell-fm and start listening Last.fm from there.

Links to customize it:
http://jdin.blogspot.com
http://shell-fm.wikidot.com/extending-shell-fm

Extend tempdb in Sybase

The transaction log in database tempdb is almost full. Your transaction
is being suspended until space is made available in the log.

If you are getting this error message you can extend tempdb running the following commands:

disk init name ="extra_tempdb", physname ="/opt/sybase/data/extra_tempdb", vdevno=8, size=512000
alter database tempdb on extra_tempdb = 500
alter database tempdb log on extra_tempdb = 500

Fsniper

fsniper allow to monitor your folders and trigger some actions based on the type of files you have there.

Example: ~/.config/fsniper/config
PDF files downloaded from Firefox on the desktop, get moved to ~/Desktop/pdf.

watch {
~/Desktop {
*.part {
handler = echo ignoring file: %%
}
application/pdf {

handler = mv %% ~/Desktop/pdf
}
}
}

Fsniper can be run in daemon mode:

fsniper --daemon

usermod, groupadd

Add group with specfic id:
# groupadd -g {gid} {group}

Add existing user to existing group:
# usermod -G {group} {username}

Check to which group a user belong:

# id -nG {username}

Remove existing user to existing groups (group1,group2,group3.group4), e.g remove it from group3:

# usermod -G {group1,group2,group4} {username}

Extract sample dataset from a mysql database using mysqldump

mysqldump --opt --where="true LIMIT 1000000" mydb > mydb1M.sql

    On 1 specific table:
mysqldump --opt --where="true LIMIT 1000000" mydb mytable > mydb_mytable_1M.sql
    Restore:

mysql -p mydb_1 < mydb1M.sql