Notes about Linux (Gentoo) - General

(Or, back to main notes index)



FEATURES="-sandbox" emerge <application>
Or, if emerge db or emerge sandbox fails, use as well FEATURES="-sandbox" emerge sandbox and then try again emerging db.
Or, if a package is masked by the ~x86 keyword, add eg. "app-laptop/fnfx" (without version number) to the file /etc/portage/package.keywords. E.g.: media-tv/mythtv ~x86
Or, if you want to install a specific version of a software which is masked write the version and add an equal sign in front of the string. E.g.: =media-tv/ivtv-0.8.2
  • To update the system "emerge --update --deep world" and or "emerge --update --deep --newuse world" is you modified the USE flags.
  • Local portage database can be searched faster using eix.
  • Mouse speed:
xset m 1/2 5
  • Problems with installing Mythtv and making it update the mysql database:
To see if you have problems because of UTF8, run mythbackend in a terminal. If you get an error about the primary key being too long try:
$mysql -u root
DROP DATABASE mythconverg;
CREATE DATABASE mythconverg CHARACTER SET latin1;
exit;
If mythbackend says it was already started and as well already stopped write "/etc/init.d/mythbackend zap".
  • To automatically load modules on boot modify the file /etc/modules.autoload.d/kernel-2.6
  • Keyboard remap:
    The bindings of enlightenment are under "/usr/share/e16/config/bindings.cfg"
    xev is a small program that shows the key codes of the keys pressed
    xmodmap maps one key with another. Example:
    xmodmap -e "keycode 77 = Down"
    Such mappings can be saved in the root directory in a file called eg. .Xmodmap which contains informations eg. in the following format:
    keycode 77 = Down
    This can be loaded automatically at X-startup, e.g. with a script containing xmodmap $HOME/.Xmodmap.
    Afterwards it is possible to set in the file .xbindkeysrc instructions like...
    "eesh desk arrange"
    Down
    
    "$MYSCRIPTS/menu/alsa_increase_volume"
    XF86AudioRaiseVolume
    
    ...and automatically set xbindkeys upon X-startup to have those scripts & applications run whenever you press the key.
  • How to user multimedia keys: A description of how to map keys to programs or events.
  • To write / flush the data from memory to the harddisk use the "sync" command (has no options).
  • If a system fails during boot (Error "Could not create directory...) and it is on a jfs partition it is because a deeper filesystem check with "jfs_check -f /dev/hdaX" has to be performed on the not mounted partition.
  • eesh can be used in order to change enlightenment parameters and as well the desktop.
  • To update the system:
    emerge --update --deep [--newuse] world
  • To see what's the estimated end of emerging the current package type:
genlop -c
  • To see what's currently being emerged type:
tail /var/log/emerge.log
  • To see the CPU usage of a process using the command PS, digit:
ps -o cpu -p [pid of the process]
"cpu" could be as well uppercase.
  • To do a grep NOT for the word specified (opposite behaviour), use "grep -v".
  • You tell X to use enlightenment by editing the file rc.conf
  • Kernel modules that have to be loaded are saved in the file "/etc/modules.autoload.d/kernel-2.6". Run "modules-update" after modifiying the list.
  • Global variables can be defined in the file /etc/env.d/99local (create it if you never defined global vars before). !!!Run env-update afterwards!!!
  • In order to send keyboard events, use xvkbd. Per example, type the following in order to send a backspace char event to Firefox:
    xvkbd -window 0x1c00040 -text "\b"
Use eesh in order to get the window id:
eesh wl | grep -i firefox
If you have to use special keys, you have to use the utility xev (should be included in X - it is not in gentoo), grab the keysym (example the right arrow is 0xff53),...
... then search the code 0xff53 in the file...
/usr/include/X11/keysymdef.h
..., find the key definition you're interested in (like in this case XK_Right), remove the XK_ and use the remaining string like this:
xvkbd -window 0x1c00040 -text "\[Right]"
Another example is if you have two X servers running. By sending a combination of ctrl+alt+F7 or F8 you switch servers:
xvkbd -display :0 -text "\C\A\[F7]"
  • In order to set the dynamic CPU clock, type:
echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
  • After re-compiling the kernel or changing version, re-emerge nvidia-drivers, ieee80211 and ipw2200.
  • To create and MD5 SSH1 digest file do
ebuild xf86-video-ivtvdev-0.10.6.ebuild digest
  • Use johntheripper to guess passwords (e.g. /etc/shadow)
The config file is located in /etc/john/
  • Use "lsof" to list the open files.
"lsof -u <username>" lists for each user the files that are open.
"lsof <filename>" lists for a specific file who has it open.
"lsof -c <running program name>" lists the files opened by a specific program.
  • Read this article on Gentoo for important informations on memory management in Linux (e.g. why you see only 880MB RAM for your system even if you have more installed).
  • The program "free" shows the available memory.
  • Use usbview to see which USB devices are connected to what.
  • If during an emerge of kdelibs I get "ERROR: kde-base/kdelibs-3.5.5-r6 failed.", and I just switched compiler version, follow the guide under http://www.gentoo.org/doc/en/gcc-upgrading.xml
  • You can delete the whole content of the directory /usr/portage/distfiles/ if it's using too much space. Emerge will afterwards automatically download anything that is missing during an emerge.
  • Run the command time <command> to see how much cpu time (real time and sys/user time of the CPU) was used by the execution of the command.
  • To send signals to a dcop-enabled applicatin, enter first...
    dcop <applicationname>
...to get the list of the parts of the application that are able to get signals, and afterwards...
dcop <applicationname> <partname>
...to see which signals can be sent. The ones with <void> at the beginning don't return any value.
Therefore, to start playing a song in Amarok, type the command...
dcop amarok player play
  • A good virtual keyboard for X, so that a real keyboard is not needed and character input can be done on-screen, is XVkbd.
To set the layout of the keyboard use xrdb (before starting xvkbd). Eg.:
cd /usr/share/X11/app-defaults/
xvkbd XVkbd-swissgerman
  • Mount an iso image like this:
    mount -o loop,ro -t iso9660 imagename.iso /mnt/cdrom
  • DMG images can be burned using cdrecord: cdrecord dev=/dev/cdrom mac_image_file.dmg
  • How to mount DMG image files (MAC):
Check with the file command what kind of image the file is:
file mac_image_file.dmg
mac_image_file.dmg: Macintosh HFS Extended version 4 data last mounted...
It can be mounted with:
mount -o loop,ro -t hfsplus mac_image_file.dmg /mnt/yourmountpoint
  • In order to be able to access RAM beyond 880MB, activate in the Kernel setup "Processor Type and Features => High Memory Support". See this article about Linux memory management.
  • To see details about the motherboard, use "dmidecode".
  • Use blkid in order to get the UUID of the drives.
  • In order to assemble a software raid using the UUIDs of the drives, find out the UUID with (if e.g. the partitions that compose the raid are sdf1 and sdg1)...
    mdadm --examine --scan /dev/sd[fg]1
...and afterwards assemble it with the command (if md1 is the target)...
mdadm --assemble /dev/md1 --uuid=56301900:9d834972:43b1cab9:ee964b44
  • If a failure happens in a sw-raid after you replace the HDD it's enough to run e.g. ...
    mdadm /dev/md1 --add /dev/sdf1
...to add the new HDD to the raid and start the recovery/sync/rebuild.
  • The Canon i865 works well with CUPSD if configured as a "bjc600" (remember to emerge CUPS with the ppds flag).
  • Send remote processes to sleep with kill -STOP PID or kill -19 PID and resume them with kill -CONT PID or kill -18 PID.
  • If in a RAID array two HDDs or more fail / get an unhealthy status at the same time, there is the possibility that something might have gone wrong with the drivers of the controller. Try to restart the array with all the HDDs (e.g. a RAID 5 with 4 HDDs)...
    mdadm --assemble --force /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
...and check in "cat /proc/mdstat" if both the HDDs are still marked as "failed". If not, try to re-add the faulty HDD with...
mdadm --manage /dev/md0 --add /dev/sdd1
...or whichever HDD failed and see if the RAID rebuilds correctly and still works afterwards.
  • The top 100 Amiga games (for UAE emulator): http://www.lemonamiga.com/games/votes_list.php
  • If when booting using an ide-CD or -DVD you get an error saying...
    No bootable medium found. Waiting for new devices...
    Could not find CD to boot, something else needed!
...give to the kernel the option all-generic-ide. More informations here.
  • If you're using e.g. an external HDD-case which contains multiple HDDs and this is connected by USB and you can only see one of them, make sure that the kernel has "SCSI_MULTI_LUN" activated (under "Device Drivers -> SCSI device support -> Probe all LUNs on each SCSI device").
  • Use cp -Rxvad to copy EVERYTHING from one HDD to another - e.g. when you want to copy everything from one partition to another.
  • Use "ccd2iso" to convert a CloneCD image (.img) to a normal iso image.
  • Run update-pciids so that lspci can show up-to-date descriptions of your pci devices. There are as well other update-* commands - e.g. for the ca-certificates, usb devices, etc... .
  • Use "powertop" to see how to improve notebook in battery mode.
  • To split up a file into smaller pieces:
    rar a -v2048k outfile file
  • To have a look at the hardware (e.g. RAM speed, CPU type, Chipset, etc...) use lshw or dmidecode.
  • Use k9copy to make backups of DVDs.
  • Use iotop to see which process generates the most disk activity.
  • To avoid a filesystem check during boot just write an empty file called fastboot in the root directory
    touch /fastboot
  • Clones of Windiff in Linux are e.g. Easydiff or xxdiff.
  • Location of Kernel modules is e.g. in /lib/modules/2.6.28-gentoo and they have the ending .ko.
  • Use gpg -c <filename> to encrypt a file. Just gpg <filename> to decrypt it.
  • If, after taking out some HDDs from a SW-raid, the system says...
    /dev/sdX is apparently in use by the system; will not make a filesystem here!
...when creating or mounting an ext filesystem (e.g. mkfs.ext3 /dev/sdX), and you're sure that the disk is not mounted (df -h) nor in use by the raid (cat /proc/mdadm), the format fails because the superblock of the raid is still present at the end of the HDD. The solution is to overwrite the HDD with 0s (dd if=/dev/zero of=/dev/sdX bs=64k). BE CAREFUL - YOU WILL LOSE ALL THE DATA ON THE HDD!!!.
  • mdadm commands lookup:
Create a raid:
mdadm --create --verbose /dev/md2 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1
Grow a raid (HDDs replaced by some bigger ones and raid already re-synced):
mdadm --grow /dev/md2 --size=max
See here about shrinking and growing raids.
Startup a raid:
mdadm --assemble /dev/md0 --uuid=503cbba1:7bed6e2f:b543e69e:13f1698e
Or:
mdadm --assemble /dev/md0 /dev/sdc1 /dev/sdd1
Stop a raid:
mdadm --stop /dev/md0
Delete a raid:
mdadm --manage /dev/md0 --fail /dev/sdc1
mdadm --manage /dev/md0 --remove /dev/sdc1
mdadm --zero-superblock /dev/sdc1
  • iozone command line...
    iozone -a -z -i 0 -i 1 -i 2 -i 5 -b exceloutput.xls -e -g 16777216
...will generate an excel file, use biggest file of 16GB for testing purposes, run an fsync for each file, perform automatic testing sizing, test as well small record sizes with very big files, perfom tests write/rewrite, read/re-read, random-read/write, stride-read.
Alternatively...
iozone -a -z -i 0 -i 1 -i 2 -i 5 -b exceloutput.xls -e -s 16G
...to run the tests on just a single 16GB file.
Or:
iozone -a -i 0 -i 1 -i 2 -i 5 -i 8 -b exceloutput.xls -e -g 8G
...to run additionally a random mix of "reads/writes" and run all test sizes, with a maximum file size of 8G.
  • To use an HP printer in Linux, install "hplip" and use it in combination with cups. Make sure to use the latest version (unmask for emerge).
The location in the network where to find the CUPS-server is defined in "/etc/cups/client.conf". Add a like like e.g. "ServerName <mycupsserver>:<cupsserverport>"
  • Use "keytouch" to easily assign commands to special notebook buttons or similar.
  • Use "autounmask" to automatically unmask a series of masked packages.
  • Hard-masked packages can be unmasked in Gentoo by commenting the line in "/usr/portage/profiles/package.mask".
  • To avoid loading automatically modules ("autoload") when the system boots, add the module name that you don't want to be loaded in /etc/modprobe.d/blacklist.conf. The entry will be e.g. "blacklist <your_module>".
  • Send stats about your Gentoo installation (smolt): http://www.linuxquestions.org/questions/gentoo-87/gentoo-machine-setup-statistics-public-beta-test-launched-756303/
  • If you modify an ".emerge"-file in Gentoo you will have to modify as well the hash values inside the Manifest file. To do that use "ebuild <.ebuild-file> manifest" which will generate a new "Manifest"-file for all files in that directory.
  • Use "ntp"/"ntpd" (/etc/init.d/ntp-client start) and then "hwclock" (hwclock --systohc) to set the system clock/date and set the hardware clock with that value.
  • Mount raw local devices to loop devices (loopback) with "losetup":
Mount: losetup /dev/loopX /myfile.img
Check if anything is mounted: losetup /dev/loopX