quickreference:unix
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
quickreference:unix [2019/01/29 01:18] – external edit 127.0.0.1 | quickreference:unix [2020/01/18 19:25] – rodolico | ||
---|---|---|---|
Line 2: | Line 2: | ||
This is just a location where I store various commands I found handy for Unix. | This is just a location where I store various commands I found handy for Unix. | ||
+ | |||
+ | ===== Systems Administration ===== | ||
+ | |||
+ | ==== Grab Data via SSH ==== | ||
+ | |||
+ | I needed to grab the output from dmidecode for a bunch of machines. This would have been a good place for something like puppet, but we don't have it fully deployed. However, I have ssh access to most of the machines, so I was trying to figure out how to do it. I wanted the resulting filename to be `hostname -f`.dmidecode, | ||
+ | |||
+ | <code bash> | ||
+ | ssh HOSTNAME ' | ||
+ | </ | ||
+ | |||
+ | Dave came up with most of this, then I modified it for my use. Basically, he is returning the hostname and the output of dmidecode to a local temp file named aaee. If that works, then grab the first line into variable FNAM. Then send everything but the first line to the filename $FNAM.dmidecode. | ||
+ | |||
+ | Note, since dmidecode requires root privileges, I had to use sudo to get it to work. sudo wants a terminal unless you pass the -S parameter, in which case it prints the prompt on STDERR and waits for input. That input is not blanked, so it is visible on your monitor. | ||
+ | |||
+ | ===== Disk Management ===== | ||
+ | |||
+ | ==== Create Swap file ==== | ||
+ | |||
+ | I generally prefer a swap //file// as opposed to a swap // | ||
+ | |||
+ | <code bash> | ||
+ | fallocate -l 1G /swapfile | ||
+ | # if no fallocate on your system, use the following | ||
+ | # dd if=/ | ||
+ | chmod 600 /swapfile | ||
+ | # use " | ||
+ | mkswap -f /swapfile | ||
+ | # save, then modify fstab | ||
+ | mv /etc/fstab / | ||
+ | echo '/ | ||
+ | # turn on swap for everything in fstab | ||
+ | swapon -a | ||
+ | # display the result | ||
+ | swapon --show | ||
+ | </ | ||
===== Shell (mainly BASH) ===== | ===== Shell (mainly BASH) ===== | ||
Line 152: | Line 188: | ||
===== References ===== | ===== References ===== | ||
* https:// | * https:// | ||
+ | * https:// | ||
quickreference/unix.txt · Last modified: 2024/03/04 15:54 by rodolico