apt-file – Find programs inside APT/Debian-repositories

Recently I noticed on a freshly installed server that there was no command called nslookup. Luckily, Debian-like distributions have the apt-file tool.

This makes it possible to search for applications that are not yet installed but are in principle available in the APT repository. The command

apt-file search nslookup

quickly shed light on the matter and delivered the following output:

bash-completion: /usr/share/bash-completion/completions/nslookup
bind9-doc: /usr/share/doc/bind9-doc/arm/man.nslookup.html
dnsutils: /usr/bin/nslookup
dnsutils: /usr/share/man/man1/nslookup.1.gz
exim4-doc-html: /usr/share/doc/exim4-doc-html/spec_html/ch-the_dnslookup_router.html
fpc-source-3.0.4: /usr/share/fpcsrc/3.0.4/packages/fcl-net/examples/cnslookup.pp
libnet-nslookup-perl: /usr/share/doc/libnet-nslookup-perl/changelog.Debian.gz
libnet-nslookup-perl: /usr/share/doc/libnet-nslookup-perl/copyright
libnet-nslookup-perl: /usr/share/lintian/overrides/libnet-nslookup-perl
libxpa-dev: /usr/share/man/man3/xpanslookup.3.gz

So it was clear that the dnsutils package had to be installed afterwards. Calling

apt-get install dnsutils

was enough and the nslookup tool was already available on my server.

If apt-file itself is not yet installed, it can be installed beforehand using

apt-get install apt-file

It is important that the cache is set up immediately afterwards. This is done using

apt-file update

Linux administration can be so easy …

Bye firefox

Is there actually a worse web browser than Firefox-Mozilla? I hardly thought that it couldn’t get any worse and Firefox is already putting one on it with the next version.

On the one hand, the high version numbers are a sign of crooked development and, on the other hand, the browser patronizes you wherever it can, under the pretext of security.

Aside from memory consumption and profile clutter, it has numerous bugs, although it has to be admitted that it runs even worse on Microsoft Windows than on Linux.

Anyway, I’ve buried him now. I’m not fixated on any browser but Firefox doesn’t come into my house anymore.

Freshcode-Club – Your preferred software-repository

Can anyone remember Freshmeat aka Freecode? This was the ultimate site to get OpenSource or Linux software.

Unfortunately, the project was stopped in 2014 and has been standing still ever since. The state at that time was frozen and can still be reached.

Alternatively, however, the Freshcode Club project has developed, which is reminiscent of the old days of Freshmeat with a similar design. See also https://freshcode.club

Unfortunately, I only discovered the project now, although it has been available on the internet for some time.

Prevent password query for SSH access on client side

Especially with automated scripts which establish SSH connections to external systems, the request for a password within the script is undesirable or leads to the script being blocked.

It is possible to simulate such password entries with the expect tool, but this is anything but secure. The best way is authentication via RSA keys, which must be entered as a public key in the target system in order to enable password-free access.

If you administrate many systems and have forgotten to import a public key into a target system, you end up with the problem of the blocked script again because a password query is initiated as a failover.

To prevent this, the -o BatchMode=yes parameter is simply passed to the SSH client. It is generally recommended to use this parameter as soon as ssh appears in a script. As a rule, however, it is not considered and prevents many a system from running automated processes.

A typical command-line will look like this:

ssh -o BatchMode=yes www.my-sample-hostname.com

If you use SSH indirectly via Rsync, this parameter can be used as follows:

rsync -av -e "ssh -o BatchMode=yes" www.mysample.com:/src1 /dst1

Set up Steam under Debian without an installer

First of all: When setting up Steam, I act as user tester. Any other user can be used instead of tester. However, all path information in this documentation must then also be changed.

First, download the official Steam installer from their web portal. A file steam.deb is then available in the downloads folder.

If you unpack this Debian package you will find the files that are necessary under the directory /CONTENTS (unpacking with the Midnight Commander is very simple by selecting steam.deb and pressing Enter)

  • /usr/bin/steam
  • /usr/bin/steamdeps
  • /usr/lib/steam/bootstraplinux_ubuntu12_32.tar.xz

The last file can be named differently under certain circumstances. Below /usr/lib/steam (within steam.deb!) There should be only one file.

All three files are now e.g. copied to /home/tester/steam/bin (This directory must be created beforehand!) Then the following steps are carried out as user root:

sudo dpkg --add-architecture i386
sudo apt-get update
sudo apt-get install libgl1-mesa-dri:i386
sudo apt-get install libgl1-mesa-glx:i386

Now change to the directory /home/tester/steam/bin and call the file steam:

cd /home/tester/steam/bin
./steam

If packages are still missing, they are now displayed in a separate window (missing packages are installed as above, the package names displayed by Steam can be adopted 1: 1) Otherwise, the execution of the Steam application begins, which usually starts with the Update of own binaries begins. Ultimately, the usual Steam window appears where games can be started and installed.

Addendum: The way described above does not create any desktop icons and otherwise Steam is NOT integrated into the existing desktop environment via GUI but has to be started manually as stated above.

Generate spectrograms with arecord, sox and ffmpeg/avconv

Create a spectrogram (image)

The following command creates a WAV file using Alsa (Device 2.0). In this case, Sox is additionally piped, which is completely unnecessary here, however, Sox could still add various filters to the resulting test.wav change:

arecord -D hw:2,0 -r 32000 -f S16_LE -c 1 -t wav | sox -t wav -c 1 -L -b 16 -r 32000 - test.wav

Using the file test.wav that has just been created, a spectrogram is now generated:

sox test.wav -n spectrogram -o image.png

The file image.png then looks something like this (in this case a simple whistle)

Similar can also be created using avconv:

avconv -i test.avi -lavfi showspectrumpic=s=hd480:legend=0,format=yuv420p out.png

Create a spectrogram (Video)

The following instruction creates a spectrogram from a video test.avi. This is saved as a video under the name out.avi.

avconv -i test.avi -filter_complex "[0:a]showspectrum=s=854x480:mode=combined:slide=scroll:saturation=0.2:scale=log,format=yuv420p[v]" -map "[v]" -map 0:a -b:v 700k -b:a 360k out.mp4

Instead of avconvffmpeg could also have been used. The Debian version does not currently support all parameters here.

Alternatives

A spectrogram of a video can also be created with mplayer or with the mplayer/sox combination.

First a WAV file is created using MPlayer:

mplayer test.mp4 -ao pcm:file=/dev/stdout -vo null > test.wav

This is followed by the creation of the spectrogram:

sox test.wav -n spectrogram -o test.png

The graphics created in this way can be compared directly. With some (apparently identical) WAV files this can be difficult.

For this reason, the display of a spectrogram diff is recommended.

First a WAV diff is created:

sox -m -v 1 source1.wav -v -1 source2.wav diff.wav

Then the spectrogram diff is created:

sox diff.wav -n spectrogram -o diff.png

Set the exif-date with exiftool

exiftool -AllDates="2017:03:11 00:00:00" test.jpg

Using

exiftool -AllDates+="3:0:0 0" *.jpg

incorrect Exif data can also be corrected (in this case the year is increased by 3)

Transferring files with Netcat/nc

Individual files can also be transferred using netcat. To do this, the following instructions must be used on the transmitter and receiver:

On the receiver:

nc -l -p 8888 -w 5 > ziel < /dev/null

At the sender:

nc servername 8888 < quelle

Explanation: The recipient starts a server service based on the first parts, which reacts to requests on TCP port 8888. With the instruction > ziel the content of received data is written to a file name ziel.

The file transfer is started on the transmitter by entering the second instruction. Here a connection with the server servername via port 8888 is initiated and the file quelle is transferred.

The file is transmitted unencrypted and uncompressed. Using tools like gzip and openssl this could be implemented transparently.

Convert images to a single video

There are several approaches here. The order of the images is problematic. The easiest way would be by:

cat *.jpg | ffmpeg -f image2pipe -r 25 -vcodec mjpeg -i - test.mp4

A warning is issued here because the pipe is aborted and ffmpeg does not seem to be able to recognize this.

Another method would be via image names which contain a sequential counter in the file name. If this is not the case, the file names can be changed as follows:

#!/bin/bash

COUNTER=1
for i in *.jpg; do
        NEW_FILENAME=$(printf "%04d.jpg" "$COUNTER")
        mv -i -- "$i" "$NEW_FILENAME"
        let COUNTER=COUNTER+1
done

The video can be created using:

ffmpeg -start_number 1 -i %04d.jpg -vcodec mpeg4 test.avi

In this case, the 4 fixed numerical digits on the left are filled in with 0. If the number is higher, the mask %04d must be changed accordingly.

Download YouTube videos in high quality using youtube-dl

This works with the command youtube-dl. The quality is indicated by 137+140137+140 means full HD quality (1080p)

#!/bin/bash

while [ 1 ]; do
	for FILE in $(ls queue); do
		echo $FILE
		UUID=$(cat /proc/sys/kernel/random/uuid)
		mv queue/$FILE processed/$UUID
		for URL in $(cat processed/$UUID); do
			echo $URL
			youtube-dl -f 137+140 "$URL"
		done
	done
	echo "Warte"
	sleep 15
done

To get a list of all possible formats for a video, instead of the parameter -f just write -F (stand-alone, without format specification!)

youtube-dl can also download entire playlists from Youtube! If you want to start from a certain position, the parameter --playlist-start can be used.