FedoraFaq is invaluable for Fedora Linux users.
Fedora News and the Redhat Magazine's Tips and Tricks column are worth a look.
Steve Litt's Linux Quick Hacks.
Hostseeq provides Unix/Linux hosting and server reviews.
Handy one-line tricks using awk from Eric Pement.
The Problem: All printing options except "Print to File" have disappeared from the print dialog box in Firefox 3 under Linux. Yet inspection of the print configuration options in about:config reveals no obvious changes and furthermore values related to the expected printers are present.
Crude Fix: Add the following line in /etc/gtk-2.0/gtkrc
gtk-print-backends = "lpr,file"
This will give you a very minimalistic command line interface to lpr, which means you must know the printer names and options you wish to invoke. Another fine example of of newer Linux software sacrificing core functionality for superficial improvements in other areas.
See this email thread.
The yum-utils package is an absolute must have for any rpm+yum-based Linux distribution, as it include the incredibly useful package-cleanup tool. Getting faster downloads using yum-fastestmirror package is also worthwhile. Shadow Logs discusses some of the uses of these and other yum tools .
package-cleanup has a number of useful functions, but I find that the two most useful are:
package-cleanup --dupes Setting up yum Loaded plugins: fastestmirror, refresh-packagekit Loading mirror speeds from cached hostfile AdobeReader_enu-8.1.2_SU1-1.i486 AdobeReader_enu-8.1.3-1.i486 AdobeReader_enu-9.1.0-1.i486
Dealing with problem duplicates or orphans: Some times removing old duplicates or orphans is simple, e.g. "yum remove AdobeReader_enu-8.1.2_SU1-1.i486" or "rpm -e AdobeReader_enu-8.1.2_SU1-1.i486" runs and completes without errors. On occasion yum or rpm will hang while running one of the preceding commands, presumably because the old package is damaged in some way or may only exist as an entry in the rpm database and not on disk. You may have to remove stale rpm database locks to get rpm working again, if simple "rpm -qi glibc" test queries start hanging (ls /var/lib/rpm/__db* ; rpm -i /var/lib/rpm/__db*).
There are various ways to proceed, but in the worst case you can simply remove the entry from the rpm database and then remove the files by hand (as long as you're sure they belong to problem package and not to the newer replacement). In the example of the duplicate AdobeReader packages I gave above I knew that the installation of the AdobeReader_enu-9.1.0-1.i486 package had not actually completed itself successfully, and both yum and rpm would hang when trying to remove the older packages. To recover I did the following:
The default XFCE4 xinitrc starts ssh-agent, but ssh-add must also be run to allow ssh sessions to operate without always prompting you for a password. This is easy to do, but differs slightly from the KDE. Contrary to naive expectation startup programs are not (and can not) modified through the XFCE4 Settings Manager "Sessions and Startup" tab, but are instead controlled and added/deleted using xfce4-autostart-editor started from the command line.
Start xfce4-autostart-editor from a terminal as the normal user. Click the "Add" button on the bottom left and in fill in the following.
Name: ssh-add Description: Invokes ssh-add at startup Command: /usr/bin/ssh-add
Finally click OK. The xfce4-autostart-editor will then create a file called ~/.config/autostart/ssh-add.desktop
Note this differs from a KDE Autostart entry, in that the Exec command required under KDE is "/usr/bin/ssh-add < /dev/null" and this will not work properly under XFCE4.
Additional useful XFCE4 tips and tricks can be found in the ArchWiki XFCE section.
Recent versions of Fedora (from Core 6 onwards) make an annoying beep when the machine finishes booting. In actuality the cause of this beep is gdm. To switch of the beep make sure SoundOnLogin=false in the [greeter] section of /etc/gdm/custom.conf, or follow the gdm graphical configuration instructions from rivviepop.
Standard moden shells provide a variety of useful command line recall mechanisms:
These are all trivial, although they can save you a lot of time if you have to re-issue the same commands many times.
What about when you want to issue a similar command, one that is not exactly the same? You're still in luck. Consider the following example of two commands:
csh subtractor.csh lambda_apec_e305315_z100.dat \
lambda_apec_e305315_hhe.dat lambda_apec_e305315_ar.dat
!:gs/305315/325335/
The second command reruns the prior command, and substitutes (s) 325335 for 305315 globally (g) within the string of the prior command. In effect, the shell executes the following command, without us hvaing to retype the unchanged parts of the command.
csh divider.csh lambda_apec_e325335_ar.dat \
lambda_apec_e305315_ar.dat ratio_apec_ar325335_to_ar305315.dat
For long complex command-line strings this simple regular expression magic saves both a lot of time and reduces the possibility of making typographical mistakes.
To compile and install PGPLOT using the latest gnu gfortran compiler, rather than using the older g77 compiler, follow the instructions on http://www.lorene.obspm.fr/pgplot_quick.txt. For ppglot (python pgplot bindings), follow these instructions from Durham University's Astrolab.
If you need either GIF or PPM output from PGPLOT then you will need to use modified "Fortran 95" versions of these drivers that are available in the Cluster Science Analysis System (QSAS). Download and unpack the source for version 2.2 of QSAS before following the PGPLOT compiliation instructions described above (the "pgplot quick" instructions). Now follow the "pgplot quick" instructions as far as running makemake and editing the makefile to change FCOMPL and FFLAGC. Add "-fcray-pointer" to the end of your modified FFLAGC line. In the qsas source you just unpacked now locate and copy the gidriv_f95.f (qsas modified GIF driver) and/or ppdriv_f95.f (qsas modified PPM driver) to the drivers/ directory of the PGPLOT source. Now return to the directory from which you ran makemake and edit the makefile again. You need to modify the section of the makefile containing the rules for creating gidriv.o and ppdriv.o so that it look like the following:
gidriv.o: $(DRVDIR)/gidriv_f95.f
$(FCOMPL) -c $(FFLAGC) $(DRVDIR)/gidriv_f95.f
mv gidriv_f95.o gidriv.o
nudriv.o: $(DRVDIR)/nudriv.f
$(FCOMPL) -c $(FFLAGC) $(DRVDIR)/nudriv.f
ppdriv.o: $(DRVDIR)/ppdriv_f95.f
$(FCOMPL) -c $(FFLAGC) $(DRVDIR)/ppdriv_f95.f
mv ppdriv_f95.o ppdriv.o
You should now be able to type "make" and "make cpg" and have PGPLOT compile itself and its demo programs successfully. At this point you can follow the "pgplot quick" instructions as normal.
The problem: By default, closing the lid on a Dell Latitude C400 running Kubuntu 7.04 will set the laptop into suspend-to-RAM mode and blank the screen. However, on opening the lid the screen remains blank and the user must perfom a hard restart of X (control-alt-backspace) to be able to use the machine (the only other alternative is to power cycle and reboot).
The solution: Modify your Xorg configuration file (e.g."sudo /etc/X11/xorg.conf") so as to (a) include Option "NoPM" in your ServerFlags section, and (b) Option "VBERestore" "true" in your Device section. Then restart X. Thus the relevant sections of your xorg.conf file will look similar to the following:
Section "ServerFlags" Option "NoPM" EndSection Section "Device" Identifier "Intel Corporation 82830 CGC [Chipset Graphics Controller]" Driver "i810" BusID "PCI:0:2:0" Option "DRI" "True" Option "VBERestore" "True" EndSection
The information for this fix was found here and here (which goes into greater detail about suspending and hibernating with Linux)
If you need to count the number of times a certain pattern occurs on a single line in a file, or the total number of times in a set file, then grep will not work. Grep can count the number of lines matching a regular expression (e.g. "grep -c mypattern myfile.txt"), but if the pattern occurs multiple times on a single line grep will only count that line once.
Consider the following line of text:
>set p_line="mod_ccm82_e4b3.param e4b3 1.400e+00 3.00 match match match 1"
Using grep to look for the word "match" we can only establish that the pattern does exist, at least once, on the input line:
>echo $p_line | grep -c match 1
To actually count the number of matches we can use a very simple awk script:
>echo $p_line | awk '{for (i=1;i<=NF;i++) if ($i=="match"){n++} }; END {print n}'
3
Note that the pattern matching in this example is rather crude (but it works). Ideally we should use the more power regular expression pattern matching that awk is known for. A useful list of awk one-liners has been compiled by Eric Pement.
If you use yum to maintain and update the packages on a Linux system running Fedora Core you will find that it retains 2 versions of the kernel by default: the current version (i.e the latest as of when you last updated the system) and the preceding version.
How do you change this behaviour? And why might you need to change this?
Occassionally you may find that the latest version will not work properly as it has not been sufficiently bug tested, which is not too surprising given that FC is supposed to be bleeding edge. In this case you would normally boot and run the older version. But if you then ran "yum update" once an even newer kernel version became available, then the old version you are using will be removed. If the newest kernel also doesn't work then you may be in trouble. One solution to this dilemma is to retain more than one old kernel version.
To solve this easily just edit (as root) the file /etc/yum/pluginconf.d/installonlyn.conf and change "tokeep=2" to "tokeep=N", where N is the integer total number of kernel versions (including the most current kernel version) you want to retain.
Mozilla Thunderbird can simultaneously handle email from many different accounts (e.g. gmail via pop, and your local work IMAP-served mail) at the same time. However it is widely reported on the internet that Thunderbird can not handle any local unix mail. i.e. the mail sent internally on your computer and stored in /var/spool/mail/. This is not quite true - with some work it could be made to work, and with the latest versions (v1.5 and up) of Thunderbird its easy to set up.
The following are a variety of links to tips for setting up local mail access in older versions of Thunderbird:
The problem: Modern Linux distributions automatically detect inserted media (e.g. DVD's, cameras or other storage connected by USB) in increasingly opaque ways. In some cases the device's filesystem contents may appear in a GUI file browser (e.g. Konqueror) without any entry being added to /etc/mtab, and with a path that does not correspond to a real filesystem path visible from the command line.
For example my Camera appears in a Konqueror window as system:/media/camera, even though on the command line /media appears empty. There are no entries either /etc/mtab or the dmesg log to indicate that the device has been mounted.
The problem is how can we access these files using the command line or via a script? Of course we could manipulate the files by hand using drag and drop with multiple Konqueror windows, but that is tedious and non-automatable.
The solution: Dragging and dropping a GUI folder onto a
X-terminal (may only work on a modern terminal such as Konsole)
reveals one mechanism for doing this using kfmclient on the command line,
for example to copy the entire 110CANON directory and its contents over
to the current directory you would use:
kfmclient copy 'system:/media/camera/store_00010001/DCIM/110CANON' .
I still have not worked how to use standard command line
wildcards (*,?,[] etc etc) to work with this method.
More on using kfmclient here.
The FC5 problem: Sound doesn't work in FC5 because the audio devices have their permisions and ownership set to 0600 root. Basically /dev/audio, /dev/dsp, /dev/mixer (and maybe others) have the wrong permissions. You can sudo and change the permissions by hand (e.g. "chmod 0666 /dev/dsp"), but if you log out and then log back in again you'll find they've been changed back to 0600.
The FC 5 solution: Edit /etc/security/console.perms.d/50-default.perms (or the equivalent console.perms config file in a non-FC5 distribution) and change the following line
< console> 0600 < sound > 0600 root
to
< console > 0666 < sound > 0666 root
Log out and log back in and the permissions will be set correctly. The offending package(s) are pam-0.99.4.0-fc5.4 and pam-0.99.5.0-5.fc5
The FC6 problem: In FC6 sound for the non-root user will occasionally stop working (or the volumes will be set weirldy low), which seems to happen after using yum to update the system. This does not seem to be a permissions issue.
The FC6 solution: Become root and run system-config-soundcard. Hit play on the sound sample (the right-facing triangle) and you should hear sound again. Hit OK in the small query box when asked if you heard the sound, then hit apply and OK on the bottom of the system-config-soundcard window. Back in your normal user account you should now be able to heart sound again.
The problem: The ssh-add passphrase is no longer prompted for on logging into a KDE session on Fedora Core 5, even though there is a correct link to the application in your ~/.kde/Autostart directory.
Partial solution/work-around: Follow this passphrase tip on fedoranews.org and use pam_ssh to do the work. Note than when it says edit /etc/pam.d/kde it really means /etc/pam.d/kdm.
Note that this only invokes ssh-agent ONLY if the user logs in through gdm or kdm, i.e. you boot into run level 5. Now users with ssh passphrases are prompted for them by the gdm/kdm log in screen - logging in with the passphrase invokes the behaviour of running ssh-agent and ssh-add, while logging in with the normal password means that ssh-agent will not be run, i.e. trying to remotely log into another machine will result in you being prompted for the passphrase. Really we want a solution that invokes ssh-agent and ssh-add when you start kde, whether or not you've used gdm/kdm or a runlevel 3 password login. Personally I'd prefer the added security of a password login and a separate passphrase access to other machines.
Second partial solution/work-around: rsync your ~/.kde/Autostart/ directory from a machine where its works to the problem machine. Magically it now works as normal, although I don't know what actually happened. Here is a copy of a working SSH-ADD_link.desktop file.
The problem: Recent versions of CUPS (I've seen on linux FC4 and FC5 systems and OSX 10.3) do not print in duplex mode by default, and even when the printer is set up to print in duplex by default CUPS/lp/lpr somehow manages to override this. Command line options to lp or lpr specifying duplex printing are also ignored.
The solution: Root must go into the CUPS web-based administration by pointing their browser at http://localhost:631/admin. If/when prompted for an administrator username and password use "root" and the root password. Click the "Printers" link on the navigation bar at the top of the web page. You will now see the names and types of the printers that have been defined for this system, along with options to print test pages, reject jobs, modify the printer and so on. Select and click "Configure." In the resulting web page you can configure duplex printing under General options: its called "Double-Sided Printing". When you have changed the values click continue to save the settings. You do not need to restart CUPS for these changes to be used by printing applications.
The problem: Until very recently GNU tail could be used to skip the first N lines of a file or pipe using the +N invocation (instead of -N to get the last N lines). This was the case in coreutils version 5.2.1 and earlier. As of 5.93 doing something like tail +4 bob.dat will now give an error message and complain about not finding a file called "+4". Note that the same +N invocation could be used with sort as well, and also is messed up.
The solution: Its a change in POSIX standards. See the coreutils documentation. The solution is to define the POSIX compliance mode (_POSIX2_VERSION) you want as an environment variable. For the tcsh to get the original behaviour do the following:
setenv _POSIX2_VERSION 199209
The problem: Spammers access your web pages with fake http referal fields that point to the shady company they're trying to advertise, typically Christian dating services or porn. This is done repeatedly from one or more machines every 15 minutes or every hour. These fake referals end up in your web page usage statistics which, if visible to the outside world, bump up that shady company's web page in the Google ranks due to the larger number of links to it. And you have your web pages looking like sex-obsessed Christians are eagerly accesssing your site. Great, just what you need! And it sucks up significant bandwidth too.
The solution: (a) Block outside acess to your web logs. (b) Use the Apache module mod_rewrite to catch and drop any http request matching a set of regular expressions. You could use iptables to simply block all access from a known offender's IP address (e.g. put "/sbin/iptables -A INPUT -s 195.175.37.0/4 -j DROP" in rc.local), but typically the spammers have infected a large number of machines (typically, but not always, MS Windows based on the user-agent strings in the web logs) making this not as robust as it would seem. Still, using iptables save you the bandwidth and CPU time otherwise used by Apache processing the requests and returning "access forbidden" messages. Anyway, follow the instructions below and write the RewriteEngine etc rules into a text file called what ever you want (but ending in .conf) in your /etc/httpd/conf.d/ directory so that it'll automatically get started when Apache (re)starts. Here is an example called z_referalspam_conf [Note: You should save it as z_referal.conf, the current underscore is to get around Apache thinking this is a top secret config file.].
Some good guides to the problem and fixing it with mod_rewrite can be found on Peter's Blog (along with a nice python script to test your mod_rewrite rules once installed), a blog post at Urban Mainframe on this subject that has some examples with slightly more advanced regexs, and finally a cool way to actually catch the spammers with Apache and automatically add an iptables rule to drop them.
If your LaTeX distribution is reasonably recent (TeTeX or TeX Live) you're best off using pdflatex directly to create a PDF without the intermediate stage of producing dvi and ps files. The following discusses two fixes for cases where pdflatex may not have correctly embedded all the fonts.
Pdflatex directly produces PDF documents. To check that the fonts are correctly embedded in the resulting (or any) PDF document use pdffonts on the command line. Alternatively you can check the fonts using Adobe acroread by accessing the File -> Properties -> Fonts menu option, and then checking that they're all Type 1, but using pdffonts is much faster.
The following is an example of a PDF document produced with pdflatex on Fedora 8 that correctly has all fonts embedded. Note the "emb" column.
pdffonts Strickland_starburst_galaxy_outflows_GAN_GCT.pdf name type emb sub uni object ID ------------------------------------ ----------------- --- --- --- --------- PPMVLE+CMBX12 Type 1 yes yes no 41 0 PVYNHG+CMR17 Type 1 yes yes no 44 0 XIFTSJ+CMR12 Type 1 yes yes no 47 0 QTTWAF+CMMI12 Type 1 yes yes no 55 0 BIUJHR+CMSY10 Type 1 yes yes no 58 0 MIHTTE+CMR8 Type 1 yes yes no 61 0 QARRCR+CMTI12 Type 1 yes yes no 64 0 PLHJLH+CMR10 Type 1 yes yes no 81 0 GCUWZZ+CMTI10 Type 1 yes yes no 85 0 VKBSCR+CMMI10 Type 1 yes yes no 88 0 EQJFNF+CMCSC10 Type 1 yes yes no 91 0 KDBFNG+Times-Roman Type 1C yes yes no 102 0 IGCBJB+CMSY8 Type 1 yes yes no 115 0 CPXFYP+CMMI8 Type 1 yes yes no 187 0 QMUCRI+Helvetica Type 1C yes yes no 191 0 ASVTUF+Times-Roman Type 1C yes yes no 192 0 GVDROO+Times-Roman Type 1C yes yes no 214 0 LQABOJ+CMR7 Type 1 yes yes no 237 0 INBZOH+CMTT10 Type 1 yes yes no 242 0 GZKTLB+Times-Roman Type 1C yes yes no 248 0 DYNQJT+Helvetica Type 1C yes yes no 249 0 KVZYOF+Symbol Type 1C yes yes no 250 0
Here is an example of a PDF produced with pdflatex on the same system that does not have all the fonts embedded.
pdffonts astro2010_superwinds_wp_technical.pdf name type emb sub uni object ID ------------------------------------ ----------------- --- --- --- --------- WMGLRT+CMR17 Type 1 yes yes no 62 0 VVMLGG+CMBX12 Type 1 yes yes no 65 0 NNSIJM+CMR10 Type 1 yes yes no 68 0 ESPOUA+CMMI10 Type 1 yes yes no 72 0 FCSYUG+CMSY10 Type 1 yes yes no 75 0 GZKTLB+Times-Roman Type 1C yes yes no 80 0 DYNQJT+Helvetica Type 1C yes yes no 81 0 KVZYOF+Symbol Type 1C yes yes no 82 0 ITSGWW+CMR12 Type 1 yes yes no 98 0 EXHIWM+CMTI12 Type 1 yes yes no 101 0 WOESKI+CMR8 Type 1 yes yes no 105 0 OZMAQH+CMMI12 Type 1 yes yes no 121 0 GUVNRB+CMR7 Type 1 yes yes no 129 0 BQANZS+CMTT10 Type 1 yes yes no 134 0 QFXVAI+CMTI10 Type 1 yes yes no 138 0 XNYIZU+CMSY8 Type 1 yes yes no 154 0 DVPNVS+CMMI8 Type 1 yes yes no 161 0 Times-Roman Type 1 no no no 209 0 Times-Roman Type 1 no no no 238 0 Times-Bold Type 1 no no no 239 0 Helvetica Type 1 no no no 240 0
Note the four fonts at the end with normal sounding names. They are not embedded. There are two possible reasons why they have not been embedded.
pdflatex has failed to embed the fonts in the Base 14 set: It is possible that pdflatex is set up not to embed certain fonts. On Fedora 8 this does NOT appear to be the case, but the solution is simple and widely discussed on the internet (e.g. here). As root perform the following commands (they are equivalent to editting the updmap.cfg file by hand and then running updmap):
updmap --setoption pdftexDownloadBase14 true updmap --setoption dvipsPreferOutline true updmap --setoption dvipsDownloadBase35 true updmap --setoption dvipdfmDownloadBase14 true
The problem fonts are in the EPS files you used for figures: If you're including figures in your latex document then its likely that you are used to using EPS format figures. The trick is to ensure that the fonts used in the EPS file are also embedded, as its not pdflatex's job to do this by default.
With pdflatex the epstopdf latex package allows you to keep using EPS and let the conversion of each figure to PDF to occur when pdflatex is run. Unfortunately the epstopdf package uses the command line epstopdf (which comes with TeTeX on Fedora) by default, and this seems to fail to embed the fonts. ps2pdf (part of ghostscript on Fedora) can do a much better job, so I end up doing the following...
cd Figs/ foreach file ( *.eps ) ps2pdf -dPDFX -dEPSCrop $file $file:r'.pdf' end cd ../
Oddly enough the psp2df command line options that you might think would embed fonts (e.g. -dEmbedAllFonts) do not embed fonts in my experience, while -dPDFX seems to be the only option that really works in this respect. If you (re)run pdflatex after converting the figures you should find that all the fonts are now properly embedded. Note that you can run pdffonts on any PDF, even the PDF versions of the figures, so you can check that embedding is occuring before run pdflatex.
Note that while the epstopdf latex package claims to allow you to change which conversion program it uses I have had no luck in getting it to work, possibly because I store all my figures in a different directory to the main latex document.
The following older set of notes may be of use if you don't have access to a pdfTeX-based LaTeX distribution.
The problem: PDF documents created from postscript files produced with LaTeX often have fuzzy or missing fonts when viewed in Acroread or xpdf, but the printed contents are perfect. The problem is PDF doesn't handle fonts as well as postscript, and really only handles Type 1 fonts. See this TeX FAQ entry. In acroread, under file->document properties->fonts you will see "Type 3" listed when you are afflicted by this problem. In my opinion it is inexcusable for any professional astronomer not to have direct access to a postscript viewer, even if you don't have linux as your primary or sole OS, or don't dual boot, or don't have a mac (even with Windows you can install cygwin to get tetex and gv as a postscript viewer, for example). But occasionally there is a genuine need to produce a PDF file from LaTeX and a postscript file. In some cases this can be done reasonably well, in others it can't.
The solution Use the -Ppdf option when running dvips to produce the initial postscript file from the dvi file LaTeX has produced. Also use the -G0 and myabe -j0 options. Then use ps2pdf to produce the final PDF file. For example:
latex bob.tex ; bibtex bob ; latex bob.tex ; latex bob.tex
dvips -Ppdf -G0 -j0 -o bob.ps bob
ps2pdf14 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true bob.ps bob.pdf
What works, what doesn't: With LaTeX 2e on Redhat 9 or later
the default document
fonts work fine. They look a little fuzzy in acroread at 100% magnification,
but at 150% they're perfect (unlike problem documents). In xpdf they look
even better, so the problem is probably with acroread.
In my experience they are embedded as Type 1 in a PDf
without needing to use -Ppdf or the other ps2pdf command
line options at all! All postscript Type 1 fonts used by the pslatex, apjfonts,
times, bookman, avant, helvet, palatino LaTeX packages work fine this way.
The elegant and very readable
computer modern bright (cmbright) fonts do not work, unless you shell
out $100 from some company.
Occasional problems: If the fonts you are using can't be substituted for
a Type 1 font you will get error messages when running dvips, e.g:
mktexpk: Mismatched mode ljfour and resolution 8000; ignoring mode.
mktexpk: Can't guess mode for 8000 dpi devices.
mktexpk: Use a config file, or update me.
dvips: Font cmbrsy8 at 8000 not found; scaling 600 instead.
See this TeX FAQ entry for more info.
Useful references: