Linux For Cynics One user's experiences with Linux

11Aug/151

Mpv is the Best Media Player for Linux

mpv-logo
The mpv-player is just the best thing we have got these last years.
Even if you use madvr, mpc-hc or mpdn, mpv is a good thing for you.
Because mpv is open source, that's fucking awesome.
All these proprietary projects have copied amazing code from mpv.
So just say thanks. ;)

29Jan/140

bro pages: an improvement on man pages

bro pages are a highly readable supplement to man pages.
bro pages show concise, common-case examples for Unix commands.

9Sep/130

Pull a Git Branch from Remote

In order to check out a remote git branch, first do a git pull:

git pull 

Then

git checkout -b [new_branch] > origin/[new_branch]

So for example, if your branch name is "newfeature", you'd do:

git pull
git checkout -b newfeature origin/newfeature
Tagged as: No Comments
2Aug/130

Reset or Change Terminal Background

Sometimes if you use vim in a virtual terminal with a color scheme with more than a 256 color pallet, you will have some ugly results:
debian-2013-08-02 14_46_17-
Even worse, those ugly colors may stick around after vim has exited. This is because a virtual terminal is essentially a state machine. When something changes, it has to be explicitly changed back to reverse it:
debian-2013-08-02 14_48_40-

One way to do this is to use the

tput

command. To go back to the normal colors, simply use this command:

$ tput reset
8May/133

Restart VNC Server via SSH

This is handy if the VNC server isn't working but you can connect via SSH. These instructions are for Ubuntu, which comes with vino-server for VNC.

To kill the currently running vino-server (if it is running), use pkill:

$ pkill vino

Then to start it again,

$ export DISPLAY=:0.0
$ /usr/lib/vino/vino-server &

That works in Ubuntu 12.10. If using something else, replace /user/lib/vino/vino-server with the location of your VNC server.

6May/130

Simple Command Line Calendar

The cal program displays a simple calendar on the command line. Here are some examples of its use:

Invoking it with no arguments displays the current month.

$ cal

Output:

      May 2013        
Su Mo Tu We Th Fr Sa  
          1  2  3  4  
 5  6  7  8  9 10 11  
12 13 14 15 16 17 18  
19 20 21 22 23 24 25  
26 27 28 29 30 31

To see a particular month, run it with like cal month year:

$ cal 12 2013

Output:

   December 2013      
Su Mo Tu We Th Fr Sa  
 1  2  3  4  5  6  7  
 8  9 10 11 12 13 14  
15 16 17 18 19 20 21  
22 23 24 25 26 27 28  
29 30 31  

To see a whole year, run it with like cal year:

$ cal 2013

Or to display a 3 month period instead of just the current month, use the -3 flag:

$ cal -3

Output:

     March 2013            April 2013             May 2013        
Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  Su Mo Tu We Th Fr Sa  
                1  2      1  2  3  4  5  6            1  2  3  4  
 3  4  5  6  7  8  9   7  8  9 10 11 12 13   5  6  7  8  9 10 11  
10 11 12 13 14 15 16  14 15 16 17 18 19 20  12 13 14 15 16 17 18  
17 18 19 20 21 22 23  21 22 23 24 25 26 27  19 20 21 22 23 24 25  
24 25 26 27 28 29 30  28 29 30              26 27 28 29 30 31     
31         

This flags can be combined.

Finally, use the ncal command instead of cal to display the calendar in a more space-efficient way:

$ ncal 12 2013

Output:

    December 2013     
Su  1  8 15 22 29   
Mo  2  9 16 23 30   
Tu  3 10 17 24 31   
We  4 11 18 25      
Th  5 12 19 26      
Fr  6 13 20 27      
Sa  7 14 21 28 
Tagged as: No Comments
1May/130

Virtual Richard Stallman

vrms is a package that will analyze the set of currently-installed packages on a Debian-based system, and report all of the packages from the non-free and contrib trees which are currently installed.

Just run this command and you can find out what software you have on your system that doesn't respect your freedom!

$ vrms

Here's the output on my Debian laptop:

                Non-free packages installed on x200

firmware-iwlwifi                    Binary firmware for Intel PRO/Wireless 3945 and 802.11
skype                               Wherever you are, wherever they are

                Contrib packages installed on x200

flashplugin-nonfree                 Adobe Flash Player - browser plugin

  2 non-free packages, 0.2% of 1164 installed packages.
  1 contrib packages, 0.1% of 1164 installed packages.

It's like having a little rms right on your command line!

To find out more about Richard Stallman and his political views, go to his personal page: stallman.org.

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.

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