ubuntu – Grey Panthers Savannah https://grey-panther.net Just another WordPress site Sun, 08 May 2022 11:39:13 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.1 206299117 Capturing your screen on Ubuntu – with sound https://grey-panther.net/2013/08/capturing-your-screen-on-ubuntu-with-sound.html https://grey-panther.net/2013/08/capturing-your-screen-on-ubuntu-with-sound.html#respond Wed, 14 Aug 2013 06:50:00 +0000 Today I have a short script which I cobbled together from Google searches to do screen captures / screen casts with Ubuntu (including audio in so that you can narrate what is going on):

#!/bin/bash
Xaxis=$(xrandr -q | grep '*' | uniq | awk '{print $1}' |  cut -d 'x' -f1)
Yaxis=$(xrandr -q | grep '*' | uniq | awk '{print $1}' |  cut -d 'x' -f2)
avconv -f alsa -i pulse -f x11grab -s $(($Xaxis))x$(($Yaxis)) -i $DISPLAY.0 -r 15 -c:v libx264 -crf 0 -c:a libvo_aacenc -b:a 256k -threads 8 ~/Videos/output.mp4

I found this to work much better than gtk-recordmydesktop, which had lags, especially when “effects” were being drawn on the screen (like bulletpoints sliding in for a presentation or switching between desktops).

]]>
https://grey-panther.net/2013/08/capturing-your-screen-on-ubuntu-with-sound.html/feed 0 12
Upgrading from MySQL to MariaDB on Ubuntu https://grey-panther.net/2012/11/upgrading-from-mysql-to-mariadb-on-ubuntu.html https://grey-panther.net/2012/11/upgrading-from-mysql-to-mariadb-on-ubuntu.html#respond Sun, 25 Nov 2012 09:14:00 +0000 So you decided that Oracle doesn’t know its left foot from the back of his neck when it comes to open source (how’s that for a mixed metaphor), but you are not ready just yet to migrate over to PostgreSQL? Consider MariaDB. Coming from Monty Widenius, the original author of MySQL, it aims to be 100% MySQL compatible while also being truly open-source.

Give that it’s 100% MySQL compatible, you can update in-place (nevertheless it is recommended that do a backup of your data first). The steps are roughly adapted from here.

  1. Go to the MariaDB repository configuration tool and generate your .list file (wondering what’s up with the 5.5 vs 10.0 version? See this short explanation). You don’t know the exact Ubuntu version you’re running? Just use lsb_release -a.
  2. Save the generated file under /etc/apt/sources.list.d/MariaDB.list as recommended and do an sudo aptitude update. You should see an output complaining about some public keys.
  3. Do sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xCBCB082A1BB943DB to add those keys (replace the last number with the one you saw in the previous output).
  4. Issue sudo apt-cache policy mysql-common and you should see mariadb as an upgrade option.
  5. Finally do sudo aptitude upgrade mysql-common libmysqlclient18 and watch your MySQL database being transformed into a MariaDB one and all keeping chugging along just as usual!
]]>
https://grey-panther.net/2012/11/upgrading-from-mysql-to-mariadb-on-ubuntu.html/feed 0 25
Using less with syntax highlight https://grey-panther.net/2011/09/using-less-with-syntax-highlight.html https://grey-panther.net/2011/09/using-less-with-syntax-highlight.html#respond Tue, 13 Sep 2011 16:14:00 +0000 https://grey-panther.net/?p=53 You can use vim as your pager and obtain two benefits: syntax highlight and access to all the advanced commands (like search). You can do this under ubuntu by adding the following line to your ~/.bashrc:

alias less='/usr/share/vim/vimcurrent/macros/less.sh'

Note:

  • You have to have vim installed (which doesn’t come by default, but it is as simple as sudo apt-get install vim-nox)
  • It supports viewing directly bz2 and gz archives as well as pipe input from stdin (but in that case it fails sometime to highlight)
  • Edit commands (like dd) are disabled, so you can’t accidentally modify the file you are viewing
]]>
https://grey-panther.net/2011/09/using-less-with-syntax-highlight.html/feed 0 53
Setting up git-daemon under Ubuntu https://grey-panther.net/2011/06/setting-up-git-daemon-under-ubuntu.html https://grey-panther.net/2011/06/setting-up-git-daemon-under-ubuntu.html#respond Wed, 01 Jun 2011 17:19:00 +0000 https://grey-panther.net/?p=61 The scenario is the following: inside a (somewhat) trusted LAN you would like to set up git-daemon so that your coworkers can access your repositories. This solution is not appropriate in cases where you want to share with random people on the interwebs. This short description is based loosely on this blogpost and it was updated to contain more details and tested with Ubuntu 11.04.

  • install the git-daemon-runit package: sudo apt-get install git-daemon-runit
  • decide where you would like to keep your git repositories – it can be your home folder, if it’s not encrypted (if it’s encrypted it won’t work because it only gets decrypted once you log in, so the git repositories won’t be available unless you log in). Lets say that you’ve decided it to be /var/git. Create it:
    sudo mkdir /var/git
    sudo chown $USER /var/git
  • Now edit the file /etc/sv/git-daemon/run and make it like the following (bold marks the spots which were changed):
    #!/bin/sh
    exec 2>&1
    echo 'git-daemon starting.'
    exec chpst -ugitdaemon
      "$(git --exec-path)"/git-daemon --verbose --export-all --base-path=/var/git /var/git
  • Restart the service:
    sudo sv restart git-daemon
  • Enable it from the firewall:
    sudo ufw allow 9418/tcp

That’s it. Now every subdirectory from /var/git which "looks like" a git repo (has a .git subdirectory) will be available over the git protocol. Alternatively, you can remove the "–export-all" option and create a "git-daemon-export-ok" file in each subdirectory you would like to export: touch /var/git/core/git-daemon-export-ok

You can symlink the directory to your home folder for your convenience:
ln -s /var/git ~/projects/git

]]>
https://grey-panther.net/2011/06/setting-up-git-daemon-under-ubuntu.html/feed 0 61
Adding tab completition to Maven3 under Ubuntu https://grey-panther.net/2011/06/adding-tab-completition-to-maven3-under-ubuntu.html https://grey-panther.net/2011/06/adding-tab-completition-to-maven3-under-ubuntu.html#respond Wed, 01 Jun 2011 17:10:00 +0000 https://grey-panther.net/?p=62

Maven 3 was released recently (depending on your definition of recent), but is not yet packaged for Ubuntu. This is generally not a problem, since the installation instructions are easy to follow (alternatively here are the installation instructions from the Sonatype maven book), but you don’t get tab completion in your terminal, which is quite a bummer, since I don’t know how to write correctly without a spellchecker.

Fortunately the steps to add it are simple:

  • Download an older Maven2 package
  • Extract from it the /etc/bash_completion.d/maven2 file (take care not to install the package by mistake)
  • Put the extracted file into /etc/bash_completion.d/maven3
  • Restart your terminal

These steps should also work with other Linux distributions if they have bash-completion installed.

This is a cross-post from the Transylvania-JUG blog.

]]>
https://grey-panther.net/2011/06/adding-tab-completition-to-maven3-under-ubuntu.html/feed 0 62
Recovering encrypted home directory under Ubuntu https://grey-panther.net/2011/04/recovering-encrypted-home-directory-under-ubuntu.html https://grey-panther.net/2011/04/recovering-encrypted-home-directory-under-ubuntu.html#comments Sun, 10 Apr 2011 19:24:00 +0000 https://grey-panther.net/?p=67 While the home-folder encryption in Ubuntu is far from a perfect solution (there is considerable data leakage from the swap file and the temp directory – for example once I’ve observed the flash videos from Chromium porn private browsing mode being present in the /tmp directory), it is a partial solution nevertheless and very easy to set up during installation. However what can you do if you need to recover the data because you fubard your system?

Credit where credit is due: this guide is taken mostly from the Ubuntu wiki page. Also, this is not an easy “one-click” process. You should proceed carefully, especially if you don’t have much experience with the command line.

  1. Start Ubuntu (from a separate install, from the LiveCD, etc) and mount the source filesystem (this is usually as simple as going to the Places menu and selecting the partition)
  2. Start a terminal (Alt+F2 -> gnome-terminal) and navigate to the partitions home directory. Usually this will look like the following:
    cd /media/9e6325c9-1140-44b7-9d8e-614599b27e05/home/
  3. Now navigate to the users ecryptfs directory (things to note: it is ecryptfs not encryptfs and your username does not coincide with your full name – the one you click on when you log in)
    cd .ecryptfs/username
  4. The next step is to recovery your “mount password” which is different from the password you use to log in (when it asks you, type in the login password used for this account – for which you are trying to recover the data). Take note of the returned password (you can copy it by selecting it and pressing Shift+Ctrl+C if you are using the Gnome Terminal)
    ecryptfs-unwrap-passphrase .ecryptfs/wrapped-passphrase
  5. Now create a directory where you would like to mount the decrypted home directory:
    sudo mkdir /media/decrypted
  6. Execute the following and type in (or better – copy-paste) the mount password you’ve recovered earlier
    sudo ecryptfs-add-passphrase --fnek

    It will return something like the following. Take note of the second key (auth tok):

    Inserted auth tok with sig [9986ad986f986af7] into the user session keyring 
    Inserted auth tok with sig [76a9f69af69a86fa] into the user session keyring
  7. Now you are ready to mount the directry:
    
    sudo mount -t ecryptfs /media/9e6325c9-1140-44b7-9d8e-614599b27e05/home/.ecryptfs/username/.Private /media/decrypted
     Passphrase:  # mount passphrase
     Selection: aes
     Selection: 16
     Enable plaintext passthrough: n 
     Enable filename encryption: y # this is not the default!
     Filename Encryption Key (FNEK) Signature: # the second key (auth tok) noted
    

    You will probably get a warning about this key not being seen before (you can type yes) and asking if it should be added to your key cache (you should type no, since you won’t be using it again probably).

That’s it, now (assuming everything went right) you can access your decrypted folder in /media/decrypted. The biggest gotcha is that home/username/.Private is in fact a symlink, which – if you have an other partition mounted – will point you to the wrong directory, so you should use the home/.ecryptfs/username directory directly.

HTH

]]>
https://grey-panther.net/2011/04/recovering-encrypted-home-directory-under-ubuntu.html/feed 1 67
Setting the maximum number of opened files under Ubuntu (for JProfiler) https://grey-panther.net/2011/03/setting-the-maximum-number-of-opened-files-under-ubuntu-for-jprofiler.html https://grey-panther.net/2011/03/setting-the-maximum-number-of-opened-files-under-ubuntu-for-jprofiler.html#respond Sun, 20 Mar 2011 12:29:00 +0000 https://grey-panther.net/?p=71 As I found out “on my own skin”, setting fs.file-max in /etc/sysctl.conf is a BAD idea. It can render your system useless in one step. Please don’t do it! If you did it, use the recovery mode to roll back the change. Also, currently I would only recommend doubling the limit (ie going from 1024 to 2048 or from 2048 to 4096) not going to the maximum value.

JProfiler is a great tool, however under 32 bit Ubuntu you can run into the problem of having a too low limit for open filehandles. This is a problem for JProfiler because it uses temporary files to work around the address-space limitation created by 32 bit (yeah, I know, I should upgrade to 64 bit – but 32 bit works great for now…)

To raise the maximum filehandle limit, do the following:


sudo gedit /etc/security/limits.conf
# add the following two lines before the # End of file marker
# yes, the initial star is also part of line, and you should add it
*       hard    nofile  4096
*       soft    nofile  4096
sudo gedit /etc/sysctl.conf
# restart your system

You can check if the changes were successful by using the ulimit command:


ulimit -n
# it should print out 4096

]]>
https://grey-panther.net/2011/03/setting-the-maximum-number-of-opened-files-under-ubuntu-for-jprofiler.html/feed 0 71
Processing clipboard data in Perl https://grey-panther.net/2011/01/processing-clipboard-data-in-perl.html https://grey-panther.net/2011/01/processing-clipboard-data-in-perl.html#respond Mon, 03 Jan 2011 15:03:00 +0000 https://grey-panther.net/?p=92 The problem: lets say you have a program which generates data to the clipboard (or it is easier to get the data into the clipboard than into a file) and you want to process the data (create a summary for example).

Perl to the rescue!

Get the Clipboard module (if you use Linux, it is as easy as sudo cpan -i Clipboard; sudo apt-get install xclip but the package is also available as an ActivePerl package for example).

Write a script like the following:

use strict;
use warnings;
use Clipboard;

my $clippy = Clipboard->paste();
my ($sum, $cnt) = (0, 0);
while ($clippy =~ /Processed in: (d+)/g) {
        $sum += $1;
        $cnt += 1;
}

print $sum/$cnt, "n";

Profit!!! 🙂

Update: you can combine this with syntax highlight for example to obtain nicely formatted source code.

Update: copying stuff to the clipboard doesn’t seem to work under Linux (tested under Ubuntu 10.10) because it invokes xclip with the “primary” clipboard but it only seems to work with the “clipboard” clipboard. Unfortunately I didn’t find any good material about the distinction between these different clipboard types, but the “monkey patch” below fixes the problem for me (of course I also filed a bug with the package so this should be resolved in a future version).


use strict;
use warnings;
use Clipboard;

if ('Clipboard::Xclip' eq $Clipboard::driver) {
  no warnings 'redefine';
  *Clipboard::Xclip::all_selections = sub {  
    qw(clipboard primary buffer secondary)
  };
}

# ... your code here ...
Clipboard->copy('foofooo1');
]]>
https://grey-panther.net/2011/01/processing-clipboard-data-in-perl.html/feed 0 92
Why Ubuntu 10.10 is better than Windows XP? https://grey-panther.net/2011/01/why-ubuntu-10-10-is-better-than-windows-xp.html https://grey-panther.net/2011/01/why-ubuntu-10-10-is-better-than-windows-xp.html#comments Mon, 03 Jan 2011 14:37:00 +0000 https://grey-panther.net/?p=93 I want to preface this with the following: I don’t want to pull a fanboy move here. The only thing I assert is that a recent OS (ie. Ubuntu 10.10) can give a considerable performance improvement (without changing the hardware) compared to an almost 10 year old OS (Windows XP).

Without further ado, compiling a large(ish) Java project on Windows XP:

real    3m16.776s
user    0m2.333s
sys     0m0.796s

And Ubuntu 10.10:

real    1m32.169s
user    2m10.488s
sys     0m12.677s

More than twice as fast! Neat!

Update: a friend just got a newer machine with better processor (Core i5 vs Core Duo) with Windows 7. The new machine with Windows 7 compiles the project in ~1m50s, so still Ubuntu seems to be the better choice.

]]>
https://grey-panther.net/2011/01/why-ubuntu-10-10-is-better-than-windows-xp.html/feed 1 93
An useful Ubuntu (online) resource https://grey-panther.net/2010/01/an-useful-ubuntu-online-resource.html https://grey-panther.net/2010/01/an-useful-ubuntu-online-resource.html#comments Mon, 11 Jan 2010 20:28:00 +0000 https://grey-panther.net/?p=141

If you use Ubuntu, the full circle magazine is a great resource, go check it out. For example from the latest issue I’ve learned that I should install vim-nox on my servers if I want to upgrade my 1980’s experience to 1990’s :-).

I there is one (small) issue, it is the fact that the PDF is very CPU intensive (I’m not really sure about the cause), but it is very good looking and professionally done. Go look at it if you use Ubuntu. And consider donating or writing an article or two 🙂

]]>
https://grey-panther.net/2010/01/an-useful-ubuntu-online-resource.html/feed 1 141