Thursday, February 5, 2015

Gnu Parallel

I had never heard of this til now, but it looks like it can make some tasks in Bash much simpler/faster.

From: https://en.wikipedia.org/wiki/GNU_parallel

The idea is to convert code such as:

for x in `cat list` ; do
do_something "$x"
done | process_output


Into


cat list | parallel do_something | process_output


Another simple example someone posted on the Arch Wiki (s/printf/echo/):


printf "world\nasynchronous processing" | parallel "echo hello, {}"

hello, world
hello, asynchronous processing

Wednesday, February 4, 2015

OpenSSL: Find certificate whose CSR was generated by a given private key


It can be confusing to determine which certificate file and which private key go together if you don't know exactly what you are looking for. At least one way to determine whether a given key was used to generate the Certificate Signing Request of a given cert is to compare their modulus values (shortened/obscured by md5 hashing).




Show the value for the private key.



$ openssl rsa -noout -modulus -in private_key.key | openssl md5

(stdin)= cab197... some stuff ... c68caa2



Show the value for the cert.




$ openssl x509 -noout -modulus -in signed_cert.crt | openssl md5

(stdin)= cab197... same stuff ... c68caa2




If the values match they go together.

I got my certificates in a bunch of formats and couldn't figure out which to use, so I brute forced the solution:



$ for file in `ls *c[er][rt]` ; do echo -n $file && openssl x509 -noout -modulus -in $file | openssl md5 ; done
some_file.crt (stdin)= cab197... c68caa2

other_file.cer (stdin)= 2241f7... D08923

...

Convert ide bus to virtio in Windows guests on Proxmox

Surprisingly simple to do this:


This is the exact procedure from http://forum.proxmox.com/threads/5248-Is-it-possible-to-convert-to-Virtio:

With "BUS" you mean IDE I suppose. Yes, it's possible, just you could risk that Win2008 ask you for a reactivation (hardware change can trigger it).
Sure on the wiki you find the answer, that is the same way you usually follow when installing as Virtio from the beginning.
In short, shutdown Win2008 and simply add a very small HD (like 1GB) with Virtio type to your Win2008 guest from web interface, and have the cdrom pointing to the ISO with the virtio drivers for kvm (latest and greatests, virtio-win-1.1.11-0.iso at the moment, see http://alt.fedoraproject.org/pub/alt...st/images/bin/).
Boot Win2008 that will detect the new 1GB HD and ask you for drivers. Install them (the ones in P { margin-bottom: 0cm; }'Wlh' dir on the .iso) and shutdown. Remove the additional hd AND your current HD (will be listed beyond as unused HD), and then re-add it picking it from the unused section, but this time with VIRTIO interface. Boot the VM and enjoy!
Of course, I don't take resposability for the success of the above, so do a backup first, just in case...


By the way, we have a VSphere setup here now, I have been messing with it for a week and it is HORRENDOUS by comparison to Proxmox as far as ease of use and administration. The interface is the most unintuitive jumbled unorganized thing I have ever seen. Now I grant you that I am still new at it, but things that are SO obvious on proxmox are either difficult or impossible on VCenter.
There are many different interfaces for doing the same things, some options are allowed some places not others, its really confusing.

Tuesday, February 3, 2015

Copy contact between address books in Thunderbird

There is NO WAY to do this via menus, right clicks etc... that I have found. But there is a secret means I found:

"Hold down the Ctrl key at the same time as you drag and drop the contact record from one book to another in order to copy rather than move the data."

Thank you to http://forums.mozillazine.org/viewtopic.php?f=39&t=1970171

Thursday, January 29, 2015

Associating MS Office file types with Wine Applications

I've posted on this previously, but this one is just a bit different. I have associations that for instance start MS Word when I click a .docx file but, the file is not loaded. The launcher was executing:

env WINEPREFIX="/home/tward/.msoffice2010" wine /home/tward/.msoffice2010/dosdevices/c\:/Program\ Files/Microsoft\ Office/Office14/WINWORD.EXE %U

After seeing this post I changed it to simply tell wine to launch the proper application:
env WINEPREFIX="/home/tward/.msoffice2010" wine C:\\windows\\command\\start.exe /Unix %U

And its working now.

Friday, January 23, 2015

Set or change timezone in Debian

Just something I can't seem to remember when I need it:

~ $ sudo dpkg-reconfigure tzdata

Friday, January 16, 2015

Scripting user passwords in Proxmox 3.3

Proxmox has had a bug in their pveum code for some time now in that it won't let you directly script the user passwords when adding a user, or when changing a user's password. The usage info SAYS you can give passwords on the command line, but it doesn't work.

Well, I figured out a workaround. After realizing that pveum is a perl script, I found this post at this post at perlmonks.org which led me to make a small change to the line which reads the password to allow for redirected text to be accepted.

The change is in a subroutine beginning with "my $read_password = sub {" (line 49 on my system) to accept redirection. The blue is from the original file, the red reflects my change.

# diff pveum.original pveum.fixed
49c49
<     my $term = new Term::ReadLine ('pveum');
---
>     my $term = new Term::ReadLine ('pveum', \*STDIN, \*STDOUT);

So now I can update a password by redirecting the password string from Bash.

# printf "mypassword\nmypassword\n" | pveum passwd myuser@pve

Sunday, December 28, 2014

Run fsck on a partition during the next boot

These are said to work for Ubuntu, I imagine the tune2fs one at least will work in Arch but have not yet tried.



REM Method 1
~ # tune2fs -c 1 /dev/name_of_device

REM Method 2
~ # touch /forcefsck

Monday, November 3, 2014

Re-creating launchers for wine applications

If you can find the .lnk launchers created within the wine virtual drive, then you can create the linux launcher items with wine's menubuilder.


$ locate <program name>.lnk
... ( bunch of junk here ) ...
$ wine winemenubuilder <shortcut.lnk>

Thursday, October 23, 2014

TCP and UDP traceroute options

I found this blog entry that details how to use the regular Linux traceroute command for UDP or TCP tracerouting.

ICMP (the default, so -I not needed)
   $ traceroute -I www.microsoft.com  


UDP
   # traceroute -U www.microsoft.com 


TCP
   # traceroute -T -p 80 www.microsoft.com 

Saturday, October 18, 2014

Find files owned or not owned by a user

Find all files owned by joe.baloney
$ find .  -user joe.baloney -print
Find files NOT owned by joe
find . \! -user tward -print

Wednesday, October 8, 2014

Getting detailed device information with udevadm

The following command outputs info about the device specified as well as any other devices in the chain (e.g. USB controllers etc...)

udevadm info --attribute-walk --name=/dev/sda

Wednesday, September 17, 2014

VFAT is patented??

I just found that the VFAT "file system" has a patent. Is there anything Microsoft can't do? It makes we wonder that they haven't they patented using consecutive memory address locations for arrays.

The surprising thing is that all of the articles I seem to come across discussing this, none of them include reactions such as WTF???

First of all it sucks, and its only in use now because its already in use now.

http://www.linux-mag.com/id/7325/