Linux Tips and Tricks
This document has not been meaningfully updated since 2006. Much
of this information is likely to be obsolete at best and in all
likelyhood flat-out wrong. Proceed with caution.
This document is an unorganized collection of various Linux tips and
tricks, mostly applicable to various flavors of Mandrake. Some of
this may apply to other distributions like Red Hat (a mostly
Mandrake-compatible distribution).
If you can't figure out how to point and click your way to changing
the hostname (assuming you can), you can edit it by hand. This is the
easiest way; I haven't bothered with any other.
Look for the file
This probably applies to all distributions that use sysconfig, such as
Red Hat and Mandrake.
You should also add an entry in
Some people get tired of having to switch to root to do certain
things, especially laptop users who frequently connect and disconnect
things. The
You can also add aliases for groups of users, or groups of commands,
which simplifies things like allowing a user to execute all
network-related commands. See the manual for details.
Yeah, I hear you.
Most current distributions have a graphical bootloader and a pretty
graphical boot screen by default, and they don't make it all that easy
to get rid of. This is handled by the
First, get rid of the LILO graphical menu. On Mandrake, the
Now change
Now make sure that you pass the
This is a known issue, with a known fix. The short story is that
Gnome 2.4 doesn't support viewports, but the workspace switcher sends
viewport messages anyway. Hilarity ensues as windows seem to shift
randomly when you click on a workspace. Please see this Bugzilla
report for the gory details.
It's usually better to rebuild the SRPM instead of downloading the
sources for everything -- this way you'll know that they will install
to exactly the same place and otherwise be exactly the same. Get the
SRPM for the libwnck package, blow it up somewhere (with
Hopefully this fix will be integrated into the next version of Gnome.
Suppose you dual boot, and Windows seems to think the time is five
hours ahead of Linux. So you change it, and now Linux is five hours
behind. What's going on here?
Windows reads the hardware clock and assumes it is in the local time
zone. Linux can read the hardware clock as either local time or GMT,
depending on how you've set it up. In the case above, you might have
noticed that your GMT offset just happens to be five hours.
The solution is to tell Linux to treat the hardware clock as local
time instead of GMT. The command for this is
Adobe Reader 7 (Acrobat 7) has a highly distracting button-like thing
in the upper right. To get rid of it, drag any button on the same
toolbar down a bit. This creates a second toolbar just below the
current one. Drag the remainder of the buttons down to match. When
you drag the last button down, the first toolbar disappears (because
it is empty), taking the offending ad thingy with it. To prevent it
from appearing again, lock your toolbar in place now.
Alternatively, going to Edit/Preferences and deselecting "Show
messages and automatically update" achieves a similar effect.
There is
This prints
There is an interesting interaction between Mozilla (and other
Mozilla-based browsers like Fire-whatever and Galeon), Xft, and Flash.
The fix is to export an environmental variable as follows:
You'll probably want to stick this in a script somewhere so that you
don't forget. The
By default, when CUPS connects to a remote LDP server, it does
not reserve a privileged port. Some LPD servers may be
configured to require an incoming connection to come from a privileged
port (per RFC 1179) and will reject print requests originating from
non-privileged ports (ostensibly for security, although that is very
debatable). You need to change this behavior.
Suppose you wish to print to
Assuming the lpd backend is installed, the remote print server should
now be receiving requests from you from a privileged port. See the
CUPS Software Administrator's Manual for more details.
You don't. That is, you don't have to - it already is.
For the unfamiliar, virtually every DVD movie in the US (and most of
the industrial world) is encrypted with CSS and has a region code. A
player made for Region 1 (United States and Canada) will refuse to
play a disc marked for Region 2 (Europe and Japan), and vice versa.
The goal of this deliberate technical incompatibility is to prevent
individuals from traveling to other countries and bringing DVDs home.
This strengthens the local distribution monopolies and allows
distributors to charge different prices for each region (since this
attempts to make importing impossible). Most reasonable individuals
feel this is underhanded at best, and possibly an illegal restraint of
trade, but nobody has the money or political will to go up against the
major studios.
Starting around 2000, all manufacturers of DVD-ROM drives were
required to implement RPC-2 region coding in hardware. In principle,
this should prevent software-only solutions for playing out-of-region
discs. However, clever people have found ways.
Region coding works in conjunction with CSS encryption to provide
hardware support for region locking. The player software and the
drive do several things before playback of encrypted content can
begin:
Note that all the hardware stops you from doing is getting the title
key. You can still read all the data on the disc in encrypted
format. If there were another way to get the title key, the hardware
protection is rendered useless, as we would have both the data and
encryption key.
Normally libdvdcss uses the usual means (which they call
"key") for playback. However, it falls back to
"title" which performs a brute-force cryptographic attack on
the key. This process can be rather CPU-intensive, but usually
reveals the key and permits region-free playback on unmodified
region-locked hardware. You should not have to do anything on a
recent build of libdvdcss to enable this behavior. For more details,
see the libdvdcss programming documentation.
The DVD FAQ
has everything you want to know about DVDs.
Go enjoy your foreign movies!
Disclaimer: I own no foreign-region DVDs, so it's not very easy for me
to rigorously test this.
This isn't very well documented anywhere, but you can type a number of
URIs into the Nautilus address bar and get cool things.
Some of the ones I know about are:
There are probably a lot more undocumented ones as well.
You got yourself some nice shiny USB external storage device (for
example) and you want to create a FAT32 filesystem on it so that
Windows and Linux can read it. You've already allocated a partition
(Windows FAT32 LBA, type 0C) and figured out that you need to do
something involving mkfs to actually create the partition, but get the
following error:
This occurs if the partition is too large for a FAT filesystem. Tell
it to create a FAT32 filesystem instead:
Anecdotally, I've seen Windows create a FAT32 partition on a removable
storage device that Linux couldn't read (lots of errors about reading
beyond the end of the device); the problem went away when I created
the partition from Linux. I haven't bothered to investigate further.
Sometimes the various point and click tools don't work right, and you
need to add a new network interface by hand. As an example, let's add
a Netgear MA401 wireless LAN card, which is happily supported out of
the box, at least as far as drivers go.
First, we insert the card and hope that the appropriate kernel modules
are loaded. I see that they are (the MA401 uses the orinoco driver):
Now I check that the wireless tools know about it (obviously, if it
isn't a wireless card, you won't want to do this):
It's there, but it isn't doing anything. Time to fix that. I want
the new network interface on eth1, with certain options. I create a
file at
This specifies that device eth1 uses DHCP to get an IP address, that
it is not started automatically on boot, it is named persephone
(although the DHCP server does not require it), and that the wireless
is operating in Managed mode (connect through base station) with ESSID
"tsunami" (if the base station is broadcasting the ESSID,
you can substitute "any").
Now that it knows the appropriate settings, we can try to bring up the
interface:
As you can see, we now have happy wireless on eth1.
Note that if your card uses the wlan-ng package, things will look
slightly different. Also, don't forget to type
If your Emacs (or other old X11 application) has weird colors under
KDE, you should uncheck the "Apply Colors to non-KDE
Applications" option, usually somewhere in Look and Feel/Colors.
Whether or not Nautilus previews text files in the icon depends on the
theme. Some themes (like Industrial) don't; some themes (like Gnome)
do.
People see something like:
instead of "Helvetica 12pt" and get all scared. This is the
old X11 font specifier string; you'll see it occasionally. It
specifies all relevant information for a font in a nice,
programmer-friendly string. I'm not going to explain exactly how it
is formed; the easiest way is to run
The old X11 specifier only works well on the X core fonts. Since all
of these fonts are ugly, you'll probably want to use your nice
TrueType fonts everywhere.
On Linux (and others), this is usually done through the Xft font
library, which actually gives pretty fonts. The font specifier is
different (and more readable) from the old X11 font string. In
general, the font strings look like:
For example, my custom Sawfish theme specifies an Xft font for the
titlebar with (via the
This does exactly what you think it does. Naturally, this only works
for applications that can use Xft. See the manpage for
This actually applies to most older X11 applications, not just Emacs.
For Emacs, you can attempt to solve this problem by going into the
Faces configuration (from M-x customize), but this doesn't always work
depending on your X11 resources and font stuff. KDE (and to a lesser
extent, Gnome) may have issues with this on some distributions.
The "nice" way to fix this is to add the appropriate lines
to your
This makes the colors more appealing to me, and makes the default font
significantly larger for my tired old eyes. Fonts are specified in
the old X11 manner.
This trick works in a lot of other older X11 apps as well, if you want
bigger fonts in xman...
This is a common error among American English speakers. Ordinarily,
when one sacrifices a goat within a circle of candles at the full moon
to appease the computer gods, one chants "Elath grash nar maral,
noor din Turing-wa ost, grash nar throk" (May our computers work,
by the grace of Turing, may they run). While technically
correct, it is important that the stress be on the second syllable of
"maral" as placing the stress on the first syllable changes
the request to "May our computers play, by the grace of
Turing..." and as the gods have a strange sense of humor, this
particular change frequently results in unfortunate consequences.
Set the Hostname
/etc/sysconfig/network and add a line
or otherwise modify it to include:
HOSTNAME=myhostname
/etc/hosts, as follows:
127.0.0.1 persephone
Running root commands without being root
sudo facility allows certain named users to
execute certain privileged commands without having to authenticate.
Edit the file /etc/sudoers. For example, if I (walter)
wanted to be able to issue the ifup and
ifdown commands without being root, I add the following
line:
walter ALL = NOPASSWD: /sbin/ifup, /sbin/ifdown
I hate the boot-time splash screen
bootsplash
package, and if we want to go back to the tried and true 80x25 text
console, we're going to have to fight it.
drakboot tool can do this, or you can edit
/etc/lilo.conf yourself, selecting
install=menu or install=text instead of
graphical.
/etc/sysconfig/bootsplash and tell it to take
the stupid graphics elsewhere by changing the lines to include
SPLASH=no
LOGO_CONSOLE=no
splash=0 option to your
bootloader (in LILO, this is the append option), reboot, and enjoy
your glorious text. Don't forget to run LILO first.
The Gnome 2.4 Workspace Switcher doesn't play nice with
Sawfish
rpm
-ivh, edit pager.c as instructed (look for the
wnck_screen_move_viewport calls and remove them, or apply their
patch), put everything back together, and install your custom-tailored
version. I walk you through this example in my RPM tutorial. If you are not familiar with
the RPM build process, I refer you to the Mandriva RPM
HOWTO, which has all sorts of stuff on building your own RPMs.
I dual boot, and the time keeps changing!
hwclock,
but this is usually initialized from boot scripts. On systems with
sysconfig, look at /etc/sysconfig/clock and change any
line that reads UTC=true to UTC=false.
Adobe Reader 7 has a stupid ad thingy
How to I merge PostScript files?
psmerge, but it doesn't always work right. The
following command uses ghostscript and has the same
effect of printing a bunch of files in sequence, except that the
output goes to a file.
ghostscript -dNOPAUSE -sDEVICE=pswrite -dBATCH -sOutputFile=out.ps file1.ps file2.ps ...
file1.ps, file2.ps, etc, to
out.ps. In my experience, this is much more reliable
than psmerge or the CUPS pdfwriter, especially in really
funky cases with non-embedded foreign fonts.
Why is Flash so slow in Mozilla?
export FLASH_GTK_LIBRARY=libgtk-x11-2.0.so.0
libgtk-x11-2.0.so.0 works on my
machine; if it doesn't work for you, you should give it the correct
libgtk-x11 library on your system. It is likely that after Flash 7,
this problem will cease to exist anyway.
CUPS won't print to a remote LPD server
printhost.cs.utexas.edu,
queue lw42. Add a printer through the CUPS web interface
(http://localhost:631) or by editing files, and for the
Device URI, specify:
lpd://printhost.cs.utexas.edu/lw42?reserve=on
How do I make my Linux DVD player region-free?
What Nautilus URIs can I use?
How do I make a Windows filesystem on Linux?
[root@persephone root]# mkfs.vfat /dev/sda1
mkfs.vfat 2.9 (15 May 2003)
mkfs.vfat: Attempting to create a too large file system
mkfs.vfat -F 32
/dev/sda1
Adding Wireless Interfaces By Hand
[root@persephone etc]# lsmod
Module Size Used by Not tainted
orinoco_cs 5652 0 (unused)
orinoco 36972 0 [orinoco_cs]
hermes 7524 0 [orinoco_cs orinoco]
eepro100 21844 1
...
[root@persephone etc]# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
eth1 IEEE 802.11-DS ESSID:"" Nickname:"Prism I"
Mode:Managed Frequency:2.422GHz Access Point: 00:00:00:00:00:00
Bit Rate:11Mb/s Tx-Power=15 dBm Sensitivity:1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0/92 Signal level:134/153 Noise level:134/153
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
/etc/sysconfig/network-scripts/ifcfg-eth1 with
the following lines:
DEVICE=eth1
BOOTPROTO=dhcp
NETMASK=255.255.255.0
ONBOOT=no
MII_NOT_SUPPORTED=yes
WIRELESS_MODE=Managed
WIRELESS_ESSID=tsunami
DHCP_HOSTNAME=persephone
NEEDHOSTNAME=no
[root@persephone network-scripts]# ifup eth1
Determining IP information for eth1... done.
[root@persephone network-scripts]# iwconfig
lo no wireless extensions.
eth0 no wireless extensions.
eth1 IEEE 802.11-DS ESSID:"tsunami" Nickname:"persephone"
Mode:Managed Frequency:2.412GHz Access Point: 00:60:1D:21:7D:EF
Bit Rate:11Mb/s Tx-Power=15 dBm Sensitivity:1/3
Retry min limit:8 RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:77/92 Signal level:-25 dBm Noise level:-144 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
[root@persephone network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:03:47:93:1C:1C
inet addr:128.83.158.153 Bcast:128.83.158.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6807 errors:0 dropped:0 overruns:0 frame:0
TX packets:4190 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:4090713 (3.9 Mb) TX bytes:949479 (927.2 Kb)
Interrupt:11 Base address:0x9000
eth1 Link encap:Ethernet HWaddr 00:30:AB:11:F5:62
inet addr:128.62.233.212 Bcast:128.62.233.255 Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:116 errors:0 dropped:0 overruns:0 frame:0
TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:9819 (9.5 Kb) TX bytes:792 (792.0 b)
Interrupt:3 Base address:0x100
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:1436 errors:0 dropped:0 overruns:0 frame:0
TX packets:1436 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:96608 (94.3 Kb) TX bytes:96608 (94.3 Kb)
cardctl eject
0 (or as appropriate) before physically ejecting the card.
Emacs has Strange Colors in KDE
Why is the text preview in Nautilus not working?
What do the long font names in X11 mean?
-adobe-helvetica-medium-*-*-*-12-*-75-*-*-*-iso8859-*
xfontsel and play
with it (it makes sense, in a strange way). If you do not have
xfontsel installed, it's probably in the X11R6-contrib rpm.
Right, now how do specify nice anti-aliased TrueType fonts?
My Font Name-pointsize:property1:property2...
get-font-typed call with
"Xft"):
Bitstream Vera Sans-14:bold:italic
fonts-conf for more information.
My Emacs fonts are tiny on my super high resolution screen
~/.Xresources file. For example, mine contains
the lines
emacs*Background: White
emacs*Foreground: Black
emacs*font: -*-fixed-*-*-*-*-18-*-*-*-*-*-*-*
My pagan sacrifices to the computer don't work!