tail -f findings.out

Tune MySQL like a pro with MySQLTuner

I don’t know why I didn’t know about this before (or why I forgot about it, more likely), but I came across MySQLTuner recently and was most pleasantly surprised. It’s a Perl script that only requires your MySQL user and password to provide detailed and useful checks of a running MySQL instance. First though, check out the awesome URL you download it at:

1
wget mysqltuner.pl

Yeah, that’s the actual URL that works. Pretty sweet.

Anyway, next you make it executable, run it, enter creds:

Get MySQLTuner running

Then the goodies appear:

MySQLTuner Results

Oh, that query_cache_limit is tiny! At this point, no changes have been made to your setup. But at a glance you get helpful stats, validate that changes you’ve decided to make are in place, and get alerted to potential improvements.

If I knew Perl now and refreshed my MySQL tuning knowledge, I’d love to help as a maintainer of this lovely script. Maybe sometime soon…

Tags: , , ,
March 13, 2010 - 6:22 PM No Comments

Converting multiple images to one PDF on Linux

There are a number of ways you can go about the process of converting image files into PDFs, most simply by opening a given image and printing it. You can select “Print to file” instead of a printer device, PDF format is the default for this type of output. But say you have a folder full of images and you want to make one big PDF of them. Here’s how you can do that:

1
2
3
4
5
6
7
cd FOLDER_WITH_IMAGES
FILES=$(ls *jpg)
mkdir temp && cd temp
for file in $FILES; do BASE=$(echo $file | sed 's/.jpg//g'); convert ../$BASE.jpg $BASE.pdf; done &&
pdftk *pdf cat output ../FINAL_NAME.pdf &&
cd ..
rm -rf temp

This loops through all the .jpg images in the directory and converts them to a PDF file of the same name. Once that is done they are all combined into FINAL_NAME.pdf by pdftk, a handy PDF utility. The temp dir business is there to make the temp PDF file removal easier.

Tags: , ,
February 21, 2010 - 1:12 PM No Comments

Quick tips for NVIDIA and ATI graphics configuration repairs on Ubuntu

While graphics card and display configuration on Ubuntu has come a long way from the days of always having to edit xorg.conf by hand, I still run into issues now and again. I almost never have problems any more when setting up a new system. But changing cards in an existing system is another story, especially if switching between NVIDIA and ATI.

Today I did indeed switch from an NVIDIA to an ATI graphics card on an Ubuntu 9.10 machine. I had the nvidia-glx kernel mod in place, and xorg.conf specified the NVIDIA related modules to load, so just switching out the card and rebooting resulted in a flickering text login, no more desktop. This post covers the commands needed to install the appropriate kernel module and reconfigure Xorg in such situations.

After putting in your new card if you aren’t able to get to your desktop/get sent to a text login when you boot/get an Xorg error, reboot and hit Escape when GRUB prompts you. Boot into the recovery mode for the latest kernel shown in the list. Drop into root prompt with networking when prompted.

NVIDIA to ATI

This assumes you have an ATI card in place. Once at the root prompt run:

1
apt-get install xorg-driver-fglrx

This will remove nvidia-glx if you have it installed and install the driver for ATI Radeon and FireGL graphics cards. After this is complete you need to reconfigure xorg.conf to use the new module. Fear not, no manual editing should be required to get a basic configuration working. Just run:

1
aticonfig --initial

This script comes with the xorg-driver-fglrx. Running this will add screen and device sections in /etc/X11/xorg.conf appropriate for an ATI card, backing up /etc/X11/xorg.conf beforehand. If you added any special configurations for your screen section before you might want to edit the file manually and copy the customizations into the appropriate new sections. The sections already in xorg.conf will still be there, just commented out or not actually called when loading X. Next run:

1
startx

If all goes well you will be back to a working desktop. You can also check from the command line by running “fglrxinfo”.

For more information on using the ATI drivers on Ubuntu see this wiki article.

ATI to NVIDIA

And in the reverse situation:

1
2
3
apt-cache search nvidia-glx
# Install the latest stable one. Currently:
apt-get install nvidia-glx-185

And the equivalent for aticonfig:

1
nvidia-xconfig

As above:

1
startx

For more information on using the NVIDIA drivers on Ubuntu see this wiki article.

No guarantees here, but these have worked for me.

Tags: ,
November 4, 2009 - 9:15 PM Comments (2)

Viewing all users on a Linux system

There are a number of widely-used and stable utilities on Linux systems that allow you to view information related to users. You can see who’s logged in with who, get info on a particular user with finger, see who you are with whoami and see who logged in last with last and lastlog. And there are commands to create, remove, and change users and their groups.

But what if you just want to see all the users defined on the entire system? Looking in /home won’t show you users that don’t have a home dir or one not located there. All users are indeed listed in /etc/passwd, but having to look through this file every time you just want a list of users is tedious. I haven’t found a utility that performs this role.

This was somewhat surprising, as it’s not an uncommon need. Perhaps I’ve missed some essential program along my Linux journey. If so, feel free to enlighten me in a comment :-) In the meantime, let’s fill this gap:

1
2
3
4
5
6
7
8
9
10
11
12
# Prints all users, divided by login ability and homedir:
function userinfo {
    echo "----- Users that can login -----"
    awk -F":" '!/bin\/false/ { print "username: " $1 ", uid: " $3 ", homedir: " $6 }' /etc/passwd

    echo -e "\n----- And have /home dir -----"
    awk -F":" '!/bin\/false/ && /\/home/ { print "username: " $1 ", uid: " $3 ", homedir: " $6 }' /etc/passwd

    echo -e "\n----- Users that can't login -----"
    awk -F":" '/\/bin\/false/ { print "username: " $1 ", uid: " $3 ", homedir: " $6 }' /etc/passwd
    echo ""
}

This function should work on any *nix system. Place it inside your ~/.bashrc, reload that (. ~/.bashrc), and try out “userinfo”:

userinfo

Three sections are displayed showing usernames, user IDs, and homedirs for users in /etc/passwd who:

  • Don’t have /bin/false for a shell (i.e. users that can login)
  • Also have a homedir under /home (i.e. the users that aren’t for system processes)
  • Do have /bin/false for a shell (i.e. users that can’t login)

Note that the users that can login category only shows users to which one could switch with “sudo su – USERNAME” from a shell. This doesn’t mean anything about whether they can login via SSH or other access methods.

Tags: , , ,
October 4, 2009 - 3:35 PM Comments (7)

Permanently remember password for gksudo

I’m all about security practices on my remote server systems. On my firewalled desktop systems, however, I’d rather err on the side of convenience. I prefer to not have to type my password to use sudo or gksudo (graphical sudo). If I type my password to login to my account once, I want to have access to everything unfettered thereafter.

While there are plenty of posts on how to get sudo without password going, I never could seem to find information on how to do this for gksudo as well. So here’s how to do that.

First open the gconf-editor (gnome configuration):

1
gksu gconf-editor

Once that opens, go to /apps/gksu, and check “save-to-keyring”:

gconf_gksu

This will remember your password for gksudo, so you won’t get any more auth popups.

Tags: , ,
September 26, 2009 - 10:44 PM Comment (1)

« Older Entries

Twitter links powered by Tweet This v1.6.1, a WordPress plugin for Twitter.