Frequently Asked Questions - Linux

Linux

General Linux questions

Running a privileged command requires sudo. If it is performed from under apache, sudo says that it requires tty. To fix it, run visudo and comment out a string in /etc/sudoers

 #Defaults requiretty

or override its value for apache

 Defaults:apache !requiretty

I have pre-built RPMs for CentOS 5, so for this OS just attach to the vitki.net repository and install RPMs:

rpm -i vitki-net-release-5-3.el5.noarch.rpm
yum install freetype cairo libXft
yum install gedit gedit-plugins

Otherwise, you have to compile yourself.

Get the patches from http://quanli.googlepages.com/davidt...esfordebiansid (or google for "david turner subpixel"):

Get the SRPMS http://mirror.centos.org/centos/5/os/SRPMS/
cairo-1.2.4-2.el5.src.rpm
freetype-2.2.1-19.el5.src.rpm
libXft-2.1.10-1.1.src.rpm

rpm -i *.src.rpm
EDIT THE SPEC FILES TO APPLY THE PATCHES

cairo.spec

...
BuildRoot: %{_tmppath}/%{name}-%{version}-root
Patch0: libcairo-1.2.4-lcd-cleartype-like.diff
...
%prep
%setup -q
%patch0 -p1
%build
...

Note: Enabling bytecode interpreter not necessary, but fun to see windows fonts.

freetype.spec

# Disables patented bytecode interpreter.  Setting to 0 enables
# the bytecode interpreter.
%define without_bytecode_interpreter    0
...
Source1: freetype-doc-%{version}.tar.bz2
Source2: ft2demos-%{version}.tar.bz2
...
Patch0: freetype-2.2.1-subpixel-disable-quantization.diff
# Add -lm when linking X demos
Patch5: ft2demos-2.1.9-mathlib.patch
Patch20:  freetype-2.1.10-enable-ft2-bci.patch
...
%prep
%setup -q -b 1 -a 2
%patch0 -p1
pushd ft2demos-%{version}
%patch5 -p1 -b .mathlib
popd
...

libXft.spec

...
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Source0: ftp://ftp.x.org/pub/individual/lib/%{name}-%{version}.tar.bz2
Patch0: libxft-2.1.8.2-lcd-cleartype-like.diff
...
%prep
%setup -q
%patch0 -p1
# Disable static library creation by default.
%define with_static 0
...

BUILD THE RPMS

rpmbuild -bb ~/rpmbuild/SPECS/freetype.spec
rpmbuild -bb ~/rpmbuild/SPECS/libXft.spec
rpmbuild -bb ~/rpmbuild/SPECS/cairo.spec


GNOME
Subpixel smoothing (LCDs)

Subpixel order: RGB

Attachments

 $ java -version
gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-44)
$ alternatives --install /usr/bin/java java /usr/java/jre1.6.0_14/bin/java 2
$ alternatives --config java
There are 2 programs which provide 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
2 /opt/jdk1.6.0_07/bin/java
Enter to keep the current selection[+], or type selection number: 2
$ java -version
Java HotSpot(TM) Client VM (build 14.0-b16, mixed mode, sharing)

While running

 rpm -ihv *.rpm

you get the error message

 cpio: MD5 sum mismatch on rpms ...

How to fix:

 rpm --nomd5 -ihv *.rpm

Since Yum does not have a force flag, rpm commands must be used along with Yum to do some heavy lifting. Here are a few ways to force the reinstall of a broken package on a Yum Managed system.
Yum Remove and then Install.The easiest solution is to yum remove the package and then yum install the same package. If there are too many dependencies at stake with the package in question, try another method.

 yum remove PACKAGE
yum install PACKAGE

Force Erase and then Yum Install.RPM dependencies sometimes make a simple yum remove impossible and Yum will want to erase your entire OS before moving on. In this case, use rpm to force erase, then yum to install.

 rpm -e --nodeps PACKAGE
yum install PACKAGE

Prune RPM Database and then Yum Install.If your package install is so corrupted that an rpm -e is dangerous or impossible, even with --nodeps, remove the package from the local RPM database to trick yum into reinstalling the package. No files are deleted when using rpm -e with --justdb.

 rpm -e --justdb --nodeps PACKAGE
yum install PACKAGE

When I build a package, linking fails with

/usr/bin/ld: cannot find -lltdl
collect2: ld returned 1 exit status

This happens because a symbolic link is absent

/usr/lib/libltdl.so -> /usr/lib/libltdl.so.7.x

This is solved by

yum install libtool-ltdl-devel

Update OS:

yum -y update

Enable the DAG repository:

rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i...
rpm -i rpmforge-release-0.3.6-1.el5.rf.i386.rpm
yum update

First of all, consider qutIM (fc11 repo).

For smileys to work, obtain oleaut32.dll from windows and copy into ~/.wine/dosdevices/c:/windows/system32/.

Run winecfg and open "libraries" tab. Choose existing oleaut32.dll or insert this item manually, edit it and select "Native (Windows)".

To avoid choppy sound, run winecfg and open "sound" tab. Choose ALSA adn set hardware acceleration to "Emulation".

Install qipinfium9030.exe into ~/.wine/dosdevices/c:/.

When you run Qip for the first time, wine detects and attempt to show a web page. Let it install GECKO or manually do it: download and install Mozilla ActiveX Control 1.7.12. Ignore installer's requirement to point to mozilla directory.

Obtain and copy msvcp60.dll into /system32. Copy Mozilla Control DLLs into /system32:

find ~/.wine/dosdevices/c\:/Program\ Files/Mozilla\ ActiveX\ Control\ v1.7.12/* -iname '*.dll' -type f  | while read x; do echo cp "$x" "~/.wine/dosdevices/c\:/windows/system32/"; done

To have correct russian character set, run as

LC_ALL=ru_RU.CP1251 wine "c:\usr\local\qip\QIP Infium\infium.exe"

Attachments

Download Mozilla ActiveX Control 1.7.12.Install it and copy all DLLs into /system32. If animated smileys don't work, run qip with argument /oldgif

wine "~/qip.exe" /oldgif

Complete run line:

env WINEPREFIX="~/.wine" wine "C:\Program Files\QIP\qip.exe" /oldgif

Attachments

From here (via here)

cat /var/log/audit/audit.log | audit2allow -m local > local.te
vim local.te
checkmodule -M -m -o local.mod local.te
semodule_package -o local.pp -m local.mod
semodule -i local.pp

This program requireselevated user privileges.Back in 2005 the Portland project proposedsomething likeRequiresRoot=true indesktop entries,then shifted to xdg-su,but it was removed from 1.0. Ubuntu people adopted KDE approach: mark such entries by

 X-KDE-SubstituteUID=true

The menu builder shows such entries only to sudoers, i.e. users beloging to the admin group.This is right the case for synaptic.

PROCESS STATE CODES -different values that the s, stat and state output specifiers(header "STAT" or "S") will display to describe the state of a process.

D Uninterruptible sleep (usually IO)
R Running or runnable (on run queue)
S Interruptible sleep (waiting for an event to complete)
T Stopped, either by a job control signal or because it is being traced.
W paging (not valid since kernel 2.6.xx)
X dead (should never be seen)
Z Defunct ("zombie") process, terminated but not reaped by its parent.
 rsync --progress -xaSHAX sourcedir/ destdir/
 tune2fs -O +journal_data_writeback /dev/sdb9
tune2fs -O +dir_index /dev/sdb9
e2fsck -Df /dev/sdb9

ext2 to ext3:

 umount /dev/sda9
tune2fs -j /dev/sda9
fsck.ext3 -f /dev/sda9
mount -t ext3 /dev/sda9

ext3 to ext2:

 umount /dev/sda9
tune2fs -O ^has_journal /dev/sda9
fsck.ext2 -f /dev/sda9
mount -t ext3 /dev/sda9

Trying to mount using loop device prints

 mount: could not find any free loop device

See why devices are busy

 losetup -a

And probably free one

 losetup -d /dev/loop5

or all

 for f in /dev/loop*; do losetup -d $f; done

You can increase number of available devices.Create /etc/modprobe.d/loop

 options loop max_loop=64

and reload loop module (free all loop devices beforehand)

 rmmod loop
modprobe loop

This will make devices appear automatically.
Newer kernels (2.6.21+) use a dynamic allocation of loop devices,so you will only have to create the filesystem representations:

 for ((i=8;i<64;i++)); do
mknod -m 0600 /dev/loop$i b 7 $i
done

Run it as

 ssh -vvv ...

and see the reason.If it stops pending on reverese DNS lookup, check twice your DNS zones for duplicate records.Also restart your DNS server and see what it spits in /var/log/messages.
If it pends in the gssapi-with-mic authentication, edit /etc/ssh/ssh(d) and set

 GSSAPIAuthentication no


Another reason for hang could be slow DNS. SSH uses reverse DNS check of incoming IP address.

 UseDNS no

Kill hanging process with "-9".

 rpm --verifydb

and if problems are found

 rm -f /var/lib/rpm/__db*
rpm --rebuilddb

On FC9:

 yum reinstall package

On FC7-8 use a trick - remove package from database only:

 rpm -e --justdb --nodeps package
yum install package

Add this in /etc/yum.conf:

 proxy=http://proxy.company.tld:3128
 proxy_username=i-will-never-tell-you-my-real-name
 proxy_password=a-verysimple-fake-password

Add this in /etc/apt/apt.conf.d/proxy:

 Acquire { Retries "0"; HTTP { Proxy "http://proxy.ourdom.com:3128"; }; };

Reinstall RPMS: grub, fedora-logos (for grub splash), kernel

 vi /boot/grub/grub.conf
 default=0
timeout=2
splashimage=(hd0,0)/grub/splash.xpm.gz
 title Fedora Core 8 (2.6.25.14-69)
kernel /vmlinuz-2.6.25.14-69.fc8 ro root=/dev/VolGroup00/LogVol00 rhgb quiet
initrd /initrd-2.6.25.14-69.fc8.img
 grub-install --no-floppy --recheck
grubby --grub --add-kernel=/boot/vmlinuz-2.6.25.14-69.fc8
--title='Fedora Core 8 (2.6.25.14-69)'
--initrd /boot/initrd-2.6.25.14-69.fc8.img
--make-default --copy-default
 rpm -qp --scripts some_package.rpm
rpm -qp --triggers some_package.rpm

With e2fsprogs this works online for ext3 and ext4 on fedora 8 and 11:

pvresize /dev/sda3
lvdisplay
lvextend /dev/VolGroup00/LogVol00 -L +2G
resize2fs /dev/mapper/VolGroup00-LogVol00

If you like GUI, use system-config-lvm.
If your linux runs under vmware, extend vmware disk as:

vmware-vdiskmanager.exe -x 10GB disk.vmdk

For details refer to vmware disk section.

Problem:

$ rpm -e PACKAGE
error: "PACKAGE" specifies multiple packages

Solution:

$ rpm -e --allmatches PACKAGE

Save:

   $ gconftool-2 --dump / > backup.xml

Restore:

   $ gconftool-2 --load backup.xml

I'm using an HP DeskJet 840C connected to the parallel port of a Fedora Core 5with cups-1.2.5-1, hpijs-1.6.6a-1.1, and hplip-1.6.6a-1.1.All packages are binaries from the Fedora repository.
The printer has been successfully installed using the hp:/ backend, andthe device URI in CUPS is hp:/par/DESKJET_840C?device=/dev/parport0. Thebuilt-in test page works, and CUPS can produce its test page -- however, allprintouts are unreadable due to what I presume are cartridge alignmentissues.
If I attempt to run hp-align, I get the following:

 HP Linux Imaging and Printing System (ver. 1.6.6a)
Printer Cartridge Alignment Utility ver. 2.5
...
Using device: hp:/par/DESKJET_810C?device=/dev/parport0
[WARNING]: No status available for device.
An alignment page will be printed.
Please load plain paper into the printer. Press to continue or
'q' to quit.
[ERROR]: Channel write error
Traceback (most recent call last):
...
raise Error(ERROR_DEVICE_IO_ERROR)
base.g.Error: ('Device I/O error', 12)


The fix is:

  $ su
$ cd /usr/share/hplip/data/xml
$ gvim models.xml

Locate this section:

<model name="DESKJET_815C">

Change:

<io support="1" mode="0" control="0" mfp-mode="2" scan-port="0"/>

TO:

<io support="1" mode="1" control="0" mfp-mode="2" scan-port="0"/>


Also see here

Running "strace -f -o trace.log some_multithreaded_app" (BTW -f is importantas otherwise strace wouldn't print at least pids) on Fedora Core 2where the application links with the NPTL implementation by defaultcan very probably freeze sooner or later at a point like:

  futex(0x583844, FUTEX_WAIT, 2, NULL)    = -1 EINTR (Interrupted system call)

I found this can be helped by disabling NPTL via running strace as(don't ask me why 2.4.19 ;) )

  export LD_ASSUME_KERNEL=2.4.19 strace -f -o trace.log some_multithreaded_app

Problem: Nautilus refuses to open *.wmv claiming it is *.asf.
Solution:

 $ vi /usr/share/mime/packages/freedesktop.org.xml

Locate the ASF entry and add:

<alias type="video/x-ms-wmv"/>

Then rebuild the MIME database and restart nautilus

 update-mime-database /usr/share/mime
killall nautilus

Install the following: Xvfb, startx, import (from ImageMagick)
Now let’s try to run Firefox without a visible display.

  • Start Xvfb.
 startx -- `which Xvfb` :1 -screen 0 1024x768x24
  • start Xvfb running on :1 with a screen size of 1024×768 and 24bits/pixel color depth.
 DISPLAY=:1 firefox
  • Take a screenshot.
 DISPLAY=:1 import -window root firefox.png