The iproute2
package offers the ip
utility, which is a modern replacments for tools such as ifconfig
, route
, arp
and more. It allows to configure addresses, links route and arp tables. The only problem is that its documentation can be quite confusing. This post is intended to be a task-oriented guide to this utility, it’s far from complete and I intend to update it from time to time.
Continue reading iproute2
Cheatsheet
Category: Linux
Kernel Configuration and nvidia-drivers
This is more of a note to myself, as I keep forgetting this. The propriety NVIDIA drivers, provided by the x11-drivers/nvidia-drivers
dislikes alternatives. It will refuse to build against a kernel with the rivafb
(CONFIG_FB_RIVA
) and nvidiafb
(CONFIG_FB_NVIDIA
) built in or built as modules. Both can be found (and unset) under:
Device Drivers
-> Graphics support
-> nVidia Framebuffer Support
-> nVidia Riva support
sudo
for X Programs
By default (at least on my machine), it wasn’t possible to open X applications using sudo
. For example sudo
ing xclock
resulted in the following error:
$ sudo xclock
No protocol specified
Error: Can't open display: :0.0
The same error appeared even when I executed xclock
after running sudo su
.
Continue reading sudo
for X Programs
Eject Your Kindle and Reconnect under Linux
I am Your User suggested a method to eject your Kindle in Linux. While his method works, you don’t need to specify the partition number. E.g.
$ sudo eject /dev/sdd
where /dev/sdd
is the device file of the Kindle.
But what if you want to reconnect it back without plugging in and out the usb cable? You can add the -t
switch.
$ sudo eject -t /dev/sdd
Even though it prints the following error:
eject: CD-ROM tray close command failed: Input/output error
it works, and the Kindle reappears in KDE.
Searching for Updates without emerge
The normal way to see which installed packages have available updates on Gentoo is running
$ emerge -puv world
And then you usually select the packages you really want to update and emerge them. However this workflow has several downsides:
- It’s slow. When portage checks for updates this way it fully resolves all the dependencies. This process is unnecessary, as in many cases you aren’t interested in updating all the packages, furthermore in their dependencies.
- It may fail. When portage fails to resolve the dependencies, it will either complain or completely fail. If it complains, it isn’t really that bad, except for the time used for resolving the unanswered dependencies. Sometimes it fails completely (usually when masking is involved) and won’t display any of the available packages, hence leaving the user in the dark (except for some dependency error message).
- It displays lot’s of output. Many times you’re not interesting in seeing the dependencies that will be updated if you emerge every package in the world file. It’s just confusing and distract you from the interesting updates for packages in the world file.
The following scripts tries to work around these problems. It works by querying the portage API for the best version available for each package in the world file. If that version isn’t installed it reports that there are updates waiting for that package. The script runs faster then emerge -pvu world
and only displays the packages from the world file. If you find a package that you want to upgrade you can emerge it separately to see the required dependencies.
Upgrading All QT Modules in Gentoo
Upgrading minor versions QT seems to be a hassle, as each version blocks the previous and because of inter-dependencies, Gentoo can’t understand by itself how to solve them. The solution is to tell it to specifically upgrade all installed modules.
Continue reading Upgrading All QT Modules in Gentoo
NVidia driver fails to initialize after X restart
This is mainly a note to myself. Sometimes when the X server is restart it complains that nvidia
driver couldn’t be initialized and that no screens were found. This may be a result of a version mismatch between X11’s and the kernel’s nvidia
module. The solution is to
modprobe -r nvidia
before restarting the X server.
Blocking IP Range using UFW
Uncomplicated Firewall (ufw
) is one of the greatest frontends to IPTables I’ve encountered. It is very simple to use and I just wish it was also available for Gentoo. Up until recently everything went smoothly for me and ufw
, but we hit some rough waters when I’ve tried to block an IP range.
To block an IP or IP range in ufw you should do
sudo ufw deny from 188.162.67.197/21
Using Amarok Generated Playlists (m3u) on Sansa Clip
Few days ago, for the first time, I’ve created a playlist using Amarok for files on my Sansa Clip player. To my surprise (and disappointment) when I’ve unplugged my Sansa Clip and powered it, the playlist showed up empty, unlike playlists which originated in Windows. As I keep my music collection organized in Amarok, the situation seemed to be very uncomfortable.
I’ve decided to compare one of the working playlist files and the “empty” Amarok generated playlist. Two things were noticeable:
- Amarok uses forward slashes, like in a Linux environment, and the working playlist used backward slashes.
- The working playlist used relative paths without any prefix – directly beginning with the path. Amarok prefixed the relative paths with a dot-slash (./).
After noticing those things I’ve modified my Amarok generated playlist to look like the Windows generated one, and voila, it worked. I tried going through Amarok’s configuration dialogs to find some option controlling the format of generated m3u playlists, but couldn’t find any (I’m using Amarok 1.4.10). So with my newly found wits I’ve looked for a way to make using the playlists easier. I’ve came up with the following one-liner:
find -name "*.m3u" | xargs -I{} sed "s/^\.\///;s/\//\\\\/g" -i'' {}
The command should be run in the MUSIC
directory of the Sansa Clip’s filesystem. It recursivey looks for m3u playlists and for each one strips any leading dot-slash and replaces forward slashes with backward ones. It can be used to easily convert all your playlists to the format understandable by Sansa Clip.
Upgrading All KDE Related Packages in Gentoo
Yesterday, Gentoo marked KDE 3.5.10 as stable on amd64. I looked for a way to upgrade all of the KDE related packages, without manually specifying each one of them. Normally one could do
emerge -avu world
but I encountered some nasty conflicts that I didn’t have time, nor will, to resolve at that time. So I’ve looked for a different solution. To my rescue came qlist
for the great app-portage/portage-utils
package. This package provides a set of very fast utilities to query portage
. I’ve used qlist
to list all of my installed packages, grep
‘ed the list and piped the result as arguments to emerge
using xargs
.
Continue reading Upgrading All KDE Related Packages in Gentoo