Linux CLI Dumping Ground
Interesting commands I have come across.
-
losetup: create block storage loopback devices.
-
dmsetup: low level logical volume management.
-
strace - trace system calls and signals
-
Input/output operations per second is an input/output performance measurement. IO per second.
-
hdparm -I /dev/sda: hard drive info: including block size. -
stressstress test in EPEL. -
nc: netcat. Create a network stream to test connections.nc hv01g01.lunartech.tech 22 - conda config –set auto_activate_base false
-
tree: view directory structure as a tree. -
fzf: fuzzy finder. -
CTRL + V + TAB: type a tab literal on the terminal. -
#!/bin/bashvs#!/usr/bin/env bashlatter is more portable but has some gotchas with passing arguments and is arguably less secure. Latter looks for Python in $PATH. column -tsort tabular content as a table. Delimiter can be changed.blockdev --getbsz /dev/sdd: get block sizeqemu-system-x86_64 -hda /dev/sdx: test USB penpv < SOURCE > DESTINATION: dd equivalent with optimal performance and progress bar- bridge: manipulate virtual network bridges
- fuser: identify processes using files or sockets. -cu. -c POSIX compatibility. -u user. -k SIGKILL.
LVM Snapshots
-
https://serverfault.com/questions/279571/lvm-dangers-and-caveats
-
LVM snapshots:
Snapshots are hard to use, slow and buggy - if snapshot runs out of pre-allocated space it is automatically dropped. Each snapshot of a given LV is a delta against that LV (not against previous snapshots) which can require a lot of space when snapshotting filesystems with significant write activity (every snapshot is larger than the previous one). It is safe to create a snapshot LV that’s the same size as the original LV, as the snapshot will then never run out of free space.
Snapshots can also be very slow (meaning 3 to 6 times slower than without LVM for these MySQL tests) - see this answer covering various snapshot problems. The slowness is partly because snapshots require many synchronous writes.
Snapshots have had some significant bugs, e.g. in some cases they can make boot very slow, or cause boot to fail completely (because the kernel can time out waiting for the root FS when it’s an LVM snapshot [fixed in Debian initramfs-tools update, Mar 2015]).
- However, many snapshot race condition bugs were apparently fixed by 2015.
-
LVM without snapshots generally seems quite well debugged, perhaps because snapshots aren’t used as much as the core features.
-
LVM snapshots: for consistent “frozen” state for back-ups, online fsck and as a temporary roll-back point for risky changes.
- I ALWAYS turn off the fsck -A on startup for large partitions (you can to this in fstab by making that last little number a 0 instead of a 1 or 2)… you dont want a random crash or maintenance reboot adding 10-12 hours to your downtime/window. If you are worried about file system corruption you should schedule time to umount the partition and run the fsck manually.
Bash
Useful .inputrc variables
GNU Readline Init File Reference
Make tab auto-completion work via one keystroke rather than two:
set show-all-if-ambiguous on
Make tab auto-completion ignore case:
set completion-ignore-case on
Padding in GNOME Terminal
In ~/.config/gtk-3.0/gtk.css (make it if it isn’t there):
VteTerminal,
TerminalScreen,
vte-terminal {
padding: 10px 10px 10px 10px;
-VteTerminal-inner-border: 10px 10px 10px 10px;
}
Useful Applications
trash-cli
A safer way to remove files and directories on the command line.
- trash-put: Delete files and folders.
- trash-list: Pint Deleted files and folders.
- trash-restore: Restore a file or folder from trash.
- trash-rm: Remove individual files from the trashcan.
- trash-empty: Empty the trashcan(s).
Cues
Physical/virtual disks
- blkid - locate/print block device attributes
- lsblk - list block devices
- ls -l /dev/disk/ # various subcategories in folders, e.g., by uuid
fstab
mount -aormount --allto apply new fstab entries without restarting.