Random Wisdom

Linux

Joining PDF Documents

by on Aug.03, 2007, under How To ..., Linux, Software

A quick search on the web reveals that the simplest (and most available) command to do so is:


$ gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf

Source: Putting together PDF files by Scott Nesbitt on NewsForge

[Update: Feb 1, 2011] jpdftweak is probably a better option with many useful features.

Leave a Comment :, , more...

Named Pipes (FIFOs)

by on May.22, 2007, under How To ..., Linux

A named pipe is a special kind of file on *nix systems that can be used for inter-process communication. They behave like FIFOs and are created using the command “mkfifo“:


$ mkfifo mypipe
$ ls -l mypipe
prw-rw-r-- 1 xxx xxx 0 May 22 10:18 mypipe

The “p” in the attributes list indicates that this is indeed a pipe.

A trivial example of its use may be to redirect the output of a command on a remote server to a pipe and then reading from that pipe from another host via ssh.

Leave a Comment :, more...

Software Keyboard and Mouse (KM) Switcher

by on May.15, 2007, under How To ..., Linux, Software

Stumbled across this great tool a few days ago:

Synergy

Description from the project homepage:

Synergy lets you easily share a single mouse and keyboard between multiple computers with different operating systems, each with its own display, without special hardware. It’s intended for users with multiple computers on their desk since each system uses its own monitor(s).

Redirecting the mouse and keyboard is as simple as moving the mouse off the edge of your screen. Synergy also merges the clipboards of all the systems into one, allowing cut-and-paste between systems. Furthermore, it synchronizes screen savers so they all start and stop together and, if screen locking is enabled, only one screen requires a password to unlock them all.

Leave a Comment :, more...

Mass conversion of images

by on May.07, 2007, under How To ..., LaTeX, Linux, Software

The following “one-liner” can be used to mass convert a given image format into another using the convert (part of ImageMagick) and basename tools:


$ for A in $(ls *.$SRC_TYPE); do convert $A $(basename $A .$SRC_TYPE).$DST_TYPE; done

where $SRC_TYPE is the file suffix of the original images (e.g. png) and $DST_TYPE is the file suffix of the type desired (e.g. eps).

Leave a Comment :, , , more...

Linux and DVD Regions

by on Apr.12, 2007, under How To ..., Linux, Software

Typically, Linux DVD playback software are capable of decrypting (libdvdcss must be installed) and playing back DVDs from any region, irrespective of the region code of the drive. Therefore, there should be no need to change the region code of the drive to watch discs from a different region. Regardless, there exists a very handy program that allows the user to change the region code and view other relevant information such as the number of changes remaining. It is called “regionset” and is available for Fedora from the Extras repository. The project website is:

http://linvdr.org/projects/regionset/

There is also a useful article on Linux.com about DVD playback:

DVD Playback HOWTO

Leave a Comment :, , more...

Gnome automount options

by on Mar.15, 2007, under How To ..., Linux, Software

On a default Fedora installation, Gnome will automatically mount (with some default options) any recognized volumes as soon as an external storage device is plugged in. While the defaults might be fine in general, sometimes it is necessary to supply some more options.

The tool responsible for automating the mount (gnome-volume-manager) gets additional options from the /system/storage/default_options/$fstype$/mount_options key of gconf — the Gnome “system registry”. One can check/modify existing entries (one a per user basis) by running:


$ gconf-editor /system/storage/default_options &

This should launch the graphical configuration editor with the default_options key selected. Under this key are the entries for different filesystems. Default mount options can then be changed by selecting the desired filesystem and editing the mount_options key.

If a required filesystem type is not listed, then it can be added by using the gconftool-2 utility. E.g. if we wanted to add the ext3 filesystem to the configuration database with the options “sync” and “uid=“, we would run the command:


$ gconftool-2 -t list –list-type string \
-s /system/storage/default_options/ext3/mount_options “[sync,uid=]”

Next time an external volume is plugged in, it will be mounted with the additional options specified! It should be noted that regardless of the options supplied via gconf, some mount options are always present: r(o|w),noexec,nosuid,nodev. At the moment I do not know how to change them.

The main motivation for finding out about the defaults is that I wanted to add “sync” as a default option. This causes data to be written immediately to the device, instead of being buffered first — a useful option to have for external devices. It should minimized data loss in case of an accidental removal (without running umount first). However, it should also be noted that for solid state drives (e.g. flash), this may result in a shortening of service life and poorer performance.

Update [Sun Mar 18, 2007]:
I’ve done some rudimentary throughput performance testing with both the sync and async modes and the performance hit with sync appears to be quite severe (at least 20 times slower than async) — even with a high performance HDD as the target. In light of this, I am removing sync from the list of default options. Given the type of data I’m likely to store on the device, speed is certainly more valuable than data integrity.

Test results:
Testing was carried out on a FAT32 volume. For each mode, both the transfer time and the subsequent un-mount time (indicating the time needed to flush the buffer) are shown.

async:

$ time dd if=/dev/zero of=/tmp/usb/dummy bs=8k count=130000 && time sudo umount /tmp/usb/
130000+0 records in
130000+0 records out
1064960000 bytes (1.1 GB) copied, 45.9035 seconds, 23.2 MB/s

real    0m46.026s
user    0m0.035s
sys     0m2.915s

real    0m11.680s
user    0m0.003s
sys     0m0.263s

sync:

$ time dd if=/dev/zero of=/tmp/usb/dummy bs=8k count=130000 && time sudo umount /tmp/usb/
130000+0 records in
130000+0 records out
1064960000 bytes (1.1 GB) copied, 969.384 seconds, 1.1 MB/s

real    16m13.525s
user    0m0.048s
sys     0m12.156s

real    0m0.842s
user    0m0.004s
sys     0m0.199s
1 Comment :, , more...

Linux NFSv4 Howto

by on Feb.27, 2007, under How To ..., Linux, Software

NFS is commonly used to share files on Linux. NFSv4 is the latest protocol and circumvents firewall related complications experienced with NFSv3 by requiring only ONE fixed tcp port open on the server side. It is surprisingly easy to set up:

Server side:

  1. Edit /etc/exports and add directories to be exported (fsid=0 is a mandatory option for nfs4) and authorized clients (check the exports manpage)
  2. Open up tcp port 2049 on the firewall
  3. # /etc/init.d/nfs restart
  4. # chkconfig –level 345 nfs on

Client side:

  1. # mount -t nfs4 -o rw,intr,hard server:/ /mount/point

It is not necessary to specify the exact path on the “server:/” with NFSv4.

Useful sites:

Learning NFSv4 with Fedora Core 2
RHEL4 NFS manual
Linux NFS-HOWTO

Leave a Comment :, more...

Linux – Disable Shutdown For Normal Users

by on Feb.27, 2007, under How To ..., Linux

Very useful for servers/shared machines:

Disable Shutdown For Normal Users

Addendum:

Setting file mode for /etc/acpi/events/power.conf to “0000” is not sufficient to disable the power button. It’s better to:

  1. Uninstall gnome-power-manager
  2. Leave file permissions for power.conf unchanged and simply set the action= line to an empty string

It is also advisable to set the local login screen style to plain in gdmsetup.

Leave a Comment :, , more...

Linux authentication using LDAP

by on Feb.27, 2007, under How To ..., Linux, Software

There’s a lot of information out there but none really provide a step-by-step guide that would be useful to a novice:

This one however, sheds some light on the bigger picture:

LDAP Authentication In Linux

Once the initial configuration of the server is complete, LDAP Browser/Editor serves as a very useful client/admin tool.

Leave a Comment :, , more...

Cross-platform filesystem access

by on Nov.21, 2006, under How To ..., Linux, Software

Looks like the ntfs-3g driver has already gained a lot of popularity and is quite easy to use:

NTFS-3G Read/Write Driver

The driver itself is supposedly available from the Fedora Extras repository for FC6 onwards. Completely safe read/write access to NTFS drives from Linux — now that’s a dream come true!

In the meanwhile, it looks like there’s also a windows Ext2 file-system driver that allows full read/write access to Ext2/3 volumes:

Ext2 Installable File System For Windows

Of course, one of the drawbacks here is that the Ext3 volume is mounted as Ext2 — so there is no journaling support. In case of a ‘dirty’ unmount e2fsck will have to be run. The other drawback is the fact that is won’t work with LVM.

So, these drivers really open up a lot of choices. But I guess the best option is to have the shared drive as NTFS since the ntfs-3g driver takes care of journaling.

Leave a Comment :, , , , , more...