├── .gitignore ├── README.md ├── virtualbox.md ├── emmet.md ├── gradle.md ├── postgres.md ├── mysql.md ├── raspbian.md ├── python.md ├── edgeos.md ├── LICENSE.md ├── bash.md ├── mac.md ├── ffmpeg.md ├── bios.md ├── docker.md ├── ubuntu.md └── nix.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS Generated files 2 | .DS_Store 3 | .DS_Store? 4 | ._* 5 | .Spotlight-V100 6 | .Trashes 7 | Icon? 8 | ehthumbs.db 9 | Thumbs.db -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cheatsheet 2 | [![License: Unlicense](https://upload.wikimedia.org/wikipedia/commons/e/ee/Unlicense_Blue_Badge.svg)](https://unlicense.org) 3 | 4 | A compendium of CLI commands I can't stop looking up. -------------------------------------------------------------------------------- /virtualbox.md: -------------------------------------------------------------------------------- 1 | ```bash 2 | # List all virtual machines 3 | VBoxManage list vms 4 | 5 | # List all running virtual machines 6 | VBoxManage list runningvms 7 | 8 | # Start a virtual machine in headless mode 9 | VBoxManage startvm "" --type headless 10 | ``` 11 | -------------------------------------------------------------------------------- /emmet.md: -------------------------------------------------------------------------------- 1 | ## Shortcuts 2 | 3 | * `!` - new html page template 4 | * `h1#foo` - new h1 tag with id=foo 5 | * `div.test` - new div with class=test 6 | * `#test` - new div with class=test 7 | * `.test` - new div with class=test 8 | * `li*5` - create 5 new li tags 9 | * `lorem*4` - fill in lorem impsum 4 times -------------------------------------------------------------------------------- /gradle.md: -------------------------------------------------------------------------------- 1 | ## Get Task information 2 | ```bash 3 | gradle tasks --all 4 | ``` 5 | 6 | ## Create a new java gradle build in current dir 7 | ```bash 8 | # new java application 9 | gradle init --type java-application 10 | 11 | # new java library 12 | gradle init --type java-library 13 | ``` 14 | 15 | ## Run continuous tasks on change in the background 16 | ```bash 17 | gradle -t '' '' 18 | ``` -------------------------------------------------------------------------------- /postgres.md: -------------------------------------------------------------------------------- 1 | ## User Management 2 | ```SQL 3 | -- display users 4 | \du 5 | 6 | -- change user password 7 | \password 'USER_NAME' 8 | ``` 9 | 10 | ## Database Management 11 | ```SQL 12 | -- create DB 13 | CREATE DATABASE db_name; 14 | 15 | -- drop database 16 | DROP DATABASE db_name; 17 | 18 | -- create user with password 19 | CREATE USER some_username WITH PASSWORD 'password'; 20 | ``` 21 | 22 | ## Navigation 23 | ```SQL 24 | -- quit CLI 25 | \q 26 | ``` -------------------------------------------------------------------------------- /mysql.md: -------------------------------------------------------------------------------- 1 | ## Change Primary Key Value 2 | ```SQL 3 | ## Note: auto_increment value must be greater than largest index 4 | ALTER TABLE DATABASE.TABLE auto_increment=9000 5 | ``` 6 | 7 | ## Drop All Rows/Reset Primary Key Counter 8 | ```SQL 9 | truncate DATABASE.TABLE 10 | ``` 11 | 12 | ## cli 13 | * `-q` - don't buffer output into memory (quick) 14 | * `-r` - raw output, don't escape special chars like backslashes 15 | * `-B` - use tabs as column separators in output (results in a tsv) 16 | * `-h ''` - hostname to use 17 | -------------------------------------------------------------------------------- /raspbian.md: -------------------------------------------------------------------------------- 1 | ## Configure Settings: 2 | ```bash 3 | sudo raspi-config 4 | ``` 5 | 6 | ## Get system version information 7 | ```bash 8 | # Kernel version 9 | uname -a 10 | 11 | # Everything else 12 | cat /etc/os-release 13 | ``` 14 | 15 | ## Mount FAT32 USB 16 | ```bash 17 | sudo mount -t vfat '/dev/' '/media/' -o uid=1000,gid=100,utf8 18 | ``` 19 | 20 | ## Useful Programs 21 | ```bash 22 | # headless jre 23 | sudo apt -y install openjdk-11-jre-headless 24 | 25 | # samba 26 | sudo apt -y install samba samba-common-bin 27 | ``` 28 | 29 | ## Get CPU temp 30 | ```bash 31 | vcgencmd measure_temp 32 | ``` -------------------------------------------------------------------------------- /python.md: -------------------------------------------------------------------------------- 1 | ## django 2 | ```bash 3 | # install dependencies 4 | pip install Django pylint pylint-django 5 | 6 | # create new project 7 | django-admin startproject '' 8 | 9 | # add sub-app to project 10 | python manage.py startapp '' 11 | 12 | # start server 13 | python manage.py runserver 14 | 15 | # create migration 16 | python manage.py makemigrations 17 | 18 | # migrate db 19 | python manage.py migrate 20 | 21 | # create superuser for admin panel 22 | python manage.py createsuperuser 23 | 24 | # collect static files into one folder 25 | python manage.py collectstatic 26 | ``` 27 | 28 | ## gunicorn 29 | ```bash 30 | # restart a gunicorn service 31 | sudo systemctl restart gunicorn 32 | ``` 33 | 34 | ## twine 35 | ```bash 36 | # generate distribution files (from within project's root folder) 37 | python -m build # requires build package - pip install build 38 | 39 | # upload generated distribution files to pypi 40 | twine upload ''/* 41 | ``` 42 | 43 | ## pip 44 | ```bash 45 | # Create an editable install that works with vscode/pylance 46 | pip install -e '' --config-settings editable_mode=compat 47 | ``` -------------------------------------------------------------------------------- /edgeos.md: -------------------------------------------------------------------------------- 1 | ## Change Config 2 | ``` 3 | configure 4 | 5 | 6 | 7 | commit 8 | save 9 | exit 10 | ``` 11 | 12 | ## ssh 13 | ```bash 14 | # Disable password-based auth 15 | set service ssh disable-password-authentication 16 | 17 | # Install Public Key. Copy public key to the router (e.g. in /tmp/blah.pub), then do: 18 | loadkey '' '' 19 | 20 | # Delete public key 21 | delete system login user "" authentication public-keys '' 22 | ``` 23 | 24 | ## show 25 | ```bash 26 | # List user info 27 | show system login user '' 28 | 29 | # List interfaces 30 | show interfaces 31 | 32 | # show storage 33 | show system storage 34 | 35 | # list ssh keys 36 | show configuration commands | egrep public-keys 37 | ``` 38 | 39 | ## upgrade 40 | ```bash 41 | # show current version 42 | show version 43 | 44 | # show current storage 45 | show system image storage 46 | 47 | # upgrade image 48 | add system image 'https://dl.ubnt.com/.../firmware.tar' 49 | 50 | # confirm it worked; be sure to reboot when done 51 | show system image 52 | ``` 53 | 54 | ## misc 55 | ```bash 56 | # reboot 57 | reboot 58 | 59 | # shutdown 60 | shutdown 61 | ``` -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Unlicense (Public Domain) 2 | ============================ 3 | 4 | This is free and unencumbered software released into the public domain. 5 | 6 | Anyone is free to copy, modify, publish, use, compile, sell, or 7 | distribute this software, either in source code form or as a compiled 8 | binary, for any purpose, commercial or non-commercial, and by any 9 | means. 10 | 11 | In jurisdictions that recognize copyright laws, the author or authors 12 | of this software dedicate any and all copyright interest in the 13 | software to the public domain. We make this dedication for the benefit 14 | of the public at large and to the detriment of our heirs and 15 | successors. We intend this dedication to be an overt act of 16 | relinquishment in perpetuity of all present and future rights to this 17 | software under copyright law. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 23 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 24 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | For more information, please refer to <> -------------------------------------------------------------------------------- /bash.md: -------------------------------------------------------------------------------- 1 | ## Loop through lines of a file 2 | ```bash 3 | while read theLine || [[ -n $theLine ]]; do 4 | echo "$theLine" 5 | 6 | done < "" 7 | ``` 8 | 9 | ## ! commands 10 | ```bash 11 | # re-run last command 12 | !! 13 | 14 | # Re-run command N commands ago 15 | !-N 16 | 17 | # Last parameter from previous command 18 | !$ 19 | 20 | # All params from previous command 21 | !* 22 | ``` 23 | 24 | ## Job Control 25 | ```bash 26 | # list all jobs 27 | jobs 28 | 29 | # bring job to foreground 30 | fg %N # where N is the job number obtained from jobs 31 | 32 | # bring job to background 33 | bg %N # where N is the job number obtained from jobs 34 | ``` 35 | 36 | ## Variables 37 | ```bash 38 | # Get cli args but only from the 2nd element and onwards 39 | "${@:2}" 40 | 41 | # Prepend Foo to every element of an array, MY_ARRAY 42 | ${MY_ARRAY[@]/#/Foo} 43 | 44 | # Append Foo to every element of an array, MY_ARRAY 45 | ${MY_ARRAY[@]/%/Foo} 46 | 47 | # Convert a string, referenced by MY_VAR, to lowercase 48 | "${MY_VAR,,}" 49 | ``` 50 | 51 | ## slurp file into variable 52 | ```bash 53 | myVariable=$(<'') 54 | ``` 55 | 56 | ## append string to files (before the extension) 57 | ```bash 58 | # ${f%.*} - all chars before ext 59 | # ${f##*.} - all chars after ext (dot not incl) 60 | for f in *; do 61 | mv -v "$f" "${f%.*}.${f##*.}" 62 | done 63 | ``` 64 | 65 | ## debug 66 | ```bash 67 | bash -x "" 68 | ``` 69 | 70 | ## truncate file 71 | ```bash 72 | > '' 73 | ``` 74 | 75 | ## Recursively move files to new directory 76 | ```bash 77 | # recursively move all MOV files in cwd to a new dir 78 | mv ./**/*.MOV '' 79 | ``` -------------------------------------------------------------------------------- /mac.md: -------------------------------------------------------------------------------- 1 | ## Hide a file/folder 2 | ```bash 3 | # Hide 4 | chflags hidden '' 5 | 6 | # Show 7 | chflags nohidden '' 8 | ``` 9 | 10 | ## Make password-protected, encypted zips 11 | ```bash 12 | # Encypt and zip two files 13 | zip -e '.zip' 'input1.txt' 'input2.txt' 14 | 15 | # Encypt and zip a directory 16 | zip -er '.zip' '' 17 | ``` 18 | 19 | ## Software Update via Terminal 20 | ```bash 21 | # Check for new updates 22 | softwareupdate -l 23 | 24 | # Install an update 25 | softwareupdate -i '' 26 | 27 | # Install all available updates 28 | softwareupdate -ai 29 | 30 | # List recent update history 31 | softwareupdate --history 32 | ``` 33 | 34 | ## Show information about a volume 35 | ```bash 36 | diskutil info '' 37 | ``` 38 | 39 | ## SMB 40 | ```bash 41 | # List information about all SMB shares we're currently connected to 42 | smbutil statshares -a 43 | ``` 44 | 45 | ## Get summed lengths of videos in folders of current dir 46 | ```bash 47 | for d in */ ; do 48 | mdls "$d"/*.mov | grep Duration | awk '{ print $3 }' | paste -s -d+ - | bc 49 | done 50 | ``` 51 | 52 | ## Get info about the Mac 53 | ```bash 54 | # general hardware information 55 | system_profiler SPHardwareDataType 56 | 57 | # show info about battery cycles and/or connected AC adapter 58 | system_profiler SPPowerDataType 59 | 60 | # show name of CPU 61 | sysctl -n machdep.cpu.brand_string 62 | 63 | # show arch 64 | uname -m 65 | 66 | # get macOS version 67 | sw_vers -productVersion 68 | ``` 69 | 70 | ## Xcode 71 | ```bash 72 | # Uninstall Xcode CLT 73 | sudo rm -rf "/Library/Developer/CommandLineTools" 74 | 75 | # Get version of Swift that Xcode is using 76 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift --version 77 | ``` 78 | 79 | ## WiFi info 80 | ```bash 81 | # Show Available WiFi Networks 82 | /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s 83 | 84 | # Get information about current WiFi connection 85 | /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I 86 | ``` 87 | 88 | ## Change Wallpaper 89 | ```bash 90 | osascript -e 'tell application "Finder" to set desktop picture to POSIX file ""' 91 | ``` 92 | 93 | ## Gatekeeper 94 | ```bash 95 | # enable 96 | sudo spctl --master-enable 97 | 98 | # disable 99 | sudo spctl --master-disable 100 | 101 | # ad-hoc sign a binary (i.e. disable signature check for specific app) 102 | sudo codesign -f -s - '/Contents/MacOS/' 103 | 104 | # perform security assessment on app 105 | spctl --assess -vv "/App.app" 106 | 107 | # Get verbose info about app's signing status 108 | codesign -d --deep --verbose=2 -r- "/App.app" 109 | ``` 110 | 111 | ## Reset local account password 112 | ```bash 113 | # Recovery mode -> Terminal. Can't be locked with Apple ID. 114 | resetpassword 115 | ``` 116 | 117 | ## sips 118 | ```bash 119 | # Convert a single file from heic to jpg, highest quality 120 | sips -s format jpeg -s formatOptions best -m "/System/Library/ColorSync/Profiles/Display P3.icc" '.heic' -o '.jpg>' 121 | 122 | # Convert multiple files from heic to jpg, highest quality 123 | sips -s format jpeg -s formatOptions best -m "/System/Library/ColorSync/Profiles/Display P3.icc" '' '' -o '/' 124 | ``` 125 | 126 | ## plutil 127 | ```bash 128 | # Print contents of a plist in a human readable format 129 | plutil -p '' 130 | 131 | # Print a binary plist in XML format 132 | plutil -convert xml1 -o - '' 133 | ``` 134 | 135 | ## Internet speed test 136 | ```bash 137 | # uses Apple's servers 138 | networkQuality -v 139 | ``` 140 | 141 | ## open 142 | ```bash 143 | # reveal the file in a new finder window 144 | open -R '' 145 | ``` -------------------------------------------------------------------------------- /ffmpeg.md: -------------------------------------------------------------------------------- 1 | ## Transcode Audio 2 | ```bash 3 | # Convert audio to mp3 4 | ffmpeg -i '' -vn -c:a libmp3lame -b:a 320k out.mp3 5 | 6 | # Convert audio to flac 7 | ffmpeg -i '' -vn -c:a flac out.flac 8 | 9 | # Convert audio to wav 10 | ffmpeg -i '' -vn -c:a pcm_s16le out.wav 11 | 12 | # Convert audio to oga 13 | ffmpeg -i '' -vn -c:a libvorbis -q:a 8 out.oga 14 | 15 | # Convert audio to opus 16 | ffmpeg -i '' -vn -c:a libopus -b:a 96k out.opus 17 | 18 | # Convert every flac file in the current directory to mp3 19 | for f in *.flac; do ffmpeg -i "$f" -vn -c:a libmp3lame -b:a 320k "${f%.flac}.mp3"; done; 20 | 21 | # increase audio by 150% 22 | ffmpeg -i '' -vn -filter:a "volume=1.5" '' 23 | 24 | # increase audio by 10dB 25 | ffmpeg -i '' -vn -filter:a "volume=10dB" '' 26 | ``` 27 | 28 | ## Transcode Video 29 | ```bash 30 | # Convert a video to mov (x265) with okay quality 31 | ffmpeg -i '' -c:v libx265 -crf 28 -preset slower -c:a aac -vbr 3 -tag:v hvc1 'out.mov' 32 | 33 | # Convert a video to mkv (x265) with okay quality 34 | ffmpeg -i '' -c:v libx265 -crf 28 -preset slower -c:a aac -b:a 96k 'out.mkv' 35 | 36 | # Convert video to x264 37 | ffmpeg -i '' -c:v libx264 -preset slow -crf 22 -c:a aac -vbr 3 -pix_fmt yuv420p -movflags +faststart 'out.mp4' 38 | 39 | # Convert video to ogv 40 | ffmpeg -i '' -c:v libtheora -q:v 10 -c:a libvorbis -q:a 10 'out.ogv' 41 | 42 | # Convert video to webm 43 | ffmpeg -i '' -c:v libvpx-vp9 -b:v 0 -crf 24 -threads 4 -speed 0 -c:a libvorbis -q:a 8 -f webm 'out.webm' 44 | 45 | # Convert every MOV file in the current directory to audioless webm 46 | for f in *.MOV; do ffmpeg -i "$f" -an -c:v libvpx-vp9 -b:v 0 -crf 24 -threads 4 -speed 0 -f webm "${f%.MOV}.webm"; done; 47 | 48 | # convert a video to gif with okay quality 49 | ffmpeg -i '' -r 15 -vf "scale=512:-1,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" '' 50 | ``` 51 | 52 | ## Trim audio/video 53 | ```bash 54 | # Trim audio/video (ex: start at 5 sec and go until 2 min) 55 | ffmpeg -i '' -c:a copy -c:v copy -ss 5 -to 120 '' 56 | ``` 57 | 58 | ## Video Effects 59 | ### Rotation 60 | * 0 = 90° CounterCLockwise and Vertical Flip (default) 61 | * 1 = 90° Clockwise 62 | * 2 = 90° Counter-Clockwise 63 | * 3 = 90° Clockwise and Vertical Flip 64 | 65 | `-vf "transpose=2,transpose=2"` or `-vf "hflip"` for 180 degrees. 66 | 67 | ```bash 68 | # Rotate video 90° Clockwise 69 | ffmpeg -i '' -vf "transpose=1" -c:v libtheora -q:v 10 -c:a libvorbis -q:a 10 '' 70 | 71 | # Rotate using metadata (no transcode needed) 72 | ffmpeg -i '' -c copy -metadata:s:v rotate="90" '' 73 | ``` 74 | * [Rotate Guide](https://stackoverflow.com/a/9570992/5987787) 75 | * [How to rotate a video 180° with FFmpeg?](https://superuser.com/questions/578321/how-to-rotate-a-video-180-with-ffmpeg) 76 | 77 | ### Slow-Motion/Timelapse 78 | ```bash 79 | # Timelapse - 16x slowdown, forced 60fps 80 | ffmpeg -i '' -an -r 60 -vf "setpts=0.0625*PTS" -c:v libtheora -q:v 10 out.ogv 81 | 82 | # Slow-Motion - 8x speedup, forced 30fps 83 | ffmpeg -i '' -an -r 30 -vf "setpts=8*PTS" -c:v libtheora -q:v 10 out.ogv 84 | 85 | # Convert every MOV file in the current directory to audioless webm, slowed down 8x 86 | for f in *.MOV; do ffmpeg -i "$f" -an -r 30 -vf "setpts=8*PTS" -c:v libvpx-vp9 -b:v 0 -crf 24 -threads 4 -speed 0 -f webm "${f%.MOV}.webm"; done; 87 | ``` 88 | 89 | ### Deinterlace 90 | ```bash 91 | ffmpeg -i '' -c:v libx265 -crf 28 -vf yadif -an -tag:v hvc1 out.mov 92 | ``` 93 | 94 | ## Join MP4s 95 | ```bash 96 | # Convert all files to ts, then concatenate them 97 | for f in *.mp4; do ffmpeg -i "$f" -c copy -bsf:v h264_mp4toannexb -f mpegts "${f%.mp4}.ts"; done; 98 | ffmpeg -i "concat:FILE1.ts|FILE2.ts|FILE3.ts" -c copy -bsf:a aac_adtstoasc '' 99 | ``` 100 | 101 | * [Concat Guide](https://trac.ffmpeg.org/wiki/Concatenate#protocol) 102 | 103 | ## loop a video and/or audio file 104 | ```bash 105 | # loop a a/v file 5 times and dump the result into the output 106 | ffmpeg -stream_loop 5 -i '' -c copy '' 107 | ``` 108 | 109 | ## combine srt & video into mkv 110 | ```bash 111 | ffmpeg -fflags +genpts -i '' -f srt -i '' -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt 'OUTPUT.mkv' 112 | ``` 113 | 114 | ## Create spectrogram of audio file 115 | ```bash 116 | ffmpeg -i '' -lavfi showspectrumpic '.png' 117 | ``` 118 | 119 | * Spectrogram [reference](https://old.reddit.com/r/trap/comments/3l5l3q/a_guide_to_determining_the_true_quality_of_an/) -------------------------------------------------------------------------------- /bios.md: -------------------------------------------------------------------------------- 1 | # Booting to the Boot Menu and BIOS 2 | Push these keys to display the bios menu or boot into the bios. 3 | 4 | ## Acer 5 | | Models | Boot Menu Key | Bios Key | 6 | | --- | --- | --- | 7 | | Aspire One zg5, zg8, Aspire Timeline | F12 | F2 | 8 | | Aspire v3, v5, v7 | F12 ("F12 Boot Menu" must be enabled in BIOS) | F2 | 9 | | | Esc, F2, F12 | Del, F2 | 10 | 11 | 12 | ## Apple 13 | | Models | Boot Menu Key | Bios Key | 14 | | --- | --- | --- | 15 | | Post-2006 models | Option | | 16 | 17 | 18 | ## Asus 19 | | Models | Boot Menu Key | Bios Key | 20 | | --- | --- | --- | 21 | | Desktops | F8 | F9 | 22 | | VivoBook f200ca, f202e, q200e, s200e, s400ca, s500ca, u38n, v500ca, v550ca, v551, x200ca, x202e, x550ca, z202e | Esc | Delete | 23 | | N550JV, N750JV, N550LF, Rog g750jh, Rog g750jw, Rog g750jx Zenbook Infinity ux301, Infinity ux301la, Prime ux31a, Prime ux32vd, R509C, Taichi 21, Touch u500vz, Transformer Book TX300 | Esc (Disable "Fast Boot" and "Secure Boot Control") | F2 | 24 | | k25f, k35e, k34u, k35u, k43u, k46cb, k52f, k53e, k55a, k60ij, k70ab, k72f, k73e, k73s, k84l, k93sm, k93sv, k95vb, k501, k601, R503C, x32a, x35u, x54c, x61g, x64c, x64v, x75a, x83v, x83vb, x90, x93sv, x95gl, x101ch, x102ba, x200ca, x202e, x301a, x401a, x401u, x501a, x502c, x750ja | F8 | Delete | 25 | | Eee PC 1015, 1025c | Esc | F2 | 26 | 27 | 28 | ## Compaq 29 | | Models | Boot Menu Key | Bios Key | 30 | | --- | --- | --- | 31 | | Presario | Esc, F9 | F10 | 32 | 33 | 34 | ## Dell 35 | | Models | Boot Menu Key | Bios Key | 36 | | --- | --- | --- | 37 | | | F12 (Select "USB Flash Drive") | F2 | 38 | 39 | 40 | ## eMachines 41 | | Models | Boot Menu Key | Bios Key | 42 | | --- | --- | --- | 43 | | | F12 | tab, DEL | 44 | 45 | 46 | ## Fujitsu 47 | | Models | Boot Menu Key | Bios Key | 48 | | --- | --- | --- | 49 | | | F12 | F2 | 50 | 51 | 52 | ## HP 53 | | Models | Boot Menu Key | Bios Key | 54 | | --- | --- | --- | 55 | | | Esc, F9 | Esc, F10, F1 | 56 | | Pavilion Media Center a1477c | Esc | F10 | 57 | | Pavilion 23 All In One | Esc (Select boot media from the menu) | F10 | 58 | | Pavilion Elite e9000, e9120y, e9150t, e9220y, e9280t | Esc, F9 | F10 | 59 | | Pavilion g4, g6 and g7, Probook 4520s, 4525s, 4540s, 4545s, 5220m, 5310m, 5330m, 5660b, 5670b | Esc | F10 | 60 | | Pavilion HPE PC, h8-1287c, Pavilion PC, p6 2317c, Pavilion PC, p7 1297cb, TouchSmart 520 PC, ENVY x2, m4, m4-1015dx, m4-1115dx, sleekbook m6, m6-1105dx, m6-1205dx, m6-k015dx, m6-k025dx, touchsmart m7, Envy, dv6 and dv7 PC, dv9700, Spectre 14, Spectre 13, 2000 - 2a20nr, 2a53ca, 2b16nr, 2b89wm, 2c29wm, 2d29wm | Esc (Then F9 for "Boot Menu") | Esc | 61 | | 2000 | Esc (Then F9 for "Boot Menu". Select "Patriot Memory" on the Boot Option Menu) | Esc | 62 | | Pavilion a410n | Esc | F1 | 63 | 64 | 65 | ## Intel 66 | | Models | Boot Menu Key | Bios Key | 67 | | --- | --- | --- | 68 | | | F10 | | 69 | 70 | 71 | ## Lenovo 72 | | Models | Boot Menu Key | Bios Key | 73 | | --- | --- | --- | 74 | | Desktops | F12, F8, F10 | F1, F2 | 75 | | Laptops | F12 | F1, F2 | 76 | | ThinkPad edge, e431, e531, e545, helix, l440, l540, s431, t440s, t540p, twist, w510, w520, w530, w540, x140, x220, x230, x240, X1 carbon | F12 | F1 | 77 | | IdeaPad s300, u110, u310 Touch, u410, u510, y500, y510, yoga 11, yoga 13, z500 | Novo Button (Next to power button), F12 | Novo Button | 78 | | IdeaPad P500 | F12 or Fn + F11 | F2 | 79 | | IdeaPad S10-3, g460, g470, g475, g480, g485 | F12 | F2 | 80 | 81 | 82 | ## Microsoft 83 | | Models | Boot Menu Key | Bios Key | 84 | | --- | --- | --- | 85 | | Surface Pro 1-3 | | Volume-Down Button | 86 | | Surface Pro 4 & Book | | Volume-Up Button | 87 | 88 | 89 | ## NEC 90 | | Models | Boot Menu Key | Bios Key | 91 | | --- | --- | --- | 92 | | | F5 | F2 | 93 | 94 | 95 | ## Packard Bell 96 | | Models | Boot Menu Key | Bios Key | 97 | | --- | --- | --- | 98 | | | F8 | F1, DEL | 99 | 100 | 101 | ## Samsung 102 | | Models | Boot Menu Key | Bios Key | 103 | | --- | --- | --- | 104 | | | F12, Esc | F2, F10 | 105 | | NC10, np300e5c, np300e5e, np350v5c, np355v5c, np365e5c, np550p5c | Esc | F2 | 106 | | Series 5 Ultra, Series 7 Chronos, Series 9 Ultrabook | Esc (Must disable "Fast Boot" in BIOS) | F2 | 107 | | Ativ Book 2, 8, 9 | F2 (Must disable "Fast Boot" in BIOS) | F10 | 108 | 109 | 110 | ## Sharp 111 | | Models | Boot Menu Key | Bios Key | 112 | | --- | --- | --- | 113 | | | | F2 | 114 | 115 | 116 | ## Sony 117 | | Models | Boot Menu Key | Bios Key | 118 | | --- | --- | --- | 119 | | VAIO Duo, Pro, Flip, Tap, Fit | Assist Button (Use the Assist Button when the computer is off, not when it is booting) | Assist Button (Use the Assist Button when the computer is off, not when it is booting) | 120 | | VAIO, PCG, VGN | F11 | F1, F2, F3 | 121 | | VGN | Esc, F10 | F2 | 122 | 123 | 124 | ## Toshiba 125 | | Models | Boot Menu Key | Bios Key | 126 | | --- | --- | --- | 127 | | Kira, Kirabook 13, Ultrabook, Qosmio g30, g35, g40, g50, Qosmio x70, x75, x500, x505, x870, x875, x880 | F12 | F2 | 128 | | Protege, Satellite, Tecra | F12 | F1, Esc | 129 | | Equium | F12 | F12 | 130 | 131 | 132 | ## Custom Builds 133 | | Manufacturer | Boot Menu Key | Bios Key | 134 | | --- | --- | --- | 135 | | ASUS | F8 | DEL | 136 | | Gigabyte | F12 | DEL | 137 | | MSI | F11 | DEL | 138 | | Intel | F10 | F2 | 139 | | Asrock | F11 | F2, DEL | 140 | | EVGA | F7 | DEL | 141 | 142 | 143 | Source: https://kb.wisc.edu/page.php?id=58779 -------------------------------------------------------------------------------- /docker.md: -------------------------------------------------------------------------------- 1 | ## container 2 | ```bash 3 | # show running containers 4 | docker container ls # old way was docker ps 5 | 6 | # show *all* containers, running or stopped 7 | docker container ls -a 8 | 9 | # start container and route traffic from 8080 on the host to 80 on the container. 10 | docker container run -d --publish 8080:80 --name '' '' 11 | 12 | # start container and attach it to the specified network 13 | docker container run -d --network '' --name '' '' 14 | 15 | # start container with specified network and DNS alias. Can be used for round-robin DNS 16 | docker container run -d --network '' --network-alias '' '' 17 | 18 | # start container with a specified volume name and path 19 | docker container run -d -v '':'' '' 20 | 21 | # start container and bind mount it to the specified path 22 | docker container run -d -v '':'' '' 23 | 24 | # stop a running container 25 | docker container stop '' # unique prefix of CONTAINER_ID also works 26 | 27 | # show logs for a container 28 | docker container logs '' 29 | 30 | # view processes running in a container 31 | docker container top '' 32 | 33 | # (forcibly) remove a cotnainer 34 | docker container rm -f '' 35 | 36 | # remove all stopped containers 37 | docker container prune -f 38 | 39 | # show json metadata about container (startup config, volumes, networking, etc) 40 | docker container inspect '' 41 | 42 | # show live performance for all containers 43 | docker container stats 44 | 45 | # create a container and start an interactive shell in it 46 | docker container run -i -t '' bash 47 | 48 | # create a container, start an interactive shell in it, delete the container on exit 49 | docker container run --rm -i -t '' bash 50 | 51 | # run a stopped container and start an interactive shell in it 52 | docker container start -a -i '' 53 | 54 | # start a shell in a running container 55 | docker container exec -i -t '' bash 56 | 57 | # view port mappings for a container 58 | docker container port '' 59 | ``` 60 | 61 | ## network 62 | ```bash 63 | # show networks 64 | docker network ls 65 | 66 | # get json metadata about a network 67 | docker network inspect 68 | 69 | # create a network (w/ default bridge driver) 70 | docker network create '' 71 | 72 | # create a network with the specified network driver 73 | docker network create --driver '' '' 74 | 75 | # add container to a network (like installing a new NIC and connecting to ethernet) 76 | docker network connect '' '' 77 | 78 | # remove a network from a container 79 | docker network disconnect '' '' 80 | ``` 81 | 82 | ## image 83 | ```bash 84 | # list downloaded images 85 | docker image ls 86 | 87 | # show image layers/history 88 | docker image history '' 89 | 90 | # json metadata about an image 91 | docker image inspect '' 92 | 93 | # give a new tag to an existing image 94 | docker image tag '':'' ''/'':'' 95 | 96 | # upload changed layers to docker hub 97 | docker image push '':'' 98 | 99 | # build an image based on a dockerfile 100 | docker image build -t '' '' 101 | 102 | # remove an image from the cache 103 | docker image rm '' 104 | 105 | # remove all images without at least one associated container 106 | docker image prune -af 107 | ``` 108 | 109 | ## volume 110 | ```bash 111 | # list volumes 112 | docker volume ls 113 | 114 | # determine which container a volume belongs to 115 | docker ps -a --filter volume=VOLUME_NAME_OR_MOUNT_POINT 116 | ``` 117 | 118 | ## dockerfile 119 | ```Dockerfile 120 | # create a new volume location and assign it to this location in the container. Outlives container 121 | VOLUME PATH/TO/DIRECTORY 122 | ``` 123 | 124 | ## docker-compose 125 | ```bash 126 | # setup all volumes/networks and start containers, run detached 127 | docker-compose up -d 128 | 129 | # stop all containers and remove containers/volumes 130 | docker-compose down -v 131 | 132 | # (re)build all custom images 133 | docker-compose build 134 | 135 | # view logs 136 | docker-compose logs 137 | 138 | # view containers, running and stopped 139 | docker-compose ps 140 | 141 | # view running processes 142 | docker-compose top 143 | ``` 144 | 145 | ## swarm 146 | ```bash 147 | # list running swarm nodes 148 | docker node ls 149 | 150 | # create a service/container and run a command 151 | docker service create '' '' 152 | 153 | # list running services/containers 154 | docker service ls 155 | 156 | # list tasks for a service 157 | docker service ps '' 158 | 159 | # scale up a service to 3 instances 160 | docker service update '' --replicas 3 161 | 162 | # remove a service 163 | docker service rm '' 164 | 165 | ``` 166 | 167 | ## misc 168 | ```bash 169 | # get version/check that docker is working 170 | docker version 171 | 172 | # login to push 173 | docker login 174 | 175 | # logout 176 | docker logout 177 | 178 | # enable swarm 179 | docker swarm init 180 | ``` -------------------------------------------------------------------------------- /ubuntu.md: -------------------------------------------------------------------------------- 1 | ## trash-cli 2 | ```bash 3 | # Move a file or directory to the trash 4 | trash-put '' 5 | 6 | # View contents of trash 7 | trash-list 8 | 9 | # Empty the Trash 10 | trash-empty 11 | ``` 12 | 13 | ## apt & dpkg 14 | ```bash 15 | # Install a .deb 16 | dpkg -i '' 17 | apt-get install -f 18 | 19 | # Add a PPA 20 | add-apt-repository 'ppa:' 21 | apt-get update 22 | apt-get install '' 23 | 24 | # Remove a PPA 25 | apt-add-repository --remove 'ppa:' 26 | apt-get update 27 | 28 | # Remove package 29 | apt-get remove '' 30 | 31 | # Remove package and delete all of its config files 32 | apt-get purge '' 33 | 34 | # Bypass phased upgrades nonsense 35 | sudo apt -o APT::Get::Always-Include-Phased-Updates=true upgrade -y 36 | sudo apt dist-upgrade -y # yolo 37 | 38 | # Determine the package a binary belongs to 39 | dpkg -S '' 40 | ``` 41 | 42 | ## mdadm 43 | ```bash 44 | # show all raid statuses 45 | cat /proc/mdstat 46 | 47 | # Check array status 48 | mdadm -D '/dev/' 49 | 50 | # Remove/Delete raid array 51 | sudo umount -l '/dev/' # lazily unmount 52 | sudo mdadm --stop '/dev/' 53 | sudo mdadm --zero-superblock '/dev/' 54 | sudo mdadm --remove '/dev/' 55 | sudo wipefs -a '/dev/' # stop kernel from re-adding 56 | 57 | # don't forget to remove any entries in /etc/fstab if applicable 58 | ``` 59 | 60 | ## Ubuntu Version 61 | ```bash 62 | # Get your ubuntu version 63 | lsb_release -r -s 64 | 65 | # Get version information about this debian distro 66 | lsb_release -a 67 | ``` 68 | 69 | ## lsblk 70 | ```bash 71 | # list out all block devices 72 | lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT 73 | 74 | ``` 75 | 76 | ## lsusb 77 | ```bash 78 | # list all usb device ids (vendor:product id) 79 | lsusb 80 | 81 | # dump usb heierarchy as a tree 82 | lsusb -t 83 | ``` 84 | 85 | ## smart 86 | ```bash 87 | # enable smart on a drive 88 | sudo smartctl -s on '/dev/' 89 | 90 | # estimate how long it will take to run a test 91 | sudo smartctl -c '/dev/' 92 | 93 | # run a smart test 94 | sudo smartctl -t short '/dev/' 95 | 96 | # view drive's test stats 97 | sudo smartctl -l selftest '/dev/' 98 | 99 | # view detailed smart information for a disk (ATA disks) 100 | sudo smartctl -a -d ata '/dev/' 101 | 102 | # view detailed smart information for a disk (SCSI to ATA, typically for external USB hdd's) 103 | sudo smartctl -a -d sat '/dev/' 104 | 105 | # get lots of information about a disk 106 | sudo smartctl -x '/dev/' 107 | 108 | # temporarily set usb quirks flag for a device - use UAS, but still allow smartctl (reset on reboot) 109 | cat "/sys/module/usb_storage/parameters/quirks" # verify empty first 110 | printf "":"":"u\n" | sudo tee "/sys/module/usb_storage/parameters/quirks" # plug in device and try again 111 | ``` 112 | 113 | ## zfs 114 | ```bash 115 | # create raidz1 pool 116 | sudo zpool create '' raidz '/dev/' '/dev/' '/dev/' 117 | 118 | # create raid0 pool 119 | sudo zpool create '' '/dev/' '/dev/' '/dev/' 120 | 121 | # check zpool statues 122 | zpool status 123 | 124 | # list all properties of a zpool 125 | zfs get all '' 126 | 127 | # move zpool mount location 128 | sudo zfs set mountpoint='' '' 129 | 130 | # destroy a zpool 131 | sudo zpool destroy '' 132 | sudo wipefs -a '/dev/' # stop kernel from re-adding 133 | 134 | # list zpools which can be imported 135 | sudo zpool import 136 | 137 | # import zpool 138 | sudo zpool import '' 139 | 140 | # create snapshot. nb: datasets cannot be destroyed if snapshots of it exist. 141 | sudo zfs snapshot '@' 142 | 143 | # list snapshots 144 | zfs list -t snapshot 145 | 146 | # initiate a scrub 147 | zpool scrub '' 148 | 149 | # kill a running scrub 150 | zpool scrub -s '' 151 | ``` 152 | 153 | ## nfs 154 | ```bash 155 | # list all shares 156 | sudo exportfs -v 157 | 158 | # reset nfs after editing /etc/exports 159 | sudo exportfs -r 160 | ``` 161 | 162 | ## Useful Programs 163 | ```bash 164 | # SMART monitoring and GUI 165 | sudo apt -y install smartmontools gsmartcontrol 166 | 167 | # GUI Partioner 168 | sudo apt -y install gparted 169 | 170 | # LAN speed tester 171 | sudo apt -y install iperf3 172 | 173 | # screen recorder 174 | sudo apt -y install kazam 175 | 176 | # useful mkv tools 177 | sudo apt -y install mkvtoolnix 178 | 179 | # trash management cli that actually works 180 | sudo apt -y install trash-cli 181 | 182 | # ubuntu minimal desktop 183 | sudo apt -y install ubuntu-desktop-minimal 184 | 185 | # zfs 186 | sudo apt -y install zfsutils-linux 187 | ``` 188 | 189 | ## sed 190 | ```bash 191 | # grab all lines in a file matching REGEX_LINE_TO_MATCH and for each line replace TEXT_TO_REPLACE_REGEX w/ REPLACEMENT_TEXT 192 | sudo sed -i -e '//s///' '' 193 | 194 | # enables extended regex: capturing groups '(foo)' and quantifiers '?' 195 | sudo sed -i -E 's///' 196 | ``` 197 | 198 | ## hostnamectl 199 | ```bash 200 | # change this computer's (static, pretty, transient) hostname 201 | hostnamectl set-hostname '' 202 | ``` 203 | 204 | ## udisksctl 205 | ```bash 206 | # power off an external hard drive (do this after unmounting) 207 | sudo udisksctl power-off -b '/dev/' 208 | ``` 209 | 210 | ## sshd log 211 | ```bash 212 | # view 100 most recent sshd log entries 213 | grep "sshd" "/var/log/auth.log" | tail -n 100 | less 214 | ``` 215 | 216 | ## write xz'd img to SD card 217 | ```bash 218 | xzcat '' | sudo dd of='' bs=4M 219 | ``` 220 | 221 | ## mkvtoolnix 222 | ```bash 223 | # Concatenate mkv files. Note the plus sign on input2.mkv 224 | mkvmerge -o "OUTPUT.MKV" "input1.mkv" "+input2.mkv" 225 | ``` -------------------------------------------------------------------------------- /nix.md: -------------------------------------------------------------------------------- 1 | ## adduser 2 | ```bash 3 | # add a new user interactively 4 | sudo adduser '' 5 | 6 | # add a new service account interactively 7 | sudo adduser --disabled-password '' 8 | 9 | # add a new service account non-interactively 10 | sudo adduser --disabled-password --gecos "" '' 11 | ``` 12 | 13 | ## curl 14 | ```bash 15 | # perform a GET request, print headers to stdout 16 | curl -s -L -D - -o /dev/null '' 17 | ``` 18 | 19 | ## dd 20 | ```bash 21 | # Write ISO to a USB. Be sure to unmount any mounted partitions before attempting. 22 | sudo dd if='' of='' bs=4M status=progress && sync 23 | ``` 24 | 25 | ## diff 26 | ```bash 27 | # recursively compare two directories and list differences 28 | diff -rq directory1/ directory2/ 29 | 30 | # diff output of 2 commands 31 | diff <(command1 arg1 arg2) <(command2 arg1 arg2) 32 | ``` 33 | 34 | ## dig 35 | ```bash 36 | # get everything 37 | dig example.com 38 | 39 | # return MX records only 40 | dig example.com MX 41 | 42 | # use a specific dns server (e.g. cloudflare) 43 | dig @1.1.1.1 A 'example.com' 44 | ``` 45 | 46 | ## eyeD3 47 | ```bash 48 | eyeD3 -A '' -b '' --add-image '':FRONT_COVER '' 49 | ``` 50 | 51 | ## exiftool 52 | ```bash 53 | # delete all GPS and XMP metadata from a media file 54 | exiftool -gps:all= -xmp-exif:all= '' 55 | ``` 56 | 57 | ## find 58 | ```bash 59 | # find all files in a directory older than 10 days and delete them 60 | find '' -mtime +10 -name '*.pdf' -type f -delete 61 | 62 | # Recursively delete music metadata files 63 | find . -name '*.nfo' -type f -delete 64 | find . -name '*.m3u' -type f -delete 65 | find . -name '*.m3u8' -type f -delete 66 | 67 | # Recursively delete empty directories 68 | find . -type d -empty -delete -print 69 | ``` 70 | 71 | ## git 72 | ```bash 73 | # remove a file from git index but don't delete the local copy. 74 | git rm --cached '' 75 | 76 | # squash the last 3 commits 77 | git reset --soft HEAD~3 && git commit -m '' && git push -f 78 | 79 | # delete the most recent commit and rollback changes to the previous commit 80 | git reset --hard HEAD~1 81 | 82 | # add upstream to a GitHub fork 83 | git remote add upstream 'https://github.com//.git' 84 | 85 | # sync a GitHub fork with master. Be sure to have added 'upstream' as a remote 86 | git fetch upstream && git checkout master && git merge upstream/master 87 | 88 | # show content of last stash 89 | git stash show -p 90 | 91 | # delete your local changes and replace with what is currently on master 92 | git fetch --all && git reset --hard origin/master 93 | 94 | # don't use your system keychain for this repository 95 | git config --local credential.helper "" 96 | 97 | # Have git prompt for your new password next push 98 | git config --global --unset user.password 99 | 100 | # sync a branch with master 101 | git checkout master && git pull && git checkout '' && git merge master 102 | 103 | # cherry pick a commit 104 | git cherry-pick -x '' 105 | 106 | # clear saved git passwords in macOS keychain, make sure to press enter key after each line. 107 | git credential-osxkeychain erase 108 | host=github.com 109 | protocol=https 110 | 111 | # permanently delete all dangling commits 112 | git reflog expire --expire-unreachable=now --all 113 | git gc --prune=now 114 | ``` 115 | 116 | ## gpg 117 | ```bash 118 | # generate a key 119 | gpg --full-generate-key 120 | 121 | # list keys and show short IDs (used by gradle) 122 | gpg --list-keys --keyid-format SHORT 123 | 124 | # list keys for which I have both the public and private keys 125 | gpg --list-secret-keys --keyid-format LONG 126 | 127 | # Print GPG public key in ASCII armor format 128 | gpg --armor --export "" 129 | 130 | # Publish a public key (using Ubuntu's keyservers) 131 | gpg --keyserver keyserver.ubuntu.com --send-keys "" 132 | 133 | # Force gpg to output a secring.gpg file in the current directory 134 | gpg --export-secret-keys -o secring.gpg 135 | ``` 136 | 137 | ## grep 138 | ```bash 139 | # recursive grep for text in files 140 | grep -rnw '' -e '' 141 | ``` 142 | 143 | ## groups and users 144 | ```bash 145 | # list current user's groups 146 | groups 147 | 148 | # list another user's groups 149 | groups '' 150 | 151 | # Add existing user to new group 152 | sudo usermod -a -G '' '' 153 | 154 | # list users on a system 155 | compgen -u 156 | ``` 157 | 158 | ## imagemagick 159 | ```bash 160 | # Remove a white background from an image 161 | convert '' -fuzz 20% -transparent white out.png 162 | 163 | # Make a GIF from JPG files in a directory 164 | convert -dispose none -loop 0 -delay 100 *.JPG -resize 20% out.gif 165 | 166 | # Create a favicon from a square png 167 | convert '' -background transparent -define icon:auto-resize=16,24,32,48,64,72,96,128,256 favicon.ico 168 | 169 | # Convert a pdf to png (high resolution) 170 | convert -density 288 '' '' 171 | 172 | # Convert a svg to png with height 1000, high density, and alpha transparency 173 | convert -resize x1000 -density 1200 -background none '' 'OUTPUT_PNG' 174 | 175 | # get detailed information about an image 176 | magick identify -verbose '' 177 | 178 | # append images vertically 179 | magick '1.webp' '2.webp' '3.webp' -append 'OUT.webp' 180 | ``` 181 | 182 | ## iperf3 183 | ```bash 184 | # Start iperf3 server 185 | iperf3 -s 186 | 187 | # connect to server with iperf3 client 188 | iperf3 -c '' 189 | ``` 190 | 191 | ## lsof 192 | ```bash 193 | # Quickly (-n) list all open sockets by port (-P) on local device 194 | lsof -Pn -i4 195 | ``` 196 | 197 | ## ln 198 | ```bash 199 | # create symlink. Omit trailing slashes 200 | ln -s '' '' 201 | ``` 202 | 203 | ## ls 204 | ```bash 205 | # natural sort files in a directory 206 | ls -1 -v 207 | ``` 208 | 209 | ## nginx 210 | ```bash 211 | # restart an nginx service 212 | sudo nginx -t && sudo systemctl restart nginx 213 | ``` 214 | 215 | ## nmap 216 | ```bash 217 | # Scan all ports, no ping (-Pn), no DNS resolution (-n, helps reduce scan time) 218 | nmap -n -Pn -p 0-65535 127.0.0.1 219 | 220 | # Scan specific ports, no ping 221 | nmap -Pn -p 80,443,555 127.0.0.1 222 | 223 | # Scan all ports, be aggressive, probe for OS/app versions 224 | nmap -p 1-65535 -T4 -A -v 127.0.0.1 225 | 226 | # Host discovery on a CIDR range 227 | nmap -sP 10.0.1.0/24 228 | ``` 229 | 230 | #### other options 231 | * `-A` - enables OS/version detection, script scanning, and traceroute 232 | * `--allports` - enables scanning on 9100, a printer port. Caveat: some printers print anything sent to this port. 233 | * `-T4`/`-T5` - use an aggressive/insane timing template 234 | 235 | 236 | ## nc 237 | ```bash 238 | # check if a port is open, close connection immediately 239 | nc -vz '' '' 240 | ``` 241 | 242 | ## php 243 | ```bash 244 | # Initalize a dev php server at localhost:8080 rooted at ./public_html 245 | php -S localhost:8080 -t public_html/ 246 | ``` 247 | 248 | ## ps 249 | ```bash 250 | # get process name if you have its pid 251 | ps -p '' -o comm= 252 | 253 | # get detailed information about process with PID 254 | ps -Flw -p '' 255 | ``` 256 | 257 | ## rdfind 258 | ```bash 259 | # Recursively delete duplicate files in a directory 260 | rdfind -deleteduplicates true '' 261 | ``` 262 | 263 | ## rsync 264 | ```bash 265 | # archive, show progress, delete files on dest. Note trailing slash on SOURCE_FOLDER 266 | rsync -avh --progress --delete "/" "" 267 | 268 | # archive, use ssh to copy to dest on server 269 | rsync -avh "/" "user@myserver.com:" 270 | ``` 271 | 272 | #### notes 273 | `-a` stands for "archive mode", implies: 274 | * `-r`: recursive 275 | * `-l`: copy symlinks as symlinks 276 | * `-p`: preserve permissions 277 | * `-t`: preserve times 278 | * `-g`: preserve group 279 | * `-o`: preserve owner (super-user only) 280 | * `-D`: preserve device files and special files 281 | 282 | other interesting args: 283 | * `-v` - verbose 284 | * `-h` - human readable 285 | * `-P` - show progress bar and keep partially copied files 286 | * `-n` - dry run 287 | * `--delete` - delete files on dest which are not in source 288 | * `-u` - skip files that are newer on destination 289 | 290 | ## pgrep 291 | ```bash 292 | # compare against entire process name (why isn't this the default?!) 293 | pgrep -f '' 294 | ``` 295 | 296 | ## poppler 297 | ```bash 298 | # Extract images from pdf 299 | pdfimages -all '' '/' 300 | ``` 301 | 302 | ## screen 303 | ```bash 304 | # Start a new screen 305 | screen '' '' 306 | ``` 307 | * Enter command mode, use shortcut `Control` + `a` while running a screen. 308 | * To detach from the screen, press `d`. 309 | * To kill the current screen, press `k`. 310 | * To get documentation, press `?`. 311 | 312 | ```bash 313 | # List screens from bash 314 | screen -ls 315 | 316 | # Reattach a screen 317 | screen -r '' # pid comes from doing screen -ls 318 | ``` 319 | 320 | ## samba 321 | ```bash 322 | # create or change password of samba user 323 | smbpasswd -a '' 324 | 325 | # enable the account of an existing samba user 326 | sudo smbpasswd -e '' 327 | 328 | # create a system user for use with samba 329 | sudo adduser --no-create-home --shell /usr/sbin/nologin --disabled-password --disabled-login --ingroup sambashare '' 330 | 331 | # Various ways to get status/information about smbd: 332 | smbstatus 333 | pdbedit -L -v 334 | net usershare info --long 335 | smbtree 336 | ``` 337 | 338 | ## sox 339 | ```bash 340 | # Generate a spectrogram for an audio file 341 | sox '' -n spectrogram -o out.png 342 | ``` 343 | 344 | ## ssh 345 | ```bash 346 | # run a local script on a server 347 | ssh 'username@hostname' 'bash -s' < '' 348 | 349 | # List supported key types on a client 350 | ssh -Q key 351 | 352 | # Probe a server about its supported ssh algorithims 353 | nmap --script ssh2-enum-algos -sV -Pn -p 22 '' 354 | 355 | # Get info about an existing ssh key (either pub or priv key) 356 | ssh-keygen -l -f '' 357 | 358 | # Remove an entry from known_hosts 359 | ssh-keygen -R '' 360 | 361 | # Generate a new ed25519 priv/pub pair (best practice) 362 | ssh-keygen -t ed25519 -C '' 363 | 364 | # Generate a new rsa priv/pub pair (legacy systems) 365 | ssh-keygen -t rsa -b 4096 -C '' 366 | 367 | # have sshd parse and print its config (does not represent currently running daemon) 368 | sshd -T 369 | ``` 370 | 371 | ## systemctl/systemd 372 | ```bash 373 | # get status of a service 374 | systemctl status '' 375 | 376 | # enable service at boot 377 | systemctl enable '' 378 | 379 | # list all known services 380 | systemctl list-units --all 381 | 382 | # list all known unit files 383 | systemctl list-unit-files 384 | 385 | # display a unit file 386 | systemctl cat '' 387 | 388 | # display service's dependencies 389 | systemctl list-dependencies '' 390 | 391 | # mark a service as unstartable by nobody 392 | systemctl mask '' 393 | 394 | # unmask a service and return it to its previous state 395 | systemctl unmask '' 396 | 397 | # reload unit files after editing them 398 | systemctl daemon-reload 399 | ``` 400 | 401 | ## tar 402 | ```bash 403 | # Extract .tar.gz 404 | tar -xvzf '' 405 | 406 | # Create .tar.xz, based out of the specified dir 407 | tar -cJf '.tar.xz' -C 'DIR_TO_USE_AS_ROOT_OF_TAR' . 408 | 409 | # Create .tar.xz, use as many threads as possible 410 | XZ_OPT='-T0' tar -cJf '.tar.xz' . 411 | ``` 412 | 413 | ## ufw 414 | ```bash 415 | # see all registered firewall profiles 416 | ufw app list 417 | 418 | # allow a profile/rule 419 | ufw allow '' 420 | 421 | # show status 422 | ufw status 423 | 424 | # show status with rule priority 425 | ufw status numbered 426 | 427 | # delete a rule with id obtained from 'ufw status numbered' 428 | ufw delete '' 429 | 430 | # start firewall 431 | ufw enable 432 | ``` 433 | 434 | ## wget 435 | ```bash 436 | # download all media files on a page 437 | wget -nd -r -l 1 -H -A png,gif,jpg,svg,jpeg,webm -e robots=off '' 438 | 439 | # recursively download the contents of a website 440 | wget -e robots=off -m -k -np -w 5 '' 441 | 442 | # download contents of an open directory (not recursive) 443 | wget --no-directories --no-parent -r -l 1 -H '' 444 | ``` 445 | 446 | ## whois 447 | ```bash 448 | # get whois data for host 449 | whois example.com 450 | ``` 451 | 452 | ## xxd 453 | ```bash 454 | # view binary files 455 | xxd -b '' | less 456 | ``` 457 | 458 | ## yt-dlp 459 | ```bash 460 | # rip embedded vimeo 461 | yt-dlp '' --referer '' 462 | ``` --------------------------------------------------------------------------------