linux ยท reference

Linux HOW-TOs


Get .ini file value

sed -nr "/^\[protocol.mysql\]/ { :l /^password[ ]*=/ { s/.*=[ ]*//; p; q;}; n; b l;}" /etc/somefile

where protocol.mysql is the section and password is the variable name.

Fancy PS1 prompt

export PS1='[\u@\[\033[41;1m\]\h\[\033[0m\] \W(openstack_$OS_TENANT_NAME)]\$ '

dont forget to add \[ \] around control codes or cursor position will be wrong


Youtube-DL shortcuts


youtube-dl -o "%(playlist_title)s/%(autonumber)02d - %(title)s.%(ext)s"

Dump all formats

youtube-dl -F URL

Download one or many formats (mix)

youtube-dl -f 251 URL   # Audio only
youtube-dl -f 278+251 URL   # Audio + video
youtube-dl -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' URL
youtube-dl -f 'bestvideo[height<=480]+bestaudio[ext=m4a]/best[height<=480]' URL


hardstatus alwayslastline
hardstatus string '%{= Kd} %{= Kd}%-w%{= Kr}[%{= KW}%n %t%{= Kr}]%{= Kd}%+w %-= %{KG} %H%{KW}|%{KY}%101`%{KW}|%D %M %d %Y%{= Kc} %C%A%{-}'
defscrollback 5000
startup_message off
shell /bin/bash


Rename mate-screensaver-commandto .orig and symlink xscreensaver-command to mate-screensaver-command. Rename mate-screensaver to .orig. Edit exec section in /etc/xdg/autostart/mate-screensaver.desktop and change it to

Exec=/usr/bin/env http_proxy= xscreensaver -no-splash

Least annoying screensavers: grav, bsod (-no-nvidia), starwars, glsnake, apple2, glmatrix, substrate, cubicgrid, loop, phosphor.

Text-mode Linux: add consoleblank=60 to kernel boot to blank screen in 60 seconds.

Cups sharing

Add yourself to lpadmin group. Tick “Share printers connected to this system”. When configuring your printer, also share it.





spindown_time = 244


Check actual pixel order on the screen and configure in Appearance settings

Copy Windows 7 Segoe UI fonts to /usr/share/fonts/truetype/win7

Install terminus font to /usr/share/fonts/truetype/terminus from Run

dpkg-reconfigure fontconfig
fc-cache -f


Generate CApath manually (c_rehash utility replacement to re-index all certificates):

for f in *pem; do hash=$(openssl x509 -noout -hash -in $f); ln -s $f ${hash}.0; done;


Change domain password

Pick Domain controller from the list using

dig -t srv _ldap._tcp.dc._msdcs.[domain_name]


smbpasswd -U DOMAIN/username -r ip_of_domain_controller

Dmesg alias for Windows (cygwin .bashrc)

Use windows psTools from sysinternals:

dmesg () { /cygdrive/c/apps/pstools/psloglist64.exe -s -t '\t' |sort -k1 -n | awk -F '\t' '{print $6" "$1" "$4" "$2" "$7" "$9;}'; }

Show Windows License Key

wmic path softwarelicensingservice get OA3xOriginalProductKey

System scan / verification

sfc /scannow

Restore Health

dism /online /cleanup-image /restorehealth

Windows 10 enable Hyper-V

Run in Powershell as admin:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
DISM /Online /Enable-Feature /All /FeatureName:Microsoft-Hyper-V
comments powered by Disqus