====== Bash snippets ======
http://www.commandlinefu.com
===== Git =====
git checkout -b test5 && git rebase --autosquash --interactive --root test5
===== Play YouTube Playlists =====
youtube-dl \
-f 'bestvideo[vcodec=vp9]+bestaudio[acodec=opus]' \
--merge-output-format mkv \
-o 'id_%(playlist_index)s - %(title)s (%(id)s).%(ext)s' \
--playlist-start 1 \
--playlist-end 19 \
'https://youtube.com/playlist/url'
mkvmerge -o all_001-019.mkv \[ id_{1..19}\ * \]
mpv --save-position-on-quit all_001-019.mkv
* Achte auf ''['' und '']'' um die input Videos im //append// Modus zu mergen
* Der glob ''*'' sortiert nicht numerisch (aber ''*(n)'' geht auch)
Geeignete Formate finden:
youtube-dl -F 'https://youtube.com/playlist/url' | \
grep -E '^[0-9]+' | \
sort -nr | \
uniq -w 10 -c | \
sort -nrs
Achte auf die Hardware-Beschleunigung (siehe ''vainfo'')
===== Order files and directories recursive by date =====
Order all files and directories in a certain subdirectory by date of last modification
find -print0 | xargs -0 ls -ldt | less
===== Proxy via SSH =====
ssh -D 4242 lmu
Im Browser kann dann der SOCKS Proxy "localhost" auf "4242" eingestellt werden.
===== List most used bash commands =====
history | cut -c 8- | cut -f 1 -d ' ' | sort | uniq -c | sort -n -r
The result:
101 l
69 c
40 mupdf
24 mv
16 sudo
16 history
12 vlc
12 rm
12 man
10 zip
10 pdflatex
9 ps
9 exit
9 echo
7 while
7 ssh
7 pacman
7 mplayer
7 ln
6 wget
6 umount
6 cat
5 sml
5 mkdir
5 acroread
....
===== SSH key =====
ssh-keygen
ssh-keygen -t ecdsa
ssh-keygen -t ed25519
ssh-copy-id -i ~/.ssh/id_rsa.pub ${R_USER}@${R_HOST}
===== List modified files =====
pacman -Qii | grep ^MODIFIED | sort
find /etc/ -type f | while read f ; do pacman -Qo "$f" >/dev/null 2>&1 || echo "$f" ; done
===== Install termcaps =====
infocmp rxvt-unicode-256color | s $YOUR_HOST "cat >~/tmp-term-info && tic ~/tmp-term-info && rm ~/tmp-term-info"
===== Pacman =====
Removing packages and their dependencies
pacman -Rs
Clean the package cache of packages that are not currently installed
pacman -Sc
Clean the entire package cache
pacman -Scc
===== Parameterübergabe =====
http://mywiki.wooledge.org/BashFAQ/050
===== rsync =====
* ''-X'' / ''%%--xattr%%''
* ''-S'' \\ Sparse Files
* ''-H'' \\ Hard links
* ''-a'' \\ Archive
* ''-u'' / ''%%--update%%''
* ''-A'' / ''%%--acls%%''
* ''-E'' \\ Speichere executable bit mit
* ''%%--progress%%''
=> ''%%rsync -aAxuHS --progress%%''
===== Bling stat Beep =====
http://netbuz.org/blog/2011/11/x-bells-and-urgency-hints/
===== Müll deaktivieren =====
chmod a-x /usr/lib/colord/colord
chmod a-x /usr/lib/gvfs/gvfsd
chmod a-x /usr/lib/gvfs/gvfsd-*
chmod a-x /usr/bin/kactivitymanagerd
chmod a-x /usr/lib/at-spi2-core/at-spi-bus-launcher
chmod a-x /usr/bin/knotify4
===== diff & patch =====
* ''diff -u original.c new.c > original.patch''
* ''patch -p1 < baz.patch''
===== Find =====
==== In small files ====
find ... -size -20k -type f -exec grep ... {} +
==== Files not belonging to the current user ====
find \! -user $(whoami) -exec ls --color=always -ld {} +
oder mit meinem ''notmine'' alias.
==== Big files ====
find / -type f -size +300M -exec ls --color=always -l {} +
====== pentadactyl ======
http://nakkaya.com/2014/01/26/pentadactyl-configuration/
set scrollsteps=1
set scrolltime=0
set incfind
set hlfind
====== SSL ======
nmap --script ssl-enum-ciphers -p 443 onmars.eu
sslscan --no-failed onmars.eu
openssl ciphers | tr : '\n' | sort
====== SCP / sshfs / sftp absichern ======
wget https://github.com/mysecureshell/mysecureshell/archive/v2.00.tar.gz
tar -xvf v2.00.tar.gz
cd mysecureshell-2.00
## root check aus install.sh entfernen
mkdir -p "$HOME/mysecureshell/"{bin,etc}
./configure \
--prefix="$HOME/mysecureshell" \
--with-conffile="$HOME/mysecureshell/sftp_config" \
--with-logfile="$HOME/mysecureshell/sftp-server.log" \
--with-shutfile="$HOME/mysecureshell/sftp.shut" \
--exec-prefix="$HOME/mysecureshell"
make all
Config
## http://mysecureshell.readthedocs.io/en/latest/index.html
Home /
ApplyFileSpec OnlyData
UseFullPath true
Order AllowDeny
Allow "^/(foo/1/?|foo/2/?|bar/baz/?|$|foo/?$|bar/?$)"
Deny all
====== CUPS ======
Delete all learned Network printers:
lpstat -s | \grep ///dev/null | cut -c 12- | cut -d: -f1 | xargs -n1 -- lpadmin -x
====== Zu schlecht für ein dotfile ======
Hier sind scripte, die zwar eine nette Idee, aber viel zu schlecht für ein dotfile sind.
( pgrep bash | xargs -n 1 pstree -Uangpsu ) | sed 's/^\([ │├─└]*\)\(\({[^,]*\)\|\([^,]*\)\),\([0-9]*\),\([0-9]*\)\(,\(\w*\)\|\)/\1 \x1b[1;30m\3\x1b[0m\x1b[1;37m\4\x1b[0m \x1b[36m\5\x1b[0m \x1b[34m\6\x1b[0m \x1b[33m\8\x1b[0m/'
## https://gitlab.labs.nic.cz/labs/dnssec-validator/issues/38
JAR="`echo ~/.moonchild\ productions/pale\ moon/*.default/extensions/dnssec@nic.cz/chrome/dnssec.jar`"
cd "`mktemp -d`"
unzip -q "$JAR"
patch -p1 <
-
+
-
+
EOF
zip "$JAR" content/firefoxOverlay.xul
smartctl -x /dev/sda
for i in [2, 1.9, 1.5, 1.1, None, 0, None, -1.1, -1.5, -1.9, -2]:
print('-'*105 if i is None else f'{i: .1f}: ceil = {math.ceil(i): } || round = {round(i): } | int(i+.5) = {int(i+0.5): } || floor = {math.floor(i): } | int = {int(i): } || int(i)+1 = {int(i)+1: } | int(i)-1 = {int(i)-1: }')
2.0: ceil = 2 || round = 2 | int(i+.5) = 2 || floor = 2 | int = 2 || int(i)+1 = 3 | int(i)-1 = 1
1.9: ceil = 2 || round = 2 | int(i+.5) = 2 || floor = 1 | int = 1 || int(i)+1 = 2 | int(i)-1 = 0
1.5: ceil = 2 || round = 2 | int(i+.5) = 2 || floor = 1 | int = 1 || int(i)+1 = 2 | int(i)-1 = 0
1.1: ceil = 2 || round = 1 | int(i+.5) = 1 || floor = 1 | int = 1 || int(i)+1 = 2 | int(i)-1 = 0
---------------------------------------------------------------------------------------------------------
0.0: ceil = 0 || round = 0 | int(i+.5) = 0 || floor = 0 | int = 0 || int(i)+1 = 1 | int(i)-1 = -1
---------------------------------------------------------------------------------------------------------
-1.1: ceil = -1 || round = -1 | int(i+.5) = 0 || floor = -2 | int = -1 || int(i)+1 = 0 | int(i)-1 = -2
-1.5: ceil = -1 || round = -2 | int(i+.5) = -1 || floor = -2 | int = -1 || int(i)+1 = 0 | int(i)-1 = -2
-1.9: ceil = -1 || round = -2 | int(i+.5) = -1 || floor = -2 | int = -1 || int(i)+1 = 0 | int(i)-1 = -2
-2.0: ceil = -2 || round = -2 | int(i+.5) = -1 || floor = -2 | int = -2 || int(i)+1 = -1 | int(i)-1 = -3