Posts Tagged ‘linux’

Rhythmbox is silent: reset pulseaudio configuration

Rhythmbox is silent?

After playing around with different Linux Shells/UIs/window managers (including i3, Gnome Shell, etc) and some frequent restarts, I noticed that for some reason my music player Rhythmbox had stopped playing any sounds. Though it was still “playing” songs, no sounds were actually made by speakers, headphones, etc. In contrast, all other sounds were OK, including OS sounds like info/error messages, or other players like VLC. Changing sound setting, volumes, as well as changing audio devices did not have any effect on this.

Resetting pulseaudio configuration

Turns out that the pulseaudio configuration was messed up. The solution to this problem is to move/delete the old configuration, then let it be recreated (the original problem description and solution to this is here):

mv ~/.config/pulse/ ~/.config/pulse_old/ # move/delete the old config
pulseaudio -k # restart pulseaudio

After doing this and restarting Rhythmbox its sound should be back to normal, – though you might need to restart the OS if you run into problems with external speakers/headphones.

SSH Proxy: Server and Client Side of Using an SSH User Without Shell as Proxy Server

April 30, 2016 Leave a comment

Accessing services on an internal network over a proxy reachable from the Internet.

Imagine you want one of your machines to become a proxy for external users to be able to access local resources or the internet as if they were on that machine. You could run a dedicated proxy server for that, but if the machine provides SSH and you want an easy solution, you can use SSH as well – without risking any shell-related issues (like this user also having access to the local file system).

Why would you want stuff like that in the first place? That’s what proxy servers (and most frequently VPNs) are made for: to access country-, company-, or university-internal resources from outside of that network just as you would from the inside.

Server side

The server side is rather easy. Let’s assume we call that user “sshproxy”. The important thing is to not give your proxy user a shell, which we do here during creation of the user:

sudo useradd -m -d /home/sshproxy -s /bin/false sshproxy # create user and home directory, disable shell

The user’s password is disabled by default (you can check that there’s a ! in /etc/shadow for the sshproxy user). If you don’t want to use passwords but private-public keys (which I would recommend): in /home/sshproxy create the .ssh/ folder and the .ssh/authorized_keys file and ensure they’re readable for the sshproxy user. There you need to add the ssh public keys of people that should be allowed to use the ssh proxy. The cool thing about it is that different real life users can make use of the same sshproxy user: you just need to add to manage the keys of real life users for the sshproxy user. Further, you likely don’t want the sshproxy user to be able to change the authorized keys, therefore make the file read only for that user (e.g. root owned + writeable by owner only). If you have an AllowUsers section in your /etc/ssh/sshd_config, you need to add the sshproxy user there and restart ssh. That’s it on the server side.

User side

If you’re one of the users that need to generate their ssh keypair, you can have a look at:
(very easy to understand)
(details that are good to know if you want to have more secure keys = not so easy to crack)

If you use RSA then use at least 2048 bit key length (4096 can’t hurt…), e.g. with ssh-keygen with the “-b 4096” parameter. If you’re on a Windows machine: you can do the same using e.g. Putty. Don’t forget to use a good password to protect your private key file (usually the “id_rsa” file) and never disclose it – servers only need your public key (usually “”).

Using the proxy via Linux shell

Everything’s built in, just use the following command.

ssh -D 8080 -N sshproxy@YOUR-IP-OR-URL -p YOUR-PORT

This command opens the local port 8080 (on the client machine) for proxy tasks. YOUR-PORT-URL and YOUR-PORT correspond to the SSH server running on the server machine. If everything worked fine you won’t get any response in the shell – just leave the terminal open. Make sure your private key file is in ~/.ssh/id_rsa or provide it explicitly with “-i”. If you can’t access the server try removing the “-N”. Then you should see that the server logs you in and out immediately (this means everything works fine from the SSH, proxy and tunnel side – if you add -N again, you should be fine therefore). You can check your local opened ports with nmap (“nmap localhost”). If port 8080 is not in the list before login and opened after login your tunnel works.

Using the proxy via Putty

  • address: YOUR-IP-OR-URL (where SSH server is running)
  • port: YOUR-PORT (where SSH server is running)
  • user: sshproxy
  • Enable the check box “Don’t start a shell or command at all” in “Connection-SSH”
  • Specify your private key in “Auth”
  • Tunnels: add a “dynamic tunnel” on “local port 8080”, leave destination open (should state “D8080” in Putty after you apply)

Sending data to your local port

As you now have a tunnel on port 8080 on your local machine open, you need to send request to this port, instead of your standard gateway. E.g. for your browser you can achieve that configuring the browser to use a proxy (e.g. Firefox: FoxyProxy AddOn: set address “localhost” and port “8080”).

Btw: you can do other cool things with that proxy as well, such as reverse port tunnelling, circumventing firewalls etc. But you should ensure that this is allowed in the company/country you’re in before you get yourself into troubles.

Repair PDFLaTeX generated pdf using GhostScript (Adobe Acrobat Reader error 131)

February 28, 2016 Leave a comment

I tend to do presentations using LaTeX and Beamer, while working on Linux and using TeXLive as LaTeX distribution – which all work fine. But sometimes I need to share these PDFLaTeX compiled presentations with people using Windows and Adobe Acrobat Reader as their pdf viewer. The feedback I usually get back: your pdf is broken, error 131. And frankly, that seems to be true.

Opening PDFLaTeX generated pdf files with Windows Adobe Acrobat Reader results in error 131 – more precisely in the displayed error message “There was a problem reading this document (131)”. Other pdf viewers don’t complain about the pdf, just Adobe Acrobat Reader. A quick solution to repair the pdf file is by using GhostScript:

gs -dSAFER -dBATCH -dNOPAUSE  -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf</code></pre>

Voilà, the pdf file can be opened using Adobe Acrobat Reader – although, the source of the problem still exists of course (generating a pdf file not adhering the standard in the first place).

Git security: enabe fsckobjects in ~/.gitconfig:

February 3, 2016 Leave a comment

In order to prevent possible tampering with code in git repositories you work with (e.g. malicious manipulation of objects during clone, fetch, push…), check if these lines exist in your ~/.gitconfig and add them, if they don’t:

fsckobjects = true
fsckobjects = true
fsckObjects = true

These enable git checking transferred objects for their integrity using their computed hashes.

Original idea from here:!topic/binary-transparency/f-BI4o8HZW0
(and the corresponding bug on Debian here:

latexdiff-git: highlight changes between revisions of latex files managed in git

July 31, 2014 1 comment

latexdiff is a useful tool to determine changes between different versions of latex files and highlight them in a pdf (similar to MS word does with tracking changes). latexdiff-git is a wrapper around latexdiff optimized for git (and mercurial, but we’ll only look into git here). With it you can specify a latex document file (which is in a git repository) and a commit hash from that repository to look for changes between the file and its version from the specified commit. Same is possible with e.g. specifying two different commit hashes.

Installation (Linux)

  1. Clone latexdiff-git
    git clone
  2. All further steps are stated in the README file inside the repository you just cloned:
    1. Ensure you have a ~/.gitconfig file and that it’s accessible for your user.
    2. Add the following lines to .git/config
       cmd = latexdiff "$LOCAL" "$REMOTE"
       prompt = false
       ldiff = difftool -t latex
    3. Change the checked out script file search for revlatexdiffcmd='please define' and replace it with revlatexdiffcmd='git ldiff'
  3. Place somewhere in your path (I tend to place it in ~/bin) and make it executable: chmod +x


You can generate a tex file from differences between a latex file and a revision checked into git with (replace GITHASH and FILE with your git commit hash and latex file)

latexdiff-git -r GITHASH FILE

Alternatively you can generate the tex file from changes between two specific commits of a latex file:

latexdiff-git -r GITHASH1 -r GITHASH2 FILE

To view changes hightlighted in a pdf:

pdflatex *diff*tex # create pdf highlighting diff
evince *diff*pdf # replace evince with your preferred pdf-viewer
Categories: Misc Tags: , , , , , ,

Ubuntu Gnome 14.04: our usually applied configurations

May 11, 2014 1 comment

As we (darksider15 and myself) regularly set up PCs for private use with Ubuntu and Gnome Shell we’d like to share our usual considerations before doing the installation as well as our  list of usually applied configurations after the installation. For our example we use Ubuntu 14.04 and Gnome Shell 3.10. In order to not install Ubuntu’s default desktop Unity we use the Ubuntu GNOME flavour, but regular Ubuntu including Unity could be used as well (Gnome Shell can be installed from the repositories then). In case you are new to Gnome Shell we strongly recommend a short reading – as this will probably save you lots of time and make your life a lot easier: Gnome shell cheat sheet one and two (they are not always updated to the newest…). Some examples for usable – but not very intuitive features of Gnome Shell for people coming from other desktop environments:

  • The primary window menu of Gnome Shell Style Windows (in Ubuntu 14.04 e.g. Nautilus and gnome tweak tool) is hidden in the black area right next to the “Activities” button (top left) and gets shown on a click.
  • The message tray (lists messages from apps like skype, pidgin, thunderbird etc.) is accessible via the shortcut Super+M.
  • The suspend button is hidden in the top right user menu under the power button and becomes visible on pressing Alt.
  • You can restart Gnome Shell with executing “r” in the Alt+F2 box without closing your applications etc. Useful to developers as well as to “soft reset” stuff in case of window freezes or other bugs. This is btw. equivalent to calling gnome-shell --replace directly (in case you do that from a tty without X server you need to specify the display – which will usually be 0 as you will typically only have one X server running: gnome-shell --replace -d :0).

To consider for backup before installation

Depending on who’s PC you are installing the OS on (and if the installed OS already is Ubuntu or another Linux distribution installed) you might want to backup some things beside private documents, music, videos etc. Assuming that the old OS is Ubuntu with Gnome Shell, we usually check the following things for backup:

  • ~/.bashrc contains path variables, changes to bash behaviour etc.
  • ~/.bash_aliases contains aliases, other additions to bashrc
  • ~/.bash_profile “The personal initialization file, executed for login shells ” (see bash man page)
  • ~/bin/ may contain scripts and links to executables (as ~/bin is usually added to PATH).
  • ~/.gnupg/: contains PGP keys (used e.g. via Thunderbird enigmail).
  • ~/.mozilla/: contains Firefox configuration, history etc.
  • ~/.purple/: contains purple based messaging configuration (e.g. pidgin), including possibly used OTR keys.
  • ~/.ssh/ contains ssh private and public keys, authorized keys for ssh login and ssh fingerprints seen in the past.
  • ~/.thunderbird/ contains Thunderbird configuration and mails.
  • GTK bookmarks: contains GTK based bookmarks (used e.g. by Nautilus, Nemo, Thunar, PCManFM etc). For example on Ubuntu 12.04 gtk bookmarks are located at ~/.gtk-bookmarks, on Ubuntu 14.04 they are located at ~/.config/gtk-3.0/bookmarks.
  • /etc/fstab contains automatic mounted partitions and folders.

After installing Ubuntu 14.04 Gnome flavour: configuration


At first we usually install graphics drivers as they might cause problems (depending on the specific graphics). In our example we have a Nvidia GeForce 5400 (GF108 Fermi chip) in the Optimus graphics of a ThinkPad T430 notebook. For compatibility reasons the integrated graphics have been disabled completely in the BIOS, only the dedicated Nvidia graphics are used. To obtain drivers we include the ubuntu-x-swat PPA and install the current drivers from there:

sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current

After installing the driver you can check with

sudo lspci -k

if the driver is loaded (look for VGA in the list, check if the kernel driver in use is nvidia). To ensure that the current setup supports 3D hardware acceleration (essential for most 3D games) use

glxinfo | grep direct

Gnome shell extensions

We typically install some Gnome Shell Extensions, including the following ones:

  • AlternateTab: don’t group windows of same application in Alt+Tab.
  • Dash to Dock: easy way to set maximum dock icon size + disabling “require pressure to show dock” to achieve nearly-normal dock behaviour.
  • gTile: a window tiling utility – supports aligning windows to tiles spanning your screen (e.g. 2×2, 3×2, 4×4).
  • ignore_request_hide_titlebar: makes (some) Gnome Shell Style applications show their titlebar again (currently more of a bugfix than feature with the way we use Gnome Shell).
  • Native windows placement: more intuitive placing of windows in the activities window.
  • Notification Alerts: makes the user’s menu blink on new messages in the message tray.
  • Recent Items: adds list of recently used items to the top bar.
  • Removable Drives Menu: status icon for ejecting removable drives.
  • Search recently used files: integrated into the Gnome Shell Dash
  • TopIcons: although there exist more sophisticated versions this one shows Skype/Pidgin icon in top bar.
  • WindowOverlay Icons: shows application symbol above windows in the activities overview. With centred and enlarged icons (~150px) hepls pinpointing windows fast in our opinion.

Mount additional partition

In case there is such one (which was not stated for automatic mounting right during installing Ubuntu) you can add an corresponding entry to /etc/fstab. For compatibility reasons we are using /media/data as mount point here (nowadays Ubuntu would use /media/username/data instead). A typical entry for an ext3 partition would be

UUID=23f8a3fb-3f0d-4960-8c88-80e0db3cc471 /media/data     ext3    defaults        0       2

and for ntfs it would be

UUID=581F7F14085DF65D    /media/data    ntfs    defaults    0    0

You can either use the device in /dev or the UUID to specify the device to be mounted. Both can be found out using blkid:

sudo blkid

In case you have troubles with write access to the disk ensure that the folder it is mounted to (/media/data) exists and has write access for your user.

Window button layout: put buttons left

We usually change the button layout so that the buttons are arranged on the left side (like with MAC systems) – as this saves you mouse distance. For Gnome Shell the needed tool is dconf-editor:

sudo apt-get install dconf-editor

In dconf-editor changes have to be applied to org–>gnome–>shell–>overrides–>button-layout (there is also a button-layout in org–>gnome–>desktop–>wm–>preferences–>button-layout – that’s probably be the same entry visible multiple times in dconfg, but try changing this one if the first didn’t work for you). Our usual button layout is


System font and font size

In our opinion Ubuntu system font is rather big. It can be decrease in the fonts tab of gnome tweak tool:

sudo apt-get install gnome-tweak-tool

We usually reduce the default (11pt) to 10pt for all but monospace fonts. If you feel comfortable with the standard fonts at all: we usually change interface and documents font to “Ubuntu” (slightly easier to read in our opinion).

Cursor theme

We like to change the Gnome Shell default cursor theme (Adwaita, white border, black filling) to DMZ-White (black border, white filling). Therefore you first need the dmz cursor theme:

sudo apt-get install dmz-cursor-theme

Then the cursor theme can be changed in Appearance->Cursor of gnome-tweak-tool.

Window selection behaviour

If you’re used to mouse-over window selection (as I’m personally): this can be changed using gnome-tweak-tool again. Select “mouse over” or “sloppy” in Windows–>Focus Mode. (difference between mouseover and sloppy). I personally don’t like windows to be raised to the front automatically after the mouse pointer standing still for a certain time in it. This can be changed by deselecting “auto-raise” in org–>gnome–>desktop–>wm–>preferences. or by adapting “auto-raise-delay” next to it. And in case you want windows to immediately get focus as you hover the mouse over them deselect “focus-change-on-pointer-rest” in org–>gnome–>shell–>overrides.

Tooltip background color

The default tooltip background color is black – which is horrible for programs using dark fonts (like Eclipse). To change the tooltip background color install gnome-color-chooser and in Specific–>Tooltips change Foreground to black and Background to pale yellow as Nick Andrik suggested here.

Show all startup applications

Since Ubuntu 12.04 some startup applications are hidden, therefore not shown in gnome-session-properties. To show those applications use:

sudo sed -i "s/NoDisplay=true/NoDisplay=false/g" /etc/xdg/autostart/*.desktop

Custom shortcuts

Sadly, at the moment changing shortcuts via UI in gnome shell is split between multiple applications. Some applications show options to change settings that are not used at all. For window specific shortcuts use dconf-editor in org–>gnome–>desktop–>wm–>keybindings as you can manipulate most stuff there. Our typical shortcuts include:

  • toggle-maximized: [‘Up’]
  • Maximize vertically: [‘Page_Up’]
  • Minimize: [‘Down’]

User specific commands can be defined using “Shortcuts–>Custom Shortcuts” in the “Keyboard” app. We typically create a shortcut to open a file manager at the data partition, such as Ctrl+Alt+E for nemo /data/media or nautilus /data/media, depending on your file manager.

Multi monitors: get Ubuntu to remember their setup

Currently Ubuntu 14.04 seems to not remember multi monitor configurations for the reason of not loading ~/.config/monitors.xml (where the setup is stored correctly after configuring it). The update-monitor-position script provides a nice workaround to this problem by enforcing loading of monitors.xml as a custom startup application.

Restricted formats

By installing codecs for restricted formats we ensure to be able to play (most) formats straight away (although these formats suck for obvious reasons and should be avoided in favour of non-restricted ones).

Application configurations

File Browser

We’re not very convinced of Nautilus as file browser atm with the way we want to use Gnome Shell. The main problem is that it can’t be configured to the point anymore (e.g. bugs in the window button placement for gnome shell style windows). Another problem for power users may be the dropped tree view features in the main area (the right one, not the left tree or places view). We hope that’s coming back soon. Currently we use Nemo as file browser, but there are of course multiple options for people feeling like replacing Nautilus in Ubuntu 14.04, with us only listing some options:

  • Nemo: Nautilus fork, default for Linux mint (Cinnamon desktop), features a tree view.
  • Thunar: Nautilus fork, default for Xubuntu (Xfce desktop), no tree view either.
  • PCManFM: default for Lubuntu (Lxde desktop), no tree view either.
  • Dolphin: Kubuntu default (KDE desktop), different look and feel, but very powerful and customizable, features a tree view.


We usually adapt Bash behaviour to immediately log commands of all opened terminals.

Terminal emulation

Usually we also replace the default terminal emulation if it’s not very powerful (split screens, all hotkeys configurable etc.). Our current choice for Ubuntu is terminator, which features split screens and a detailed hotkey configuration – but of course there are many others out there with similar features.


Besides enabling the “do not track me” flags in browsers other measures might also help reducing the traceability. In Firefox–>Properties–>Privacy (actual names might differ slightly, but the meaning is clear):

  • Enable “Firefox will record custom history”: discard third party cookies when Firefox closes
  • Enable “Clear history on Firefox close”: check “empty cache”, “discard cookies” and “discard active logins”

Firefox addons

Some Firefox addons we find useful, therefore tend to install straight away as well:


If Yakuake is started along with the system we usually disable the notification popups – they might cause problems in case Yakuake displays them too soon.

Notifications from Pidgin, Skype etc.

We usually turn off notification popups on buddies going online or offline, as this causes additional notifications in the message tray (and the user’s menu to blink, caused by the corresponding gnome shell extension). With Pidgin, notifications can be configured in Tool–>Plugins–>Libnotify Popups. With Skype, notifications can be configured in Skype–>Options–>Notifications (look for “Contact Came Online/Offline”).


There seems to be an issue with the global media button “play/pause” in Ubuntu 14.04 with the command not being delivered correctly to applications. Specifically for Amarok (our music player of choice) the button works hardly anytime as long as the system (not Amarok itself) has it assigned to the system-wide play/pause shortcut. Therefore one solution is to unbind the “Play (or play/pause)” shortcut in Keyboard->Shortcuts->Sound and Media – Amark should receive the command correctly afterwards (ensure there is a correct binding in Amarok in Settings->Configure Shortcuts…->Play/Pause->Global)


We usually install Thunderbird lightning from the repositories and it’s addons directly via Thunderbird->Tools->Addons. Addons we find useful are:

Finally: root partition backup

Discussions about backups are omnipresent, so we won’t discuss the problem again here. In case there is no automatic backup having a “clean” – but properly configured system right after installation might be a good time to do a backup. That might save you lots of time in case users mess up the system. An option for quick backups is using fsarchiver from a live media (the installation media might come in handy). For a quick start with fsarchiver we’d recommend their quick start page. We assume that your installation was not split across multiple partitions in our example. The fsarchiver-command for backing up a partition on /dev/sda1 to /media/data/backups/datetime.fsa using 2 cores (-j2), splitting archives to multiple files of 4000MB (-s4000), standard compression (-z3) and verbose output (-v) from a live media would be:

sudo fsarchiver savefs -j2 -s4000 -z3 -v /media/data/backups/datetime.fsa /dev/sda1

The fsarchiver-command for restoring partition /dev/sda1 from /media/data/backups/datetime.fsa from a live media would be:

sudo fsarchiver restfs -j2 -v /media/data/backups/datetime.fsa id=0,dest=/dev/sda1

Batch sort jpg images to folders named after dates images were taken

May 11, 2014 1 comment

Once in a while I need to transfer pictures taken with my mobile phone for private use (jpg format) from my phone to my PC – and to sort them there. I want my pictures sorted in folder named by the date taken (e.g. “2014_05_11_description”) – which is pretty time consuming if done by hand. The script snippet below takes all jpg files in the current folder, creates subfolders named by the dates pictures have been taken and sorts the files in there accordingly. In case you don’t want to add a description to the folders afterwards you might want to remove the last “_” in foldername.

for f in `ls *jpg`
        foldername=`exif -t 0x9003 -m $f | sed s/:/_/g | awk '{print $1}'`_
        if ! test -e "$foldername"; then
                mkdir -pv "$foldername"
        mv -v $f $foldername

Insights to extracting date from jpg files in short:

  • exif is used to extract the date and time the image was taken,
  • sed replaces “:” with “_” and
  • awk removes the time information as I only want date.

Credits: according to my notes I originally built my script upon this script.