/dev/blog/ID10T

Advertisement

Linux: Select all files in a folder

• Linux • Comments

I wrote a very similar post nearly three years ago (in German) and still need this daily. As I’m currently writing a lot of Dockerfiles, I realised my post wasn’t completely accurate. Although I redacted it, it’s a good opportunity to port the original post to the english language.

Requirement:

Select all files in a directory, including hidden ones or files beginning with crude symbols. But exclude . and .. as those will most likely lead to an exit code > 0.

Lets assume we want to chown all files in the directory /var/www/html:

[email protected]:/var/www/html# ls -la
total 60
-rw-r--r--.  1 root     root         2 Nov 30 09:25 --test
-rw-r--r--.  1 root     root         2 Nov 30 09:25 -test
drwxr-xr-x.  5 www-data www-data  4096 Nov 30 09:25 .
drwxr-xr-x.  3 root     root      4096 Nov 20 08:35 ..
-rw-r--r--.  1 root     root         0 Nov 30 09:24 ..a
-rw-r--r--.  1 root     root         0 Nov 30 09:24 ..aa
-rw-r--r--.  1 root     root         0 Nov 30 09:24 ..aaa
-rw-r--r--.  1 root     root         0 Nov 30 09:24 .a
-rw-r--r--.  1 root     root         0 Nov 30 09:24 .aa
-rw-r--r--.  1 root     root         0 Nov 30 09:24 .aaa
-rw-rw-r--.  1 root     root      1509 Aug 23 13:57 .htaccess.dist
-rw-rw-r--.  1 root     root       306 Aug 23 13:57 README
-rw-rw-r--.  1 root     root        23 Aug 23 13:57 VERSION
drwxrwxr-x.  2 root     root      4096 Nov 30 09:23 conf
drwxrwxr-x. 12 root     root      4096 Aug 23 13:57 data
-rw-rw-r--.  1 root     root     19372 Aug 23 13:57 feed.php
drwxrwxr-x.  3 root     root      4096 Nov 30 09:22 lib

Notice how we got a lot of strange filenames here, including files beginning with dashes or double dots.

Ubuntu: Full Youtube HTML5 Player support for Firefox

• linux and firefox • Comments

Problem: Firefox on Ubuntu doesn’t support the whole spectrum of HTML5 features Youtube provides.

Youtube HTML5 unsupported Features

Solution:

Switching the following about:config Settings to true:

media.mediasource.webm.enabled
media.mediasource.enabled
media.fragmented-mp4.exposed
media.fragmented-mp4.ffmpeg.enabled
media.fragmented-mp4.gmp.enabled

Using netcat as port listener

• linux • Comments

Short but useful tip:

If you want to test if a port is open on Linux (e.g. all firewalls were opened) but you don’t have the listening application installed yet, you can use nc/netcat.

On the server side do:

# For TCP

nc -l -p $PORT_NUMBER
# For UDP

nc -l -u -p $PORT_NUMBER

On the client side you can now connect to the listening port:

# For TCP

nc host.tld $PORT_NUMBER
# For UDP

nc -u host.tld $PORT_NUMBER

This is basically a telnet chat, so you can send strings which should then be received on the other side. If you want even more good uses for netcat, I recommend this blog post.

Compile Blackcoin headless on Raspbian

• crypto currency • Comments

As I’m working with my Raspberry Pis again, I wanted to reactivate the wallets of crypto currencies I used to mine some time ago. The Pi is not very potent, so only Proof-of-stake coins qualify. For me those are Blackcoin, Mintcoin and Reddcoin all of which I wanted to run on the Pi. Of course I needed the headless version, I’m not using X11, not even speaking of QT. So here is the TL;DR for compiling the blackcoind, mintcoind and reddcoind on Raspbian. It is probably the same for every other Debian derivate and most altcoins, independent of architecture or name. I’m taking Blackcoin for my example:

sudo apt-get install build-essential libssl-dev libdb-dev libdb++-dev libboost-all-dev git
sudo apt-get install libminiupnpc-dev # For UPNP support. You can also set USE_UPNP=0
sudo apt-get install libqrencode-dev # Or set USE_QRCODE=0
git clone https://github.com/rat4/blackcoin/
cd blackcoin/src/
make -f makefile.unix

That’s it. Now drink a coffee or - in my case with the original Raspberry Pi Model B, take a long nap (5 hours compile time). Afterwards you are free to enjoy your own brand new blackcoind.

Mount partitons of dd block device image

• linux • Comments

A small tip while I’m playing with my Raspberry Pi, Docker and the love child of both, Hypriot:

If you want to mount an image of a block device you created with dd, you might encounter the problem that you don’t know where the partitions start. In past times I used either offsets or kpartx for that. Today I found an easier way on superuser, the losetup tool. With losetup the process is really easy. Just associate your image file with a new loop device mount the corresponding partition:

  losetup --partscan --find --show disk.img
  mount /dev/loop0p1 /mnt

If you’re done, umount and detach the file from the loop device:

  losetup -d /dev/loop0

It seems the –partscan function is fairly new and not every Linux distro has such a new losetup version. Then you can either upgrade the version or do it as our ancestors did, utilizing offset or using kpartx.

Advertisement