====== Technical Information: General Linux Topics ====== * [[http://www.livenix.org|LiveNIX]] * [[:tech:linux:alpine:start|Alpine]] * [[:tech:linux:slackware:start|Slackware]] * [[:tech:linux:ubuntu:start|Ubuntu]] * [[:tech:linux:centos:start|CentOS/RHEL]] [[:tech:linux:desktop:start|So, You're Ready for the Linux Desktop ...]] \\ ===== Links/Resources ===== * Firefox 64-bit [[http://download-origin.cdn.mozilla.net/pub/firefox/releases/|downloads]] * [[http://www.brendangregg.com/perf.html|Interesting site on Linux performance topics]] ([[https://lwn.net/Articles/370423/|and some more here]]) * [[https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-gitlab-on-ubuntu-16-04|Setting up GitLab Community Edition]] ===== KVM/Qemu Basics ===== qemu-img create -f qcow2 sda 18G lvcreate -L 100G -n vmnamehome vgvms See [[:tech:virt:start|here]] for further details ===== Misc Tech Trivia ===== ==== X11 Display Auth ==== * From display owner //(where X is display number)//: ''xauth extract cookiefilename ://**X**//'' * For remote user, get cookie file and: ''xauth merge cookiefilename'' ==== Storage Management ==== * Good article: [[https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-18-04]] * **NOTE:** There seems to be issues with some hardware, where GPT partition tables are manipulated by some UEFI functionality, and so RAID volumes created on raw disk (without partition) are at risk of losing their superblock(s). Because of this, its generally recommended to utilize a partition instead of full-disk devices. * Set up RAID5 with ''mdadm'':mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdX1 /dev/sdY1 /dev/sdZ1 * Check status: ''cat /proc/mdstat'' * Configure for availability after boot: \\ //(**NOTE**: this must be done after recovery status is complete)// mdadm --detail --scan >> /etc/mdadm/mdadm.conf update-initramfs -u * Scrub to prevent bit-rot: ''echo check > /sys/block/md**X**1/md/sync_action'' \\ (use ''cat /proc/mdstat'' to monitor) * Tune re-build speed ([[https://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html]]): \\ To show limits: ''sysctl dev.raid.speed_limit_min ; sysctl dev.raid.speed_limit_max'' \\ To increase speed, enter: ''sysctl -w dev.raid.speed_limit_min=value'' \\ In ''/etc/sysctl.conf''dev.raid.speed_limit_min = 50000 ## good for 4-5 disks based array ## dev.raid.speed_limit_max = 2000000 ## good for large 6-12 disks based array ### dev.raid.speed_limit_max = 5000000 * Sample LVM with ''mdadm'' RAID: pvcreate -M2 /dev/md0 vgcreate -s 64 newvg /dev/md0 lvcreate -L 128G -n newlv newvg mkfs -t ext4 /dev/newvg/newlv ==== OverlayFS ==== * Ensure ''overlay'' module is loaded //(modprobe overlay)// * Mount syntax looks like:mount -t overlay -o lowerdir=ldir,upperdir=udir,workdir=wdir overlayfs overlaydir ==== 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 (''lp//X//'' 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 ' === Some resource links === * Draw-to-recognize unicode characters: [[http://shapecatcher.com|Shapecatcher]] * Lookup: [[https://unicode-table.com/en/#geometric-shapes|unicode character table]] [[tech:linux:fun:poweredbylinux|Interesting things powered by linux]] \\ // Links: [[:tech:start|Tech Info]] ... [[:mantis:start|Mantis Area]] //