it.rcmd.org
base || coding || networks || linux || contact || privacy || imprint
WARNING: This website is outdated, it has NOT been updated since 2011. Use at your own risk.
Solutions to common linux issues
Solutions to some problems/questions I encountered with linux. Note that some of them are for very old linux versions (e.g., Debian Sarge) so don't
follow them blindly. Most of the solutions here were not invented by me. I simply
searched the internet a bit and decided to put the information that was useful to solve the problems here.
the pipe key (with "<", ">" and "|" symbols) does not work under X
Kmail / GPG : Kmail complains about a bad gpg passphrase
Excluding Applications from Autostarting via KDE Sessionmanagement
Restricting the usage of su (via wheel group, BSD-style)
ssh public key authentication
Error : Inconsistency detected by ld.so:
Burning a playlist in Amarok
Fun with the bash shell and our music collection
Kmail / GPG : Encryption failed : General Error
Firewalled FTP Server on a VServer
Using multimedia keyboards with linux
Running apps from ~/bin/ (or: permanently adding stuff to $PATH)
Switching between different system configurations in bootloader menu
Laptop with internal LCD and external LCD/Monitor : videos only visible on internal LCD
Quake 2 Sound sucks (is chopped into pieces)
Quake 3 has no sound at all (nforce2 and some other chipsets)
Getting rid of the system beep on Debian Linux
Backing up your cron jobs
Forcing a user to change his/her password at next login on linux
Preventing /etc/motd from getting overwritten at reboot (Debian Etch)
Batch conversion of images on the command line
the pipe key (with "<", ">" and "|" symbols) does not work under X
This is due to a misconfiguration of the keyboard under X11 and can be corrected by changing the X11 config file, usually /etc/X11/XF86Config-4. In the Section "Input Device", make sure that you set XkbLayout to "pc105" :
Section "InputDevice" Identifier "Generic Keyboard" Driver "keyboard" Option "CoreKeyboard" Option "XkbRules" "xfree86" Option "XkbModel" "pc105" Option "XkbLayout" "de" Option "XkbVariant" "nodeadkeys" EndSection
Restart X / your display manager and the key works.
If you're using KDE, you can archieve the same result by going to KDE Start -> Conntrol Center -> Regional and Accessibility -> Keyboard Layout and selecting 'generic 105key (Intl) PC'.
Kmail / GPG : Kmail complains about a bad gpg passphrase
If Kmail gives you the following error :
Encrypted message (decryption not possible)
Reason: Crypto plug-in "openpgp" could not decrypt the data.
Error: Bad passphrase
when trying to open an encrypted message, although you did not even get the chance to type a password,
you need to install pinentry-qt, gnupg2 and gpg-agent. This solves the problem.
Excluding Applications from Autostarting via KDE Sessionmanagement
It can be very enerving to have kmail, kopete or other programs that assume you're connected to the inet
started automatically once you login to KDE. If you're at a place where there is no inet available or you
didn't configure your interfaces for the network yet, these apps will flood your screen with error messages.
I assume you didn't place these apps in ~./kde/Autostart, startx, startkde or any other of these autostart files,
which means that they are started by the kde session manager because you had them open when you closed your last session.
The solution seems (and actually is) quite obvious : place the application in the list of apps excluded from session management :-)
The list is at [K Start]=>[Control Center]=>[KDE Components]=>[Session Manager].
But there's no text describing what exactly you should put into that field. You may notice that 'app1 app2 app3' doesn't work or wonder whether you should write '/usr/bin/app1' or just 'app1'. Answer : putting 'app1' is sufficient, but you have to use the colon (:) as a delimiter. Took me some time to figure this out :-|.
So the text in the box should look similar to this :
kopete:skype:kmail
restricting usage of su (via wheel group, BSD-style)
It is assumed that you want only the user spirit to be able to use su in the following lines.
# addgroup wheel
# adduser spirit wheel
# adduser root wheel
# vim /etc/pam.d/su
now add the following line to the file you just opened in vi :
auth required pam_wheel.so group=wheel
done.
ssh public key authentication
1) on the client, generate your key and make sure its permissions are safe :
user@client> $ ssh-keygen -t dsa
user@client> $ chmod 400 ~/.ssh/id_dsa
NOTE : instead of doing steps 2) and 3) manually, you may use the ssh-copy-id program if available :
user@client> $ ssh-copy-id -i ~/.ssh/id_dsa.pub user@server
if you don't have ssh-copy-id available or don't want to use it, set things up manually :
2) copy public key to server :
user@client> $ scp ~/.ssh/id_dsa.pub user@server:/home/user/
3) place key in correct location, set permissions, rename it
user@server> $ cd
user@server> $ mkdir ~/.ssh
user@server> $ chmod 700 ~/.ssh
user@server> $ cat id_dsa.pub >> .ssh/authorized_keys
4) configure ssh server for pubkey authentication
root@server> # vi /etc/ssh/sshd_config
make sure the configfile contains the following line :
PubkeyAuthentication yes
5) disabling password authentication
you may want to disable password-only authentication in sshd_config for all of this to make sense, otherwise
users who don't have the key will be asked for the user password (this does not disable
the passwort you set to protect the ssh key, of course). the line is :
PasswordAuthentication no
6) making things easier on the client side
creating a ~/.ssh/config file like the example given below on your client is usually a good idea :
Host foobar
Hostname foobar.domain.org
IdentityFile2 /home/user/.ssh/id_dsa
Port 22
PreferredAuthentications publickey
Protocol 2
User user
you may then simply type
ssh foobar
to connect.
Error : Inconsistency detected by ld.so:
if you get the following error while trying to run a command, chances are you are using too much memory (RAM) on a shared system, maybe something like a vserver :
root@remotehost:~# apt-get install whatever-you-want
Inconsistency detected by ld.so: dl-minimal.c: 84: __libc_memalign: Assertion `page != ((void *) -1)' failed!
E: Method http has died unexpectedly!
E: Method /usr/lib/apt/methods/http did not start correctly
root@remotehost:~#
i got the message when trying to run apt-get under debian sarge on a box under heavy load, the lines starting with "E: Method..." are apt error messages. information on the inet was very rare.
it gets even more annoying if you're using too much memory and logout - the next login attempt via ssh is
doomed to fail :
user@localhost:~$ ssh remotehost
// login messages and server motd omitted here
Last login: Sat Aug 12 16:08:59 2006 from your-host.your-isp.net
-bash: xmalloc: ../bash/make_cmd.c:89: cannot allocate 1807 bytes (0 bytes allocated)
Connection to remotehost closed.
user@localhost:~$
the only solution is to stop programs/daemons that use lots of memory and are
not needed (or to get more RAM :-x). don't ask me why the existence of a swap partition with lots of
free diskspace doesn't solve this, but if you have further ideas or other opinions on this issue, please
contact me.
if you can't login via ssh anymore, you need to login to the rescue-system most vserver providers offer, chroot to your vserver and fix the issue by removing the startup links in /etc/init.d/ for services that use too much memory.
here is an example where i assume that the filesystem of your vserver is mounted on the rescuesystem under /mnt/ and that we want to stop starting spamassassin at boottime to get more memory :
user@localhost:~$ ssh root@rescuehost
// login messages and server motd omitted here
root@rescuehost:~# chroot /mnt
root@remotehost:/# update-rc.d -f spamassassin remove
// output of update-rc.d omitted here, note that update-rc.d is debian-specific
root@rescuehost:~#
that's it. reboot the server and you should be able to login via ssh again.
Burning a playlist in Amarok
Amarok rocks, and burning a playlist is very easy once you know how to do it ;-) :
- start Amarok and select the playlist you want to burn
- select all the tracks of the playlist (CTRL-A)
- right-click on any song and choose "Burn -> Selected Tracks as Audio CD"
Note : You need to have k3b installed for this to work.
Fun with the bash shell and our music collection
Let's just have some fun with bash(1), some standard UNIX tools and our music collection :-). We'll
clean it up and get some information on it. My collection consists of mp3-files organised in the following
way :
~/media/music/<band name>/<album name>/<track name>.mp3
So let's get some info on what we have.
1) I want a list that contains every album and the band :
spirit@threat:~$ cd media/music/
spirit@threat:~/media/music$ du -h . | awk -F'/' '{ if($3) printf $2; printf "%s", " - "; printf $3; printf "%s", "\n"}' | uniq | sort
This uses the ouput of du(1) and then sets awk's Field Seperator to "/" before printing the second field of each line (the band name) and a seperator (" - ") if a third field (the album name) exists. It makes sure no line is shown twice and sorts the whole output before printing it. Example output :
Air - Talkie Walkie
Beatsteaks - Living Targets
Chokebore - A taste for bitters
...
2) Let's see what file types we have in our collection and get rid of some of them
Find all types (extensions) of files which are not '.mp3' files :
spirit@threat:~$ find ~/media/music/ -type f ! -name *.mp3 | awk -F'.' '{print $NF}' | sort | uniq
Example output :
nfo
txt
url
wav
jpg
Mp3
ogg
db
m3u
...
I want to see the path and name of every .jpg-file in there :
spirit@threat:~$ find ~/media/music/ -type f -name '*.jpg'
...and delete all of them afterwards :
spirit@threat:~$ find ~/media/music/ -type f -name '*.jpg' -exec rm {} \;
3) Some stats
How many songs do I have?
spirit@threat:~$ find ~/media/music/ -type f -name '*.mp3' | wc -l
And how many bands?
spirit@threat:~$ ls -1 ~/media/music/ | wc -l
That's it for today.
Kmail / GPG : Encryption failed : General Error
I got seriously pissed of by gpg on debian sarge in the last time cause it refused to encrypt my outgoing mails with really great error messages like :
Encryption failed : General Error
I tried to get more out of it by running kwatchgnupg, but it didn't produce any output. Some
debian bug report i found
revealed the error is caused by some program messing up the ~/.gnupg/gpg.conf file, maybe kgpg.
To get rid of the error, edit your gpg.conf and remove any lines starting with 'encrypt-to'. Then restart
kgpg and kmail and try again.
Firewalled FTP Server on a VServer
Running an FTP Server behind a firewall is not that difficult if you can use the FTP connection
tracking module that IPtables offers. This is not the case if you're using a so-called vServer and
thus lack the ability to load kernel modules. Running active FTP is not an option today as this
would require changes on all clients that are behind firewalls or home routers.
So we need a way to
handle the situation where both client and server are behind firewalls AND there is no ip_conntrack_ftp
module available. This is only possible by configuring the FTP server to use a high port range for the
data connections from clients (rememeber, the server tells the clients the port to connect to on PASV) and
allow TCP connections to these ports.
Here is an example that shows how to do this for the proftpd FTP Server and the IPtables firewall.
1) Setup proftpd to use a passive port range. Add the following line to /etc/proftpd.conf :
PassivePorts 49152 65534
And don't forget to restart the server if it is running standalone :
/etc/init.d/proftpd restart
Now let's tell our firewall to allow incoming connections on these ports :
iptables -A INPUT -p tcp -m tcp --dport 49152:65534 -j ACCEPT
Done. Note that you may need to adapt the exact rules to your firewall, ftpserver and needs.
Using multimedia keyboards with linux
To use the special key of your multimedia keyboard under linux, install the hotkeys package and the fonts it needs. This will do it for debian users :
apt-get install hotkeys libxosd2
Check if your keyboard is on the list of supported keyboards by looking at the keyboard definition files (*.def) in /usr/share/hotkeys or by typing the following command :
hotkeys -l
If it is not, you need to create you own def-file. This is easy : simply copy an existing one, adapt the keycodes for your keyboard and assign actions to the keys. You can get the keycodes by using the program xev and pressing a key. An example file for my Siemens W9020S keyboard can be found here. Note that the actions must not be commands but keywords known to hotkeys. Commands are assigned to the action keywords
later in /etc/hotkeys.conf (see below).
Note : You could also assign custom commands to a key directly in the def-file, but this is not recommended. Here's an example anyways :
<userdef keycode="130" command="quake3 +set fs_game cpma">Quake III CPMA</userdef>
When you've found/created the def-file, adapt /etc/hotkeys.conf to your needs and assign commands to the keys defined in the def-file. Here is an example that uses the multimedia keys defined in the example file shown above to control the amarok audio player :
############################## START of /etc/hotkeys.conf ################################
# choose keyboard, this is the name of the .def-file in /usr/share/hotkeys without file extension
# copy your .def-file there if you created it yourself, it must be in that directory to be used
Kbd=siemens-w9020s
# setup multimedia keys for usage with the amarok audio player using DCOP commands
PrevTrack=dcop amarok player prev
NextTrack=dcop amarok player next
Play=dcop amarok player playPause
Pause=dcop amarok player playPause
# make the OSD fancy
osd_font=-arphic-ar pl kaitim big5-bold-i-normal--0-250-0-0-c-0-*-*
osd_color=LawnGreen
osd_timeout=3
osd_position=bottom
osd_offset=25
############################## END of /etc/hotkeys.conf ################################
Start hotkeys and enjoy! You may want to start hotkeys automatically at KDE login by placing a symlink to hotkeys in your ~/.kde/Autostart directory :
ln -s $(which hotkeys) ~/.kde/Autostart/hotkeys
I'm using a laptop and do not have the USB keyboard attached all of the time. I therefore use this tiny bash script instead of a symlink to check if the keyboard is attached and start hotkeys only if it is.
Running apps from ~/bin/ (or: permanently adding stuff to $PATH)
To add a directory (~/bin/ is used in this example) to your $PATH variable do this :
export PATH="$HOME/bin:$PATH"
echo "PATH=\"\$HOME/bin:\$PATH\"" >> $HOME/.bashrc
Switching between different system configurations in bootloader menu
If you want to be able to select your system settings on your laptop in the boot menu (think dual-screen @ home,
internal LCD only elsewhere), you can define environment variables on the kernel command line and have
an initscript interprete them and copy the right config files in place depending on the value of the variable.
I've recently written an initscript for this purpose that is available below. See the file itself for more information on the usage.
download initscript
Laptop with internal LCD and external LCD/Monitor : videos only visible on internal LCD
I recently connected an external LCD to my laptop and was pretty confused when i tried to watch a movie on the external display
under Linux under the X11 Window System. Though the movie was visible in the xine window on the internal laptop LCD, only
a blue background image could be seen in the same window on the external LCD.
This is a problem with the video overlay and can easily be fixed by adding these lines to your X11 config file (if you're using XFree86 this
is most likely /etc/X11/XF86Config-4, the Xorg-Server uses /etc/X11/xorg.conf instead) under the "device" section that defines the settings
for your graphic card :
Option "OverlayOnCRTC1" "on"
Option "OverlayOnCRTC2" "on"
I found a hint to this solution on this Thinkwiki.org page and added the complete solution there.
Quake 2 Sound sucks (is chopped into pieces)
To get the sound wortking properly, open $HOME/.quake2/baseq2/config.cfg in your favorite editor and change the line
set snddriver "oss"
to the following line:
set snddriver "sdl"
Start quake2. :-)
Quake 3 has no sound at all (nforce2 and some other chipsets)
UPDATE: Simply use the IOQUAKE3 engine (google it).
Getting rid of the system beep on Debian linux
That annoying beep is caused by the so-called PC speaker. You could easily pull its plug on a desktop PC, but this gets harder on a laptop. So we'll just unload the driver as root:
rmmod pcspkr
As you may already have guessed, the little bugging fellow will be reborn at the next reboot, so let's kill him forever. Add the following line to /etc/modprobe.d/blacklist:
blacklist pcspkr
Save the file and you're done.
Backing up your cron jobs
This explains how to backup your crontab to transfer it to another server. This is NOT an article about backing up all of your data regularly using cron!
OK, this is very easy. Export your crontab to a file:
myuser@oldhost> $ crontab -l > crontab-myuser-oldhost.cron
Now copy that file to the new server (wget, scp, whatever). Then install it and make sure it is there:
myuser@newhost> $ crontab crontab-myuser-oldhost.cron
myuser@newhost> $ crontab -l
Done. (Note that cron jobs for various system services may hide in /etc/cron* and that you can simply copy those files, but that is none of your business unless you are root. If you want to backup the cron jobs of various users as root and are unsure which users have cron jobs, have a look at /var/spool/cron/crontabs/.)
Forcing a user to change his/her password at next login on linux
You can do this with the passwd command. If you want to force john to change his password the next time he logs into his account, do this as root:
root@box> # passwd -e john
If you want a pasword to expire at a certain date or need more options, have a look at the usermod(8) command.
user@box> $ man 8 usermod
Batch conversion of images on the command line
The 'convert' command that comes with 'imagemagick' makes this a breeze. To convert all jpg images in the current directory to tga, do the following:
user@box> $ for f in *.jpg; do n=$(basename $f .jpg); convert $f $n.tga; done
Preventing /etc/motd from getting overwritten at reboot (Debian Etch)
When I recently migrated a server from Debian Woody to Etch I was surprised because my welcome message in /etc/motd got overwritten at reboot. As I discovered some time later, I should maybe have read
the documentation :p. From the Debian Etch release notes:
/etc/motd
is now a symlink to /var/run/motd
which is rebuilt by /etc/init.d/bootmisc.sh
from a template, /etc/motd.tail
, at each reboot. It means that changes made to /etc/motd
will be lost. Changes made into /etc/motd.tail
are not automatically applied to /etc/motd
other than at reboot.
Also, the EDITMOTD variable at /etc/default/rcS
no longer has any effect. If you wish to disable updating of the motd, or want to maintain your own content for the message of the day you just have to point the /etc/motd
symlink to a different file such as /etc/motd.static
and make your changes there.
So this should help:
root@box> # echo "your welcome message here" > /etc/motd.static
root@box> # rm /etc/motd
root@box> # ln -s /etc/motd.static /etc/motd
base || coding || networks || linux || contact || privacy || imprint
WARNING: This website is outdated, it has NOT been updated since 2011. Use at your own risk.