Useful shell commands: last

Today I will start a new series for linux/*nix newbies called Useful shell commands. Every now and then I will write about one of the powerful commands you’ll find on your shell. I will start the series with a command called last.

# last

Calling last on your commandline gives you a list of logins. You will see who is still logged in and who was logged in before from what adress.

You can shorten the list of results with last -n XX. XX being the number of results you want to have displayed, e.g. last -n 5 for 5 lines.

# last reboot

Calling last reboot lists the reboots since the log file which tracks all logins was created.

The manual page for last – man last – will show you more parameters.

Don't miss a post with our RSS feed! Or get free updates by email.


High available NFS4 server with drbd 0.8, pacemaker 1.0, heartbeat, openais on OpenSUSE 11.1

For my podcast project I got five new root servers which are all connected internally through a switch. Two of the servers are connected directly over a crossover cable. Those two servers have 3 NICs, the other 2 servers have 2 NICs.

I share the website’s HTML, images and other resources through the NFS server to all five servers. All servers work as webservers with nginx and PHP-fpm. Each server also runs one more specific service: database master, solr master, cron jobs / crawler processes, Varnish / HAproxy.

The two directly connected servers share the static website resources over drbd. Pacemaker, heartbeat and openais secure the high availability of my NFS4 server. Setting this up took quiet a bit of fiddeling as there are how-tos for so many different (and outdated) versions are floating around the internet.


php-fpm runlevel start script for OpenSuSE 11.1

Nowadays OpenSUSE comes with almost all packages I need to run a fast and reliable webserver. As I have written before I use nginx and php-fpm for our podcast service.

You can get up-to-date packages of nginx through OpenSuSE’s build service. I have not yet found a RPM package of php-fpm though. Therefore I compile it myself. This works well and I have the advantage that I can customize by PHP package.

But there is also one disadvantage. There is no system runlevel script available this way. So you cannot make use of the rc stuff on OpenSuSE and start PHP at boot time. As I have quiet a few machines to administer I decided to write my own runlevel script to start php-fpm.

Looking closer into the stuff that is already delivered with the php-fpm package is a powerful start script. I took it as the basis of my script. I had to modify it only in a few places. Big thanks to the author(s)!

It will take a few easy steps to get php-fpm running after booting.

  1. Download my modified php-fpm script to your server’s runlevel directory (/etc/rc.d).
  2. Rename the file by removing the file extension (.txt)
  3. Give your superuser (root) rights to execute it.
  4. Open the file php-fpm in your favorite editor (Vim, emacs, joe, …).
  5. Modify the three lines (php_fpm_BIN=, php_fpm_CONF=, php_fpm_PID=) on top to match your installation directory of php-fpm.
  6. Save and close the file.
  7. Start yast with yast runlevel and switch to expert mode with Alt+x
  8. Activate php-fpm for runlevels 3 and 5 (or whatever suits you). Save your changes with Alt+o. That’s it!

Now your php-fpm installation starts on boot. If you ever have to reboot your machine you do not have to think about starting php-fpm manually as the system does it for you.

Let me know if this was helpful for you, if it works and if you have any questions!


How to find out user id on linux system

For a mount command I needed to find out what user id my user account had. There are several ways to find out. As root you could look into the passwd file (most likely /etc/passwd) or on OpenSuSE use the Yast user module. But I was looking for a way to find out my user id with my ordinary user account. The command I was looking for is id. Just open up a shell (konsole on KDE4) with your active user, type id and you get all the information about your user including groups and their ids. If you just want to know the user’s id, e.g. for a shell script use

id -u USERNAME

and you get back just the id of the user. Simple as that!


System upgrade openSUSE 11.0 to openSUSE 11.1 with zypper

I had to set up a server. The hoster offers openSUSE 11.0 at the moment but no openSUSE 11.1 yet. As I like to go with the latest and greatest I decided to upgrade the system to openSUSE 11.1 after using the hoster’s installation image for openSUSE 11.0. I searched on the web how a system upgrade should be done this time. (It seems to differ all the time.) I found a zypper command chain. Change the installation reposotories in /etc/zypp/repos.d to the new version and type:

zypper refresh
zypper dist-upgrade

I did excatly that. It did refresh a few packages but as I guessed immediately not enough. I tried over. It did not help. Here is the solution. Delete all subdirectories in /var/cache/zypper and execute the commands above again.


New software packages bundled with OpenSuSE 11.1

The newest version of OpenSuSE got released today. OpenSuSE 11.1 brings more than 230 new features the press release says. As I keep my systems up to date thanks to smart and all the repositories only a number of these new feature are missing on my OpenSuSE 11.0 installations. The most important reason I quickly upgrade my desktop system is KDE. As I am still using KDE version 3 and the version that comes with OpenSuSE 11.1 is the same I have installed (KDE 3.5.10) this does not convince me to upgrade.

I did however discover new software (packages) in OpenSuSE 11.1 I have not known before. These packages are Tasque, Tellico, Twinkle, Monsoon, PulseAudio and Derby. I googled these terms and came up with the following.

Read the rest of this entry »


The open source application stack for Windows

The bad thing with most new computers is that they come with Windows ™ preinstalled. The good thing is those Windows ™ installations don’t bring much (useful) software along. Users have to actively use which software they want to use.

Read the rest of this entry »


ejabberd on GNU/Linux OpenSuSE 11.0

I heard about the successful usage of ejabberd from weblin’s CTO Heiner yesterday at lunch during BarCamp Hamburg 08.

I was thinking of deploying jabber services for podcast.de for a while now but couldn’t decide which server to take. I checked the ejabberd website. The software looks promising. So I give it a try.

smart install ejabberd

Could not find any results. So I check OpenSuSE software search. Luckily it lists a source which I add to my smart sources.

Read the rest of this entry »


Free e-book shellprogramming

I had to write a shell program. And I was looking for a how-to / manual covering my favorites shell command set. I found a nice e-book on Wikibooks: Linux-Kompendium: Shellprogrammierung which helped me a lot. Hence the link for other people.


Apache and lighttpd replaced by nginx for PHP application

A while back I wrote an article Switching from Apache HTTP Server to Lighttpd – Installing Lighttpd. Back then I migrated static stuff to lighttpd but left the dynamic stuff (PHP) with Apache.

I was never really satisfied with the speed of our system under load. I tried and tried. I optimized a lot of stuff in the backend and with the database. Most of the time I found a switch to make the system just a bit faster. Read Retrospective on three years of Seagull development if you are interested in the whole story.

Read the rest of this entry »