List files installed by a package (RPM and APT based distributions)

RPM:

  1. Install yum-utils with:
    yum install yum-utils
  2. Make your query:
    repoquery --list *package_name*
  3. Sample:
    $ repoquery --list httpd 
    /etc/httpd
    /etc/httpd/conf
    /etc/httpd/conf.d
    /etc/httpd/conf.d/README
    /etc/httpd/conf.d/welcome.conf
    /etc/httpd/conf/httpd.conf
    …

APT

  1. Just type your query:
    dpkg -L *package_name*
  2. Sample:
    $ dpkg -L apache2
    /.
    /usr
    /usr/share
    /usr/share/bug
    /usr/share/bug/apache2
    /usr/share/bug/apache2/control
    …

Simulate load on linux serve with one-line command

Some days ago I needed a quick way to simulate load on a Linux sever. While there are many tools that can do this, all I needed was a simple bash one-line command that can make the CPUs beg for mercy.
What I ended up using is this:

dd if=/dev/zero bs=100M | gzip | gzip -d | gzip | gzip -d | gzip | gzip -d > /dev/null &

Send a few of these to the background and you’ll start seeing smoke coming from your server soon.

Howto backup and restore MySQL database with character set intact

If you want to preserve characters like ñ, ó, ç, etc. when migrating a MySQL database use mysqldump to export the database with this options:

 mysqldump -u root -p --default-character-set latin1 --skip-character-set <dbname> > mydump.mysql

create the target database with:

mysqladmin -u root -p create <dbname> --default-character-set latin1 --collate latin1_swedish_ci

then restore:

mysql -u root -p --default-character-set latin1 <dbname> < mydump.mysql