Archive for the 'Linux' category

Powerline, git, Fedora

 | February 12, 2016 2:31 pm

I recently discovered powerline, thanks to a Fedora news article. Getting powerline running on your Bash terminal is completely trivial and discussed in the article. You just:

Install powerline.

  sudo dnf install powerline

Configure your shell to use the powerline daemon.

bash

Add this to your .bashrc

  if [ -f `which powerline-daemon` ]; then
     powerline-daemon -q
     POWERLINE_BASH_CONTINUATION=1
     POWERLINE_BASH_SELECT=1
     . /usr/share/powerline/bash/powerline.sh
  fi

fish

add this to ~/.config/fish/config.fish:

set fish_function_path $fish_function_path "/usr/share/powerline/fish"
powerline-setup

Configure powerline to display git information

If all you want to do is get the git branch displayed on your powerline, that’s pretty easy, see for example this excellent article. But after I discovered powerline-gitstatus, I just had to have it.

Install the powerline-gitstatus segment:

pip install powerline-gitstatus

Setup a configuration

I’ve put my powerline configuration up on github, so if you like, you can start with my configuration, and play with it from there simply by clone my powerline-configuration repository into your local .config directory. I.e.:

cd ~/.config
git clone https://github.com/spacemoose/powerline_cofiguration.git powerline

Otherwise you can copy over the default configuration and follow the directions here.

Try out your new configuration

Since this article is focused on customizing our shell prompt, we are dealing with the powerline daemon, which means we must run

powerline-daemon --replace

when we want to see what effect our changes might have – BUT before you do that, I highly recommend running powerline-lint in case you forgot a comma somewhere.

Share on Facebook

Running Skype on 64 bit linux

 | October 2, 2009 1:25 am

The skype client for linux is 32 bit. So to run it on a 64 bit Linux installation you have to install 32 bit libraries. In a quick aside, I gotta say: Skype devs, 64 bit tech has been around for years… what the hell is taking you gyum search , the following will get you there:

yum -y install libXScrnSaver.i586 libXss qt.i586 qt-x11.i586
Share on Facebook

Fedora 11 Post Install Configuration

 | June 15, 2009 12:23 am

Fedora 11 is out, so it’s time to update my notes on configuring my fedora install. In the examples I will use a default Fedora install (with development tools selected), on my 64 bit Sony vgn-s2750N laptop, which I will henceforth refer to as Sunny.

Here’s what I have to do to get Fedora 11 running like I want it:

  1. Fix the DNS lookup bug. On all the machines I administer, this manifests itself as massive dns lookup failures, with the effect that although you can ping an address, you don’t have any internet access (no web browser, no yum…).  This answers the question:  I have an internet connection, but I can’t use the web, WTF?
  2. Access to fusion
  3. Add MP3 support/get Amarok working.
  4. Get Flash working (people need their youtube).
  5. Graphics acceleration
  6. Make FAT partitions writeable by users, and add ntfs support.
  7. Disable physical file folders.
  8. Enable Ctl-Alt-Backspace

1. Fix the DNS bug
Apparently there is a known bug, which mucks up the domain name lookup with certain ISP’s, of which bluewin (my ISP) is one. In the bug description the complaint is that you get unreliable name lookups, but in the case of bluewin (my isp), you get no successful lookups.  A workaround is:

  1. Find out the network interfaces the machine has using the command “route -n”.
  2. Create a file:  /etc/dhclient-< your network interface name here >.conf consisting of the line
    prepend domain-name-servers 127.0.0.1;
  3. Start dnsmasq (‘service dnsmasq start’).
  4. tell dnsmasq to start every time the computer does (‘chkconfig dnsmasq on’)
  5. restart the network connection (‘service NetworkManager restart’)

So on Sunny the Sony I want to get my wireless LAN working right on Bluewin. Running ‘route -n’ tells me my network interface is ‘wlan0’ (which I could have guessed). So I do the following (as root of course):

echo 'prepend domain-name-servers 127.0.0.1;' >  /etc/dhclient-wlan0.conf
service dnsmasq start
chkconfig dnsmasq on
service NetworkManager restart

And presto, my internets work again. I don’t put it on this list, but at this point I run a ‘yum -y update’ to get the base install up to date.

2. Access to fusion:
Fusion is a merge of the largest existing addon repos, and means to be the extra repo for fedora, including (separate) free and non-free packages that Fedora is not able to ship of license or export regulations (see comment by ingvar).  Apparently it is now possible to add fusion support through a GUI, but I find it much more efficient to just do:

rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

This is a good time to do another yum update. You’ll have to accept a couple of no-key warnings.

3. mp3 support.
I still use Amarok, which I am still unsure about recommending. I found Amarok 1 vastly superior to the alternatives however, so I’m hoping Amarok 2 eventually becomes awesome. In addition to Amarok, I want lame for when I rip my CD’s for my car mp3 player, mp3 support for Totem, etc. So I do the following:

yum -y install amarok lame* gstreamer-plugins-ugly xine-lib-extras-freeworld

And things seem to be running all right.

4. Get Flash (i.e. Youtube) working This solution comes from here

rpm -ivh http://linuxdownload.adobe.com/adobe-release/adobe-release-i386-1.0-1.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-adobe-linux
yum install nspluginwrapper.{i586,x86_64} alsa-plugins-pulseaudio.i586
yum -y install flash-plugin

Note that the third line is only required for 64 bit Fedora.

5. Enable your 3d hardware acceleration. In my case, I just run ‘yum install kmod-nvidia’ and restart X. If you have a radeon card, I suppose the solution is the obvious one.

6. Make the fat drive writeable, and add NTFS write support, so people can easily work with Windows.
For any fat partition, change the umask in fstab to 000. For NTFS support:

yum -y install ntfs-config.noarch

7. Disable “physical” file folders. This is the annoying behavior, default in gnome, that opens a new window for every folder that you open. Get rid of it by double clicking on a folder, and in the resulting window open edit->preferences->Behavior, and check the box for “Always open in browser windows”. There is a scriptable way to do this, so if someone wants to tell me, please do.

8. Enable ctl-alt-backspace.It always frustrates me when a distro moves away from supporting the power use to supporting the neophyte. I think there are plenty of neophyte oriented OS’s and distros around. I use Fedora instead of Ubuntu because Ubuntu aims too much at the dumb asses, and Fedora tends to support the people who want to learn and be efficient. Unfortunately the Fedora guys do make dumb-ass-friendly decisions, such as the decision to disable ctl-alt-backspace, which I find to be a very poor decision. Who hits this key sequence by accident? Anyway, to enable it in Fed 11 do System->Preferences->Keyboard, choose keyboard layout options and enable the checkbox for “key sequence to kill the x server”.

Share on Facebook

Exporting emacs org-mode html, ain’t sed grand.

 | June 7, 2009 2:45 am

I’ve recently begun using emacs org-mode, and I quite like it.  I do a lot of my writing, some of which might finally end up here on my blog, in org-mode these days.  For a lot of my applications it’s a perfect overlay on plain text documents.  I can export what I’ve written as html or latex, which is fantastic.

What’s less fantastic, is when I want to cut and paste the html output here to my WordPress blog.  Unfortunately org-mode puts in linefeeds between paragraph elements, and for some reason wordpress maintains these, resulting in incorrect word wrapping.  So I want a way to remove the the linefeeds between paragraph elements.

This was just a little bit beyond my capabilities with SED, and I’m often telling myself self, you should really learn how to use sed and regex terms better . So I thought bugger it, let’s figure out how to do this. So I whipped out the excellent book “sed&awk” from O’Reilly.

As someone who has only used sed for banal substitutions, I had to learn the following:

  • “:whatever” can be used to create a label.  There are two commands that allow you to utilize these lables: “b” creates a branch, while “t” jumps to a label if a successful substitution has been made on the currently addressed line.
  • “N” is needed to join two lines, since sed normally works on a one-line-at-a-time fashion.

With these two tidbits, and a basic understanding of how sed operates, we can construct the desired script.

:top
/

/ {:loop N s/\n/ / /<\/p>/{P;D;btop} bloop}

In one line the command looks like this:

 sed ':top;/<p>/{:loop;N;s/\n/ /;/<\/p>/{P;D;btop};bloop}'

If you’re like me, it’s not immediately clear what’s going on here, so let’s break it down:

  • First we create a label with “:top”.
  • “/<p>/” tells sed to look for the paragraph block tag.  The next ‘line’ of the script will be called after this tag is found.
  • The curly braces “{}” group a set of commands, so upon encountering the paragraph tag, it executes the contents of these brackets.   In the brackets:
    • Create a new label “:loop”.
    • “N” creates a multiline pattern space by reading the next line of input, and appending it to the contents of the pattern space.
    • “s/\n/ /”: substitute a space for the line feed.
    • “/<\/p>/{P;D;btop}”:  If sed encounters an end of paragraph tag, it executes “P;D;btop”, which (P) prints the contents of the multiline pattern space, (D) deletes it, and (btop) creates a branch(b) and goes to the label(top).   It’s a little like “if (<p>) goto top”.
    • “bloop” (b) branch and goto label(loop).

So as long as no closing tag (</p>) is found, we have a loop that keeps adding new lines to the multiline pattern buffer, and substituting spaces for linefeeds.  When the closing tag (</p>) is found, the loop goes back up to the “top” label.  That loop makes sure all of the  paragraph sections get handled.

So that’s it.  If anyone knows a more elegant solution to this, I’d be glad to here about it.

    Share on Facebook

    My .emacs file

     | May 19, 2009 4:36 am

    Since I often need a copy of my emacs file somewhere where it’s not worth pulling my whole sysadmin git repository, I’m a gonna put my .emacs file here.  Maybe someone else will find it useful.  It basically does the following:

    • makes my background color a little less harsh.
    • enables syntax highlighting by default.
    • makes the selected region highlighted (this behavior will be default in the next version of emacs, but I’m using 22.x at the moment).
    • modify the tab width to 3.
    • enable org mode
    • make line numbering available (this is sometimes useful).

    I’ll be keeping this up to date as my make changes…

    ;;-------------------------------------
    ;; Some preferences:
    (set-background-color "antique white")
    ;; I want syntax highlighting by default.
    (global-font-lock-mode 1)
    ;; I want to see the selected region (this will be default in v23).
    (transient-mark-mode 1)
    ;; I like small indents.
    (setq standard-indent 3);
    (setq default-tab-width 3);
    ;; I don't want to see the splash screen.
    (setq inhibit-startup-message t);
    
    ;;-----------------------------------------------
    ;; org mode setup
    ;;------------------------------------------------
    (add-to-list 'auto-mode-alist '("\\.org\\'" . org-mode))
    
    ;;(global-set-key "\C-o" ctl-x-map)
    (global-set-key [?\C-c ?l] 'org-store-link)
    (global-set-key "\C-ca" 'org-agenda)
    (global-set-key "\C-cb" 'org-iswitchb)
    
    ;;---------------------------------------------------
    ;; For special packages:
    ;;---------------------------------------------------
    ;; Add local lisp folder to load-path
    ;;(setq load-path (append load-path (list "~/.emacs.d/elisp")))
    ;; sometimes line numbering is useful.
    (require 'linum)
    Share on Facebook

    Granting acces using rsa-key pairs.

     | May 18, 2009 8:32 am

    This is another thing I have to do rarely enough that I forget the commands, but often enough it’s worth keeping a note of it. I use git, ssh, scp, etc. all the damn time between various computers, and it’s stupid to keep entering passwords every time. You can get around this using ssh-agent.  The process is pretty short:

    1. Generate a public key.  Logon to the host want to connect from:
       #ssh-keygen -t dsa

      This generates a key pair (of type dsa), both of which are located in the .ssh directory.  The files will be id_dsa and id_dsa.pub.  The latter file is the public key, and the former the private key.  By copying the public key to the .ssh/, we provide ssh with an alternate means of confirming our access rights.  Rather than prompt for a password, it checks that the private key (client side) matches that of the server (public key).

    2. Append the generated key to the servers .ssh/authorized_keys file.  The simplest way is:
      ssh-copy-id -i ~/.ssh/id_dsa user_name@remote_host.org

    That’s it.  Now you should be able to scp, ssh, or git (via ssh) to that machine without entering a password. You may have to enter the private key (the passphrase you provided when generating your key pairs) the first time you use ssh from the pc (this is the default behaviour on Fedora).
    If you run into problems, this is discussed in more detail here.

    Share on Facebook

    64-bit Fedora 10 Post-installation setup

     | January 14, 2009 12:44 pm

    I manage 5 Fedora installations: my work and home PC’s, my laptop, my fiancee’s laptop,  and my buddy Charles’ PC, who is generously giving Linux a shot.  I told him he’d probably have an easier time with Ubuntu, but that I would have an easier time helping with Fedora, as that’s what I know.  Often I update these machines at widely different intervals, particular with Charles’ PC, since I don’t see him that often.

    Fedora is great in many ways, and I stick with it because I’m pretty happy with it, philosophically and technically, but you often have to put a little work on it, particularly if you’re a 64-bit user and you to use a good graphics card.  Anyway, I thought it would be handy for me to have a checklist on the web, so I don’t forget anything the next time.  This is just a collection of solutions I’ve dug up somewhere else, but it might still be useful for others.

    These are the things I have to do to get Fedora working acceptably:

    1. Fix the DNS lookup bug.  On all the machines I administer, this causes massive dns lookup failuers, with the effect that although you can ping an address, you don’t have any internet access (no web browser, no yum…).Add access to the fusion repository.Install various extra software.
    2. Access to fusion
    3. Add MP3 support/get Amarok working.
    4. Get Flash working (people need their youtube).
    5. Nvidia support.
    6. Make FAT partitions writeable by users, and add ntfs support.
    7. Disable physical file folders.
    8. Enable automounting of external drives (usb sticks for example).

    1. Fix the DNS bug

    Apparently there is a known bug, which mucks up the domain name lookup with certain ISP’s, of which bluewin (my ISP) is one.   In the bug description the complaint is that you get unreliable name lookups, but in the case of bluewin, you get no successful lookups.  A workaround is described here.  All you have to do is:

    1. Make sure that dnsmasq is installed.
    2. find out the network interfaces the machine has ( route -n )
    3. create a file called /etc/dhclient/< your network intervace name here >.conf consisting of the line
    4. ‘ prepend domain-name-servers 127.0.0.1; ‘
    5. Start dnsmasq (‘service dnsmasq start’).
    6. tell dnsmasq to start every time the computer does (‘chkconfig dnsmasq on’)
    7. restart the network connection (‘service NetworkManager restart’)
    8. Add ntfs write support.

    2. Access to fusion:

    Fusion is  a merge of the largest existing addon repos, and means to be the extra repo for fedora, including (separate) free and non-free packages that Fedora is not able to ship of license or export regulations (see comment by ingvar).

    # rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

    3. Add mp3 support

    I use Amarok as my primary music application.  Fedora comes with Amarok 2, which I am still evaluating, but I found Amarok 1 vastly superior to the alternatives, so I’m hoping Amarok continues to be awesome.  I actually hate switching apps.  Unfortunately, just installing Amarok gives me no sound.  After running Amarok in a console and checking out the output, I tried:

    # yum groupinstall phonon*

    which did the trick.  I  Finally, to support mp3’s, you can do:

    # yum groupinstall sound-and-video

    4. Get Flash (i.e. Youtube) working

    This solution  comes from here.   I quote verbatim:

    • rpm -e nspluginwrapper.i386 flash-plugin (if you have installed them)
    • cd /usr/lib64/mozilla/plugins/ (this is where your Firefox plugins are)
    • wget http://download.macromedia.com/pub/labs/flashplayer10/libflashplayer-10.0.d20.7.linux-x86_64.so.tar.gz (to download the Flash plugin)
    • tar -xvzf libflashplayer-10.0.d20.7.linux-x86_64.so.tar.gz (to extract the plugin)
    • restart firefox.

    At this point you tube shows up fine.

    5.  Enable your 3d hardware acceleration

    In my case, I just run ‘yum install kmod-nvidia’ and restart X.  If you have a radeon card, I suppose the solution is the obvious one.

    6.  Make the fat drive writeable, and add NTFS write support, so people can easily work with Windows.

    For any fat partition, change the umask in fstab to 000.  For NTFS support, ‘yum install ntfs-config.noarch’.

    7. Disable “physical” file folders.

    This is the annoying behavior, default in gnome, that opens a new window for every folder that you open.  Get rid of it by double clicking on a folder, and in the resulting window open edit->preferences->Behavior, and check the box for  “Always open in browser windows”.  There is a scriptable way to do this, so if someone wants to tell me, please do.

    8.  Allow automounting of usb drives etc.

    I really hope this is an error, but it’s possible it’s a security precaution.  By default, if you plug in a usb stick or some such storage device, you won’t see it automatically on your desktop.  This is because automounting isn’t allowed by default.  You can change this by going to System->Preferences->Authorizations and click on hal->storage->Mount file systems from removable drives.  Click on the Edit box in the Implicit Authorizations sections, and change Anyone to yes.

    9.  Scripts:

    I have a script which installs a lot of the stuff I typically want but is not included in Fedora by default.  These include mplayer, par2, rar,  amarok(music listening), emacs, development tools, etc.  If you want it, the script is here.

    Share on Facebook