Table of Contents

Technical Information: General Linux Topics

So, You're Ready for the Linux Desktop ...

KVM/Qemu Basics

qemu-img create -f qcow2 sda 18G
lvcreate -L 100G -n vmnamehome vgvms

See here for further details

Misc Tech Trivia

X11 Display Auth

Storage Management

OverlayFS

Encrypted filesytem-in-a-file

This uses dm-crypt LUKS support, which is all part of the kernel (I believe) (in Ubuntu, make sure the lvm2 package is installed) :

dd if=/dev/urandom of=.diskimg bs=1M count=1024
losetup --find --show /home/rk4n3/.diskimg
cryptsetup -c aes-xts-plain64:sha256 -s 512 -v -y luksFormat /dev/loopX
cryptsetup luksOpen /dev/loopX diskname
mkfs -t ext4 /dev/mapper/diskname
mount /dev/mapper/diskname /home/rk4n3/sec

Here is similar, but for burning an encrypted DVD:

dd if=/dev/zero of=dvd.img bs=1M count=4400
losetup --find --show dvd.img
cryptsetup -c aes-xts-plain64:sha256 -s 512 -v -y luksFormat /dev/loopX
cryptsetup luksOpen /dev/loopX dvdimg
mkisofs -l -r -allow-leading-dots -allow-lowercase -allow-multidot -J -joliet-long -o /dev/mapper/dvdimg dir2burn

Cleaning up after …

cryptsetup luksClose /dev/mapper/dvdimg
losetup -d /dev/loopX

Mounting …

cryptsetup luksOpen /dev/sr0 yourdvdname
mount -o ro /dev/mapper/yourdvdname /mount/point/dir

Disable TouchPad

Run: xinput list
There will be a list that looks similar to:

⎡ Virtual core pointer                    	id=2	[master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer              	id=4	[slave  pointer  (2)]
⎜   ↳ ETPS/2 Elantech Touchpad                	id=12	[slave  pointer  (2)]
⎜   ↳ Logitech USB Receiver                   	id=15	[slave  pointer  (2)]
⎣ Virtual core keyboard                   	id=3	[master keyboard (2)]
    ↳ Virtual core XTEST keyboard             	id=5	[slave  keyboard (3)]
    ↳ Power Button                            	id=6	[slave  keyboard (3)]
    ↳ Video Bus                               	id=7	[slave  keyboard (3)]
    ↳ Video Bus                               	id=8	[slave  keyboard (3)]
    ↳ Power Button                            	id=9	[slave  keyboard (3)]
    ↳ Sleep Button                            	id=10	[slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard            	id=11	[slave  keyboard (3)]
    ↳ MSI WMI hotkeys                         	id=13	[slave  keyboard (3)]
    ↳ Logitech USB Receiver                   	id=14	[slave  keyboard (3)]

Run this command for the ID that matches trackpad device:
xinput set-prop 12 “Device Enabled” 0

Create a tmpfs filesystem

At the command-line:

mount -t tmpfs -o size=512m tmpfs /home/someone

In the /etc/fstab:

tmpfs            /home/someone         tmpfs      nodev,uid=1801,gid=100,size=512M  0  0

Ubunutu's color PS1 spec

export PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\ $'

Simple NIC speed test

On one machine:

nc -vvlnp 12345 > /dev/null

On the other:

dd if=/dev/zero bs=1M count=1K | nc -vvn x.x.x.x 12345

POS Receipt Printing

Epson ESC/POS command reference: https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=72
Nice article here: https://mike42.me/blog/2015-03-getting-a-usb-receipt-printer-working-on-linux
Use dmesg to verify that usblp has seen the printer (lpX device should be in /dev/usb):

dmesg
[12724.994550] usb 8-4: new full-speed USB device number 5 using ohci-pci
[12725.168956] usb 8-4: New USB device found, idVendor=04b8, idProduct=0e03
[12725.168963] usb 8-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[12725.168968] usb 8-4: Product: TM-T20
[12725.168971] usb 8-4: Manufacturer: EPSON
[12725.168975] usb 8-4: SerialNumber: ....
[12725.175114] usblp 8-4:1.0: usblp1: USB Bidirectional printer dev 5 if 0 alt 0 proto 2 vid 0x04B8 pid 0x0E03

Here's PHP code for a simple output:

/* ASCII constants */
const ESC = "\x1b";
const GS="\x1d";
const NUL="\x00";
 
/* Output an example receipt */
echo ESC."@"; // Reset to defaults
echo ESC."E".chr(1); // Bold
echo "FOO CORP Ltd.\n"; // Company
echo ESC."E".chr(0); // Not Bold
echo ESC."d".chr(1); // Blank line
echo "Receipt for whatever\n"; // Print text
echo ESC."d".chr(4); // 4 Blank lines
 
/* Bar-code at the end */
echo ESC."a".chr(1); // Centered printing
echo GS."k".chr(4)."987654321".NUL; // Print barcode
echo ESC."d".chr(1); // Blank line
echo "987654321\n"; // Print number
echo GS."V\x41".chr(3); // Cut
exit(0);

Some Fun Stuff

Some cool bash prompts

export PS1=$'\e[32m\u262F ${USER}@\e[33m${SYS} \u2622\u25AC\u25B6\e[0m '
export PS1=$'\e[32m\u250F\u2501\e[33m ${USER}@${SYS} \e[31m\u2622\e[36m ${PWD}\n\e[32m\u2517\u2501\u276F\u276F\u276F\e[0m '
export PS1=$'\e[32m\u250F\u2501\e[33m ${USER}@$(uname -n) \e[31m\u2622\e[36m \w\n\e[32m\u2517\u2501\u276F\u276F\u276F\e[0m '

Interesting things powered by linux


Links: Tech InfoMantis Area