Find out stuff about your system from bash

Another post in the "no X server"-section - find out useful stuff from a shell:
  • kernel? uname -a (thanks, DaWuzzz)
  • How long has the machine been running? uptime
  • Who is logged in? finger
  • Short general information (hardware, kernel): sysinfo (package hxtools)
  • Which distro am I on (for remote administrators or extremely confused users)?
    ls /etc/*-release
    less /etc/<thedistro>-release
    (more information here)
  • Did I install this package? rpm -qa | grep -i <any part of package name> (you need grep if you don't know the exact package name: rpm -q doesn't like wildcards)


openSuSE and quota

If you ever have to setup a file server, e.g. published via SAMBA, you normally will set local quota in order to keep the hard drive usage under control. The standard commands to deal with quota are


You will have to enable quota in /etc/fstab for the mountpoint you want to use it:
open fstab with vi as superuser and add "usrquota,grpquota" to the options. The changed line might look like this:
/dev/sdb1 /home ext3 suid,dev,acl,usrquota,grpquota,user_xattr,exec 0 2

Remember, only native linux file systems will have the possibility to set quota.
Now you need to create the files where the quota information is stored:
being superuser, command:
touch /partition/aquota.user
touch /partition/aquota.group (if needed)
chmod 0600 /partition/aquota.*
The files aquota.* should be owned and read-writable for root only.
Remount the partition you just prepared quota for.
mount -o remount /partition
To edit quota for a user, use /sbin/edquota as superuser (it is essentially a vi).
To switch on quota, use /sbin/quotaon -avug, to switch off quota /sbin/quotaoff -avug
If you want to get a usage statistic use the command
/sbin/repquota -avug.

Finally, if everything works, you might want to have quota enabled by default at system startup. For openSuSE (found for 10.2, 10.3 and 11) this is easily achieved by commanding
cd /etc/init.d
insserv boot.quota
as superuser and rebooting the machine.

Warning: Never never never (I really mean it) install quota on the mountpoint / otherwise you might get into trouble if root cannot login any more, because the file space available for root has reached the limit...


openSuSE grub and exchanging hard drives

One very strange feature of the openSuSE grub is that it addresses all partitions with "device-by-id". Works perfectly reasonable as long as you don't want to transfer an existing installation on another hard drive. In this case remember to change all device references in the following files:
(remember to back up the original ones first)
otherwise you will be left with an unbootable linux after having it successfully copied to your new hard drive.

You can do all these changes being root in a live linux of your choice.

SuSE KDE 4 rant

Dragging myself kicking and screaming into the 21st century, I resolved not to ignore KDE 4 completely any more - i.e. using it for serious work and longer than 3 minutes.
First impressions: more or less useable. Compiz works OK. Plasma crashes every time I change something in the panel (restarts again immediately, though). I still have to find out how to make my widget settings permanent.
Being in a rather daring and experimental mood, I checked out Amarok 2 beta 2 (I can't wait for the final release). You will find the RPM on KDE4:UNSTABLE; however, you can't install that on openSuSE standard KDE4, as it requires KDE >= 4.1.2 and openSuSE is still banking on 4.0.4.
KDE 4.1 has been out since July and SuSE is still shipping it from Factory only? Installing stuff from factory is just something I don't like doing, even in such tiny and insignificant cases as my desktop environment. Ironically, 4.1.x is supposed to be a major improvement to the notoriously buggy 4.0.4 (which would be the default desktop in a plain SuSE installation, btw). Well, apparently they keep 4.1.x up their sleeve till the openSuSE 11.1 release sometime in December.
Why oh why can't they do it a bit more modularly? For one, keeping people waiting half a year for an important bugfix release is not a very nice thing to do, and even when 11.1 is out, I don't want to do a complete OS update just to brush up my desktop and update my favourite audio player. (To be fair, I wouldn't put it past them to parallelly release 4.1.x for 11.0 - but still: December?)
Enough italics for today. Still disappointed.
Update: The opensuse download page displays an one-click installer for 4.1.3 stable by now. Didn't try it because all my systems run on factory for reasons mentioned above - though daWuzz had some trouble with strange dependency conflicts.

Linux Swiss Army Knives for exchanging hard drives

One of the very basic problems: you have to exchange a harddrive, either because it is about to fail or it has simply become too small for the job, but of course you don't want to reinstall all your OS's and data. Here are some tools which might help you rescuing your cherished Windows, Linux and all your settings.

  1. Have a computer with a CD-ROM drive and enough RAM ready.
  2. (Can't say it often enough) BACKUP ALL YOUR IMPORTANT DATA!
  3. Download a live-cd of Gparted.
  4. Get a Live-CD of your favourite flavour just in case you need to work with a console . I like to use Xubuntu, because the desktop environment is saving resources and I need the shell most of all anyway.
  5. Get the CD version of Super-Grub.
  6. Set the drive jumpers (master/slave) accordingly to the setup in your machine.
    If you use P-ATA 2.5'' drives, get a 3.5'' to 2.5'' adapter for each of them to be able to connect it to the normal IDE bus.
Now start your computer with the GParted live CD. The process of copying and enlarging partitions is self-explaining within the graphical interface of GParted.

In my case, the Windows system partition as well as the ntfs data partition and the linux ext3 home partition were copied almost perfectly; however, the Linux system partition was entirely corrupted. I restored it via dd, see this post about dd, this post about mounting images and this post about mounting network shares

Now you have a nice and resized copy of your OS's on the new hard drive. Plug it into your destination computer. BUT: booting will still be a problem, since you never copied the Master Boot Record (and be very careful about fiddling with the MBR, you might kill all your data)

Here the SuperGrub disk kicks in: just boot from it and choose super-grub. The disk will rewrite an appropriate boot sector code and will enable you to boot at least one of your OS's. BTW: it can also restore a Windows XP MBR, if you just happen to have only this OS...


Security bugfix in CUPS 1.3.9

Once again according to Heise, CUPS 1.3.9 fixes some possible exploits, so I was a bit miffed to find nothing more recent than 1.2.12 in the openSuSE main repos (on 10.3, at least).
However, CUPS 1.3.9 is available from the openSuSE Printing repo.


Spontaneous Audio failure

Tried to play an mp3 this morning. Amarok message: "xine was unable to initialize any audio drivers" Mplayer: "jack cannot open server". Had a slight déjà vu and kicked myself for not having logged what worked in my case, which was deleting the card in Yast->Hardware->Sound and having in autoconfigured again afterwards.
No risk involved, provided you did not configure the card by hand and don't care about losing the old config.

N.B.: This happened on Xanthippe, Tisiphone and Archimedes consecutively. Is it just me???


Network print on a Windows machine

Here is the howto for connecting to a Windows printer from Linux

Prerequisites: installed samba (maybe samba-client is sufficient), cups, ghostscript, foomatic-filters (most of them are default anyway), the printer must be shared and accessible over the network.

  1. Open a browser of your choice and type localhost:631 into the address bar
  2. Click "Add printer" and fill name, location and description and continue
  3. For device choose "Windows Printer via SAMBA"
  4. Device-URI: smb://<windowsboxname>/<printersharename> - no port required, so leave it empty
  5. Choose the model of the printer - if the driver is not in the database you'll have to provide the ppd-file.
  6. At around this point you'll be asked for user name and password for CUPS (most likely, your root password, depending on your configuration)
  7. Change options if neccessary and enjoy


Packages to add to a standard installation

These are the packages I would always install from the main repo (more a reminder for myself, but I guess it is useful for many people out there as well). This list is by far not complete and will be updated.

  • ntfsconfig (gui helper for setting read/write ability for ntfs drives)
  • quanta (web site development suite)
  • lynx (text browser for console - old, but can be very useful if you're left with a shell only)
  • texlive (LaTeX System)
  • kile (LaTeX Editor)
  • miktex-tools (if you use LaTeX and want to have a convenient package manager
Additionally, there are some packages which are not really usable or functional in the standard installation and should be replaced by packman versions (see post by avocadohead)


Keep track of your YaST updates

Right on top of my YaST Installer wishlist would be a "sort by install date" option in order to easily revert what yesterday's uncautious update screwed up. At least I found out where the installer log is: /var/log/YaST2/y2logRPM.
sudo tail -n 100 /var/log/YaST2/y2logRPM (100 last lines) ought to give you a hint about the most recent changes.

Note: Doesn't work for SuSE 11.1. Try
# sudo tail -n 100 /var/log/zypp/history
If you want to compare when you installed which version of a certain package:
# sudo cat /var/log/zypp/history | grep -i <packagename>