### Scan images from command line in Linux

Console utilities in Linuxes are cool: mcabber for jabber, mutt for mail, mocp for music, vim to rule them all! This note is about scaning from the console (I assume your scanner is already set-up). Aim is to scan document with good quality into pdf with reasonable size.

### SSH config for multiple hops in Linux

Often some hosts in corporate network are available only from several gateway machines. The scheme looks like that: you connect to gateway ssh -A gateway.public.net and then to desired host from gateway machines ssh -A host.private.net. But the problem arises when you want to copy or download something from host.private.net. You have to do it in two hops, because host.private.net is not available from your machine directly. The solution is ssh forwarding. Just add the following (edit according your network settings) lines to ~/.ssh/config:

### Configuration of hosts for convenient ssh connections

It is possible to save configuration of ssh connection for later usage. For example, one had to type

ssh <username>@<ip address> -p <port> -i <path to key file>


every time one wants to connect to server.

### Tools for tracing a pcap file in linux bash

Pcap files are pocket capture files. They usually contain raw log of network connections and packets. It is the most popular format and it available in almost all network analysis tool.

To play around *.pcap, you have to get such file somehow. There are two opposite ways: to generate it by yourself or to pick a ready one. To generate it by yourself, you can use wireshark or tcpdump in terminal:

tcpdump -w capture.pcap -i eth1


replace “capture.pcap” with desired output filename, “-i eth1” indicates the interface for the logging to be done.

### Show N biggest directories in linux bash

du (disk usage) utility in linux bash summarizes disk usage of each directory or file. By default, it outputs only directories. Just enter some dir and type

\$ du ./


### Toggling string case in linux bash

It’s quite an academic task, but anyway useful sometimes. I’ve collected different ways to do it in terminal in linux. Some of them work with UTF-8 characters (some it will toggle case for “й”, “ё” and so on. It will not in general handle special ligatures, such as “ß”” and “ﬁ”.)

Ways are: sed, perl, python, awk, tr, bash, dd.