Linux For Cynics One user's experiences with Linux

29Apr/131

Wifi from Command Line

In this short how-to I'll show you how to connect to a WPA wifi network from the network without any GUI tools.

First, we have to install the relevant software. Some distros do not come with much wifi firmware or wpa support out of the box and they must be installed after the fact. In Debian, follow this guide to install them.

Display the currently active network interfaces:

$ sudo iwconfig

You should see something like wlan0. Let's activate it:

$ sudo ifconfig wlan0 up

Optional if you know the SSID of the network you want:
Scan the interface for access points:

$ sudo iwlist wlan0 scan

Open the /etc/network/interfaces file (replace editor with text editor of your choice):

$ sudo editor /etc/network/interfaces

and add an entry for the network you want to join (replace words in CAPS with your details, where NAME is what you want to call the entry):

iface NAME inet dhcp
  wpa-ssid YOUR-SSID
  wpa-psk YOUR-PASSWORD

Now, just connect to that network!

$ ifup wlan0=NAME

To connect to a different network, simply add another entry to /etc/network/interfaces and run ifup wlan0=NEW-NETWORK-NAME.

26Apr/130

Ubuntu 13.04 Raring Ringtail Released

ubunturaring

Ubuntu 13.04, codenamed Raring Ringtail, has come out of beta! This might be the last regular release on the 6-month cycle, if rumors of a rolling released schedule for Ubuntu are true.

Personally, I am still using Ubuntu 12.04 LTS, but I am considering upgrading just for the new Unity and Gnome Shell versions.

24Apr/130

Install Wifi Firmware and WPA Support in Debian

Debian is a wonderful distribution but it is a bit strict on what it comes packaged with. Most wifi cards do not have open drivers, so you have to install them from the non-free repos. Here's now to install them and use them with wpa-supplicant.

First, we need to add the non-free Debian repositories. Add these lines to the /etc/apt/sources.list file:

deb http://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src http://ftp.us.debian.org/debian/ wheezy main contrib non-free
 
deb http://security.debian.org/ wheezy/updates main contrib non-free
deb-src http://security.debian.org/ wheezy/updates main contrib non-free

Once the non-free repo is added, update and install the driver I need. You might need different firmware:

$ sudo apt-get update
$ sudo apt-get install firmware-iwlwifi

Also get the wireless-tools package:

$ sudo apt-get install wireless-tools

So we have the driver, but now we need to use it!

Since the iwlwifi module is automatically loaded for supported devices, we need to reload this module to access installed firmware:

$ sudo modprobe -r iwlwifi ; modprobe iwlwifi

Now we see if the device has an available interface:

$ sudo iwconfig

Yep! Mine is called wlan0. Connecting to a wpa secured wifi will be covered in the next post.

22Apr/130

Shutdown from Command line

In order to shut down your system from the command line, use the shutdown command in a virtual terminal or terminal emulator:

$ sudo shutdown -h now

The shutdown command must be invoked with a time to shut down. That's what now is. The -h flag tells the system to power off. For more options, see the man page.

Tagged as: No Comments
19Apr/130

Check your Laptop Battery Status from Command Line

The tool used to query laptop battery state is called acpi. In Ubuntu or Debian, install it like so:

$ sudo apt-get install acpi

Let's run it!

$ acpi

The output looks something like this:

Battery 0: Discharging, 99%, 02:34:33 remaining

There are various options for acpi we can use:

Check the temperature:

$ acpi -t

Output:

Thermal 0: ok, 48.0 degrees C
Thermal 1: ok, 48.0 degrees C

To check the AC power status

$ acpi -a 

Output:

AC Adapter 0: off-line

You can check all the status together:

$ acpi -V

Output:

Battery 0: Discharging, 96%, 02:33:55 remaining
Battery 0: design capacity 1773 mAh, last full capacity 1723 mAh = 97%
Adapter 0: off-line
Thermal 0: ok, 48.0 degrees C
Thermal 0: trip point 0 switches to mode critical at temperature 105.0 degrees C
Thermal 0: trip point 1 switches to mode passive at temperature 90.5 degrees C
Thermal 1: ok, 47.0 degrees C
Thermal 1: trip point 0 switches to mode critical at temperature 127.0 degrees C
Cooling 0: LCD 8 of 15
Cooling 1: Processor 0 of 10
Cooling 2: Processor 0 of 10
17Apr/130

Change the Hostname (Computer name) in Ubuntu

Changing your computer's name (also called the system's "hostname") in Ubuntu is simple. You just have to change two files and restart the computer. These instructions also work for Debian and Ubuntu-based distros (like Linux Mint). The files in question are /etc/hosts and /etc/hostname

1. Open /etc/hosts with sudo (or gksu if you're going to use something like gedit)

$ gksu gedit /etc/hosts

The file will look something like this:

127.0.0.1       localhost
127.0.1.1       current_hostname

Instead of current_hostname you'll see the hostname / computer name. Change it to whatever you want the new name to be. Save and close the file.

2. Open /etc/hosts with sudo (or gksu if you're going to use something like gedit)

$ gksu gedit /etc/hostname

This file just contains the hostname / computer name. Change it to whatever you want the new computer name to be. Make sure it matches the name you put in /etc/hosts. Save and close the file.

3. Restart your computer.

Tagged as: , No Comments
15Apr/130

Root Droid Razr Maxx HD Running 4.1.2

If you have a Motorola Droid Razr HD or Driod Razr Maxx HD running Android version 4.1.2, you might have read that it's not possible to root your device. Well, that has changed. Last week Dan Rosenberg released a root method for the Razr HD, Razr Maxx HD, Razr M and Atrix HD.

I tested this method using a Razr Maxx HD (XT926) with build 9.16.6. It was very easy and worked flawlessly. Here are the instructions from Dan's post:

1. Download this file to your PC.
2. Extract the entire contents of the zip file.
3. If you are using Windows, ensure you have installed the latest Motorola USB drivers available for your phone. I did not have to install any special drivers using Linux (tested with Debian 7.0 and Ubuntu 12.04).
4. Ensure USB Debugging mode is enabled on your device.
5. If you are using Linux or OS X, navigate to the extracted directory in a terminal and execute “./run.sh” (If you are using Windows, navigate to the extracted directory and execute “run.bat”).

Here's a video showing the rooting process:

Tagged as: No Comments
12Apr/131

Using rxvt-unicode-256color with ssh and screen

urxvt is one of the best terminal emulators available, however it comes with problems. For example, if you use ssh to connect to a remote host and then try to use screen, you might get an error like this:

Cannot find terminfo entry for 'rxvt-unicode-256color'.

The work around for that is to add this line to your ~/.Xdefaults or ~/.Xresources file (I used .Xresources):

URxvt*termName: rxvt

This will make urxvt identify as rxvt, which should work with screen.

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