Linux For Cynics One user's experiences with Linux

10Apr/130

Determine What Version of a Package is Installed on Ubuntu or Debian

If you want to find out what version of a package you have installed, dpkg will give you information concerning a package, including the version, if you use the "--status" option, like so:

$ dpkg --status packagename

where packagename is the package in question.

Now, it gives a lot more than the version.
For example,

$ dpkg --status openbox

Returns:

Package: openbox
Status: install ok installed
Priority: optional
Section: x11
Installed-Size: 1316
Maintainer: Debian QA Group 
Architecture: i386
Version: 3.5.0-7
Provides: x-session-manager, x-window-manager
Depends: libc6 (>= 2.2), libglib2.0-0 (>= 2.24.0), libice6 (>= 1:1.0.0), libobrender27 (>= 3.5.0), libobt0 (>= 3.5.0), libsm6, libstartup-notification0 (>= 0.7), libx11-6, libxau6, libxext6, libxinerama1, libxml2 (>= 2.7.4), libxrandr2, libxrender1
Pre-Depends: dpkg (>= 1.15.7.2)
Recommends: openbox-themes, obconf
Suggests: menu, ttf-dejavu, python, libxml2-dev
Breaks: menu (<< 2.1.12)
Conffiles:
 /etc/menu-methods/openbox 454ed1e8309e6fc60b0d16894d541dfd
 /etc/xdg/openbox/menu.xml 96647f77053f8d73987a6e2b77b18e8f
 /etc/xdg/openbox/rc.xml da6375c910abc7dfb69f26b6bd7deb70
 /etc/xdg/openbox/environment 34bbf463555dbfb8f97fe957489d73b7
 /etc/xdg/openbox/autostart 2e828424c93a51d910382b53a9729166
Description: standards compliant, fast, light-weight, extensible window manager
 Openbox works with your applications, and makes your desktop easier to manage.
 This is because the approach to its development was the opposite of what seems
 to be the general case for window managers.  Openbox was written first to
 comply with standards and to work properly.  Only when that was in place did
 the team turn to the visual interface.
 .
 Openbox is fully functional as a stand-alone working environment, or can be
 used as a drop-in replacement for the default window manager in the GNOME or
 KDE desktop environments.
 .
 Openbox 3 is a completely new breed of window manager.  It is not based upon
 any existing code base, although the visual appearance has been based upon
 that of Blackbox.  Openbox 2 was based on the Blackbox 0.65.0 codebase.
 .
 Some of the things to look for in Openbox are:
 .
  * ICCCM and EWMH compliance!
  * Very fast
  * Chainable key bindings
  * Customizable mouse actions
  * Window resistance
  * Multi-head Xinerama support!
  * Pipe menus
Homepage: http://www.openbox.org

So, to only see the version, just pipe the output of dpkg -status to grep, for example:

$ dpkg --status openbox | grep 'Version'

will output something like this:

Version: 3.5.0-7

Note, dpkg --status packagename can be replaced with any of the following:

$ dpkg -s packagename
$ dpkg-query --status packagename
$ dpkg-query -s packagename
Tagged as: , No Comments
8Apr/131

Install Screenfetch and Archey in Ubuntu or Debian

Archey and Screenfetch are programs that display system information along side an ASCII art rendition of your distro's logo. You will often see their output on screenshots showing off a user's customized desktop. They are also sometimes used to display info on user login. However, neither of them are in Ubuntu's or Debian's official repositories. Here's how to install them.

Archey

$ sudo apt-get install lsb-release scrot  
$ wget http://github.com/downloads/djmelik/archey/archey-0.2.8.deb  
$ sudo dpkg -i archey-0.2.8.deb 

And just run

archey

and you'll get a result like this:
archey

Screenfetch

$ wget http://served.kittykatt.us/projects/screenfetch/screenfetch-2.5.0.deb  
$ sudo dpkg -i screenfetch-2.5.0.deb 

Run

screenfetch

to generate something like this:
screenfetch

5Apr/139

Install Spotify on Debian Testing (Wheezy)

If you follow the instructions on the Spotify Linux Preview website to install Spotify on Debian Wheezy, you will get the following error from apt:

The following packages have unmet dependencies:
spotify-client : Depends: libssl0.9.8 but it is not installable

The problem is that Spotify is hardlinked with libssl0.9.8, and the Wheezy repos only have libssl1.0. This is a very easy problem to rectify. Just go to the libssl0.9.8 package page for Squeeze and download the appropriate package for your architecture.
download_libssl
Then install the package, like so:

sudo dpkg -i /path/to/package.deb

(of course replace "/path/to/package.deb" with the actual location of the libssl0.9.8 package you just downloaded)

Now you should be able to install spotify-client by following spotify's instructions:

# 1. Add this line to your list of repositories by
#    editing your /etc/apt/sources.list
deb http://repository.spotify.com stable non-free

# 2. If you want to verify the downloaded packages,
#    you will need to add our public key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59

# 3. Run apt-get update
sudo apt-get update

# 4. Install spotify!
sudo apt-get install spotify-client
3Apr/130

Which Architecture

A common question a lot of new users have is, what is an "architecture" and which one does my computer use?

If you really want to know what is meant by computer architecture, then there's always wikipedia to learn from.

In the context of Linux users, I usually hear this question in a couple different scenarios:

Q: I want to install a Linux distribution, which version do I need, 32 or 64 bit?

A: You can't go wrong by installing a 32 bit distribution, because hardware designed to run 64 bit software, can run 32 bit software with no problem. Here's a list of 64bit CPUs. If your CPU is on your list, you might want to use a 64 bit version of your distro instead. A little tip: If you really need to ask this question and the answer confuses you, just go with the 32 bit version.

Q: I already have Linux running on this machine, now I want to know if it's a 32 bit kernel, or a 64 bit kernel.

A: Easy!

uname -m

will give you the architecture of your kernel. i386, i686 are 32 bit, and amd64 is 64 bit!

Q: Okay, how do I find out if my CPU is 32 or 64 bit, regardless of what Linux kernel it's running?

A: There are actually a few ways to do this:

lscpu

displays cpu info, and will tell you the architecture of your CPU and if it can use 64 bit op-mode. This is probably the easiest way.

Another way:

grep lm /proc/cpuinfo

searches for the "lm" string in /proc/cpuinfo/. If it's found, that means the CPU is capable of 64 bit mode. Btw, lm means "long mode".

Tagged as: No Comments
29Mar/130

Using pkg-config to Find Library Names

If you are trying to use a library in your program, of course you need to link with it. How do you know what it's called? Use pkg-config! From the pkg-config man page

The pkg-config program is used to retrieve information about installed libraries in the system. It is typically used to compile and link against one or more libraries. Here is a typical usage scenario in a Makefile:

program: program.c
cc program.c $(pkg-config --cflags --libs gnomeui)

Here are some common usages:

List all installed libraries:

pkg-config --list-all

List what compiler flags you need for somelib:

pkg-config --cflags somelib

List what linker flags you need for somelib:

pkg-config --libs somelib

Then there's also --static if you're compiling statically.

pkg-config outputs in a format that is ready for gcc, so you can use backticks to run it and get the output when invoking gcc on the command line:

gcc program.c `pkg-config --cflags --libs zlib`

Or if you use a makefile you can capture it in variables:

LIBS := $(shell pkg-config --libs zlib)
CFLAGS := $(shell pkg-config --clfags zlib)

27Mar/1317

Improve Font Rendering in Debian

After installing Debian Testing (Wheezy), and started using Firefox (aka Iceweazel), one of the first things I noticed is that the default font rendering in Debian is not pretty.

Luckily, fixing this is very straight foward. Create a file called .fonts.conf in your home directory, and put the following contents in it:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match target="font">
  <edit mode="assign" name="rgba">
   <const>rgb</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hinting">
   <bool>true</bool>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="hintstyle">
   <const>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
    <edit mode="assign" name="lcdfilter">
      <const>lcddefault</const>
    </edit>
  </match>
</fontconfig>

This will enable subpixel-hinting and font-smoothing. Now just restart X.org (log out, then back in again). Read more here: http://wiki.debian.org/Fonts

Here's the before and after (before is on the left):
fontrendering_beforeandafter

25Mar/130

Set Keyboard Repeat Delay and Rate

In order to change the key press repeat delay and rate we use a command called

xset

which is a user preference utility for X.

This command:

xset r rate DELAY RATE

where DELAY and RATE are replaced with actual values, in milliseconds. for example:

xset r rate 200 20

First, use

xset q

to see what the current values are. As shown above, I have mine set to 200 delay and 20 repeat rate.

To make this permanent, add that line to your ~/.xinitrc

xset can be used for a lot more than this. As always, use

man xset

to find out more about this command.

22Mar/130

Create Screenshots from Terminal Emulator

Probably the simplest way to create screenshots is using the commands

xwd

which dumps an image of an X window and

convert

which is a member of the ImageMagick suite of tools. It can be used for much more than converting image formats, but that's what we'll be using it for this time.

Screenshot of Whole Screen

So, to take a screenshot of your whole screen and call it capture.png, run this:

$ xwd -root | convert - capture.png

Add a Delay

Let's say you want to add a delay before the screenshot is taken (say, to move the terminal window out of the way), then simply add a sleep command before the others. For example:

$ sleep 3; xwd -root | convert - capture.png

adds a three second delay before the x window is dumped, and converted to a png.

Screenshot of Single Window

The "-root" argument to xwd tells it to capture the entire X window tree, the whole screen. If you leave it off, you will be given a cursor to click the window you want to capture.

So, if you just want to take a screenshot of a single window, then just run:

$ xwd | convert - capture.png

And click on the window you want.

Note:
I say "terminal emulator" because the xwd command relies on X to be running. This would not work on a login without X running.

20Mar/130

Using MD5 to Verify Downloaded Files

An MD5 sum is a string of numbers and letters used to verify the integrity of a file. If two files are identical, then they have the same MD5 sum. Here's an example of how to use it:

Let's find a file to download, such as the Crunchbang Linux installer image:

md5capture

Notice how it has the MD5 sum to check against under the download link? Once we have it downloaded, we can run md5sum to generate the checksum for the file we have on our disk:

$ md5sum crunchbang-11-201330119-i686.iso

Now just check to make sure that the resulting string is the same as the one listed! If it's the same, then the file on the server is identical to the file you downloaded.

Filed under: How to No Comments
18Mar/130

List Installed Packages in Debian or Ubuntu

In order to display the list of installed packages, use this command:

dpkg --get-selections

Chances are you have a lot of packages installed, so use grep to find something particular, for example, to see any packaged with the word "gnome" in their name:

dpkg --get-selections | grep gnome

Or, if you want to see how many packages you have installed, you can use the wc program:

dpkg --get-selections | wc

The first number is the number of lines dpkg output, and since there is one line per package, it is the number of packages installed.