Archive for the ‘unix’ Category

See everything and the kitchen sink about your harddrive

November 3, 2011 Leave a comment

Ever wondered what specifications your harddisk/SSD actually has? hdparm is your best friend here. I wondered whether my Corsair SSD actually had TRIM supported/enabled, and this is what sudo hdparm -I /dev/sda (of course, replace /dev/sda with w/e your desired device node is) got me:
Read more…

Ubuntu / PERL locale errors/warnings

October 31, 2011 Leave a comment

You get this?

perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LC_ALL = “en_US.UTF-8″,
LANG = “en_US.UTF-8″
are supported and installed on your system.

Use this!

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
locale-gen en_US.UTF-8
dpkg-reconfigure locales

Worked for me. Of course, replace en_US with w/e your primary language is.

Categories: ubuntu, unix Tags: , ,

Remove all non-printable ASCII Characters from filename

October 31, 2011 3 comments

Sometimes I get some crappy zipped/rared/whatever packages that contain filenames that are not UTF-8 encoded, mostly from old package programs used on the Windows platform. What happens is that those packages will unpack just fine, but more often than not you end up with filenames that contain non-printable characters. PITA if there’s a lot of them. tr to the rescue!

ls -1 | while read file; do N=$(echo $file | tr -cd '\11\12\40-\176'); mv "$file" "$N"; done

What this does is basically:

  • get every filename in the current directory and toss it to tr
  • the -c and -d options used like this command tr to only output characters that we actually specify
  • the quoted argument tells tr to only retain the octal characters 11, 12 and 40 to 176. Octal 11 is Tab, 12 is linefeed (technically, this should be omitted from a filename, but I also use this to filter textfiles, so it comes in handy and is of no real harm here). 40 to 176 are the standard keyboard characters from space to ~, which we actually like in our filenames.
  • finally, we move the garbled filename to the new, cleaned up version.
Categories: unix Tags: , ,

/usr/NX/bin/nxserver –keygen … Please, I want the last two hours of my life back!

October 27, 2011 3 comments

As good as Nomachine’s NX is … the documentation is seriously confusing  and all over the place with some documents more complete than others.

I tried to check out their new 4.x preview just yet (oh, and no, it’s definitely not ready for production), and as I always do, generate my own keys to go with it. But after the usual /usr/NX/bin/nxserver –keygen, a restart failed with

NX> 500 ERROR: Cannot start service: nxserver
NX> 500 Authentication as user nx using the NX SSH key-pair failed.
NX> 500 This may be due to the configuration of your SSH server. Please
NX> 500 ensure that the location and file name of the SSH authorized
NX> 500 keys is the same in both the SSHD and NX server configuration
NX> 500 files and that the nx user is listed among the accepted users
NX> 500 in the SSHD configuration file.
NX> 999 Bye.

Got seriously frustrated, because all seemed well according to documentation. Well, it seems like there is one important step missing – renaming or copying




If you don’t do that, nxserver will happily continue to use its prior key (which makes sense I guess, you aren’t going into production with new keys the second you generate them) while the nx user will already have the new keys in place.

So basically the procedure is:

# /etc/init.d/nxserver stop
# /usr/NX/bin/nxserver --keygen
# chown nx:root /usr/NX/home/nx/.ssh/authorized_keys2
# chmod 0644 /usr/NX/home/nx/.ssh/authorized_keys2
# chown nx:root /usr/NX/home/nx/.ssh/
# chmod 0644 /usr/NX/home/nx/.ssh/ 
# cp /usr/NX/share/keys/default.id_dsa.key /usr/NX/share/keys/server.id_dsa.key
# /etc/init.d/nxserver start

Of course, your client(s) will also need to import the new server key.

Categories: rants, unix Tags: ,

NoMachine NX, Ubuntu and the XSession

October 27, 2011 1 comment

If you get the dreaded

'Cannot run /etc/X11/xdm/Xsession ...'

when requesting a new session on an Ubuntu server, this – at least for me – fixed it:

sudo mkdir /etc/X11/xdm && sudo ln -s /etc/X11/Xsession /etc/X11/xdm/Xsession
Categories: ubuntu, unix Tags: , ,

Use ffmpeg to merge multiple avi files

October 25, 2011 Leave a comment
cat avi1.avi avi2.avi avix.avi > avi_all.avi
ffmpeg -i avi_all.avi -acodec copy -vcodec copy avi_all_reindexed.avi
Categories: unix Tags: ,

Split a video file on the command line

October 13, 2011 Leave a comment

Since it’s so insanely useful and installing/using the common graphical video editors is pretty much a pita:

ffmpeg -ss 00:15:00.0 -t 00:10:0.0 -i <source>.foo -vcodec copy -acodec copy <destination>.foo

Above command clips everything to the 15 minute mark, puts the following 10 minutes into the destination file and then clips everything after that.
If you leave out the -t parameter, everything from the -ss mark to the end gets copied to the destination file. Useful and fast.

Categories: unix Tags: , ,
%d bloggers like this: