Short Tip: Real web page zoom in KDE 4’s Konqueror

kde-logo-official
In Konqueror the font in web pages could always be increased directly by pressing Ctrl and move the mouse wheel. But since it just increased the font size, not the graphics size, and therefore destroyed the layout of the web pages totally.

With KDE 4 this behaviour has changed: the images are now zoomed as well, so the entire layout is kept and showed to the viewers as expected.

This is one of the smaller hints you do not know until someone tells you ;)

Short Tip: A simple udev rule for burn rights on /dev/sg*

shell.png
udev is a very helpful tool to manage your device lists and rights on your Linux machine. With custom rules you can alter your system to do exactly what you want. A simple example which I recently needed is to change the group and the rights of a device. Let’s say you need to have write rights on the device /dev/sg*. These are not given usually under Fedora:


crw-------   1 root     root       21,   0  2. Apr 18:26 sg0
crw-------   1 root     root       21,   1  2. Apr 18:26 sg1

However, programs like Nero’s burning suite for Linux require these. So the best way is to change the group of the devices to disk and afterwards give the group write rights. In udev the best way is to create a custom rule file: /etc/udev/rules.d/55-disk-burning.rules.


# cat /etc/udev/rules.d/55-disk-burning.rules
BUS=="scsi", KERNEL=="sg[0-9]*", GROUP="disk", MODE="0660"

After a reboot the rights are as needed:


crw-rw----   1 root     disk       21,   0  2. Apr 18:26 sg0
crw-rw----   1 root     disk       21,   1  2. Apr 18:26 sg1

Of course this still requires the user to be a member of the disk group…

Short Tip: Create a “bash alias” with an argument

shell.png
I always check for changes in rpm files. Unfortunately, the command to do so needs some typing:


rpm -q --changelog PACKAGENAME|most

(Btw., most is a replacement for less). The best idea would be to have a bash/zsh/whatever alias with an argument. This is unfortunately difficult or even impossible, but it is quite easy to define a simple function:


rpmch () { rpm -q --changelog "$1"|most}

Copy that string to your .zshrc or .bashrc and you can easily query the changelog of rpm packages with the command


rpmch PACKAGENAME

This of course works for other commands as well.

Short Tip: replace characters in txt files with sed

shell.png
When working with txt files or with the shell in general it is sometimes necessary to replace certain chars in existing files. In that cases sed can come in handy:


sed -i 's/foo/bar/g' FILENAME

The -i option makes sure that the changes are saved in the new file - in case you are not sure that sed will work as you expect it you should use it without the option but provide an output filename. The s is for search, the foo is the pattern you are searching the file for, bar is the replacement string and the g flag makes sure that all hits on each line are replaced, not just the first one.
If you have to replace special characters like a dot or a comma, they have to be entered with a backslash to make clear that you mean the chars, not some control command:


sed -i 's/./,/g' *txt

Sed should be available on every standard installation of any distribution. At lesat on Fedora it is even required by core system parts like udev.

Short Tip: Mount directories via SSH

shell.png
Other computers are often accessed via ssh. That is very easy and comes along with a lot of possibilities. However, working on files which are saved on the server is not that simple all the time. KDE offers the fish:// KIO for these cases, but this just works for KDE apps, and has to be called for each app individually.

In such cases it makes more sense to actually mount the server directories locally: sshfs let you mount any given server directory locally. And since it works on top of FUSE it does not require root interaction at all (given that the local user is a member of the fuse group).

All you have to do is:


sshfs -o idmap=user 192.168.0.1:/data ~/sshDir

The idmap=user option translates the server side uid to the client side uid and is therefore an often used and also needed option to avoid permission problems.

Of course the given directories have to exist on the used machines. Also, as already mentioned, make sure that the user who tries to use sshfs is a member of the fuse group! Last but not least the server must have a running ssh server, and the program sshfs has to be installed on the client machine. On Fedora, the package is called fuse-sshfs and is part of the main repositories. I guess it is similar on the other, bigger distributions as well.

Since every sshfs directory is a regular fuse directory, the umount is done via:


fusermount -u ~/sshDir

This can even be embedded into /etc/fstab and also understands typical ssh configuration options like other ports or the very handy key authorization.