Posts tagged ‘Linux’

restoring a MySQL dump on a freshly installed debian/ubuntu system

to restore a dump from a MySQL database created on a debianish Linux system, just feed the dumped SQL to the command-line mysql client like this:

mysql -u root -p < mysql-all-2010-03-28-0515.sql

since the whole content of all MySQL databases are overwritten with that stored in the dump, credentials are affected as well. that’s the reason why debian’s system tools won’t work any more after restoring the old dump, since debian creates a maintenance-user called “debian-sys-maint” during the installation and stores the randomly generated credentials in “/etc/mysql/debian.cnf” so it’s sufficient to just copy the “password” values from the old file into the new one and restart mysql. otherwise, you will run into an error like this:

/etc/mysql/debian-start[3181]: Running 'mysqlcheck'...
/etc/mysql/debian-start[3181]: /usr/bin/mysqlcheck: Got error: 1045: Access denied for user 'debian-sys-maint'@'localhost' (using password: YES) when trying to connect
/etc/mysql/debian-start[3181]: FATAL ERROR: Upgrade failed

my mdadm notes…

examine the superblock of a device:

mdadm --examine /dev/sdd1

re-assemble an array when autodetection fails:

mdadm /dev/md0 --assemble --force /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/dm-6

hotplugging SATA harddisks in Linux

That’s just a few records on my personal experience regarding the hot-swapping/hot-plugging capabilities of SATAContinue reading ‘hotplugging SATA harddisks in Linux’ »

find changes in config files (debian/ubuntu)

want to know which files in /etc have been changed on your debian-like Linux system?

one part can be done with the package debsums, which compares the md5sums delivered with a debian-package with those of the current files:

$ sudo debsums -a -s
.
.
debsums: checksum mismatch apache2.2-common file /etc/apache2/sites-available/default
debsums: checksum mismatch apache2.2-common file /etc/apache2/ports.conf
.
.

Note 1: this does NOT cover configuration files that are not part of the .deb-package itself, e.g. those manually created by a user AND as well those built by a package’s configuration/post-install scripts. You have been warned!

Note 2: debsums can give hints about a compromised system, but it’s absolutely no guarantee that a non-suspicious output comes from a clean system – if the system’s compromised, an attacker could as well change the md5sums-database of a package (residing in /var/lib/dpkg/info/PKGNAME.md5sums)

sed magic, including explanation

sed one-liners explained, this one is outstanding: Famous Sed One-Liners Explained, Part I: File Spacing, Numbering and Text Conversion and Substitution

stumbled upon this while trying to paginate text with (gnu) sed, aka reformatting text to a given line width. suppose you want to add linebreaks to a text so no line is longer than, say, 4 characters:

echo "0123456789ABCDEFGH" | sed 's/.\{4\}/&\
/g'

NFS on a symbian-phone?

create deb-packages from perl-modules

MySQL backup user

to create a user for doing automated backups of a MySQL installation that doesn’t have more than the necessary privileges, use the following statement:

GRANT RELOAD, SELECT, LOCK TABLES ON *.* TO 'backup'@'localhost' IDENTIFIED BY 'some_reasonable_password';

clean up frozen mails in exim queue

for mail in $(sudo mailq | grep frozen | cut -c 11-26) ; do
    sudo exim4 -Mrm $mail
done

extend or adjust the grep-pattern as required by your situation…

git and svn

by far the best article I’ve read for somebody used to subversion (and tied to an SVN-repo) who wants to use git locally:

Git-SVN: Whys And Hows

thanks!!