# Command line print:lpr-oscaling=99image.jp
# Print A3 sheet:lp-d<printername>-omedia=a3-olandscape<filename># Fit to page:lp-dPro100S-TurboPrint-omedia=a3-ofit-to-page-olandscapeDownloads/00001.pdf
Change GRUB order
# Changes the order of the operating systems in GRUB window.# Sets Windows as the first one to bootsudomv/etc/grub.d/30_os-prober/etc/grub.d/09_os-prober# change windows index numbersudogrub-mkconfig-o/boot/grub/grub.cfg# create grub config file
Setup compact flash
# Check if the disk is connected:dmesg|grepsdb
# Partitioning:sudomkfs.ext4/dev/sdb1
# Mount:sudomount-text4/dev/sdb1/mnt
# Auto mount:addrowto/etc/fstab:
/dev/sdb1/mntext4defaults01# Other commands:sudoparted/dev/sdbmklabelmsdos
sudoparted-aopt/dev/sdbmkpartprimaryext40%100%
mount-a
Linux backup command
# Example backing up firefox user configs ( .mozilla folder )tarzcPf~/mozilla-backup-$($date+%s).tar.gz~/.mozilla
# 1. redo last command but as rootsudo!!
# 2. open an editor to run a commandctrl+x+e
# 3. create a super fast ram diskmkdir-p/mnt/ram
mount-ttmpfstmpfs/mnt/ram-osize=8192M
# 4. don't add command to history (note the leading space)ls-l
# 5. fix a really long command that you messed upfc# 6. tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379)ssh-L3337:127.0.0.1:6379root@emkc.org-N
# 7. quickly create foldersmkdir-pfolder/{sub1,sub2}/{sub1,sub2,sub3}creates2foldersand3subfoldersinsidethose(2x6folderstotal)mkdir-pfolder/{1..100}/{1..100}# creates 100 x 100 folders# 8. intercept stdout and log to filecatfile|tee-alog|cat>/dev/null
# bonus: exit terminal but leave all processes runningdisown-a&&exit## Search for a phrase in text file and get the tailing and heading lines aswell# get line number$cat/var/log/messages|grep-n"text_to_search"|cut-f1-d:
1533# Get +-10 lines near "text_to_search"$sed-n'1523,1543p'/var/log/messages
Linux GRUB
# Open GRUB command line in the bootloader menuPress:'c'# To get back to bootloader menu from GRUB command lineTypein:normal
# Edit kernel boot parametersPress:'e'
Linux get process ID on port
# Which PID is using the port:§fuser80/tcp
644# Find the process name:§ls-l/proc/644/exe
Linux run script on boot
##################### Deprecated ######################### How to create and run script on startup on Linux1.sudonano/etc/init.d/superscript,saveandexit2.sudochmod755/etc/init.d/superscript
3.sudoupdate-rc.dsuperscriptdefaults
########################################################## Updated way of starting scripts on boot:1.Createascripttorunonstartup.Example:
# startupScript.sh################################################!/bin/bashforiin{1..10}do# A way to exit the loop when CTRL + C is pressed.trap"echo Exited!; exit;"SIGINTSIGTERM
echo"Starting the test $i"python/home/pi/gwtest/tester2.py-d/home/pi/gwtest/configs/TestLongPatter.txt
echo"Ended the test $i"done###############################################2.Createaservicefile:
# /etc/systemd/system/startupIOtest.service###############################################[Unit]Description="StartIOtest"[Service]Type=forking
ExecStart=/bin/bash/home/pi/gwtest/startupScript.sh
TimeoutSec=0[Install]WantedBy=default.target
###############################################3.Reloadthedaemonstate
sudosystemctldaemon-reload
4.Enabletheservicestartuponboot
sudosystemctlenablestartIOtest.conf
Notes!
# To start the service immediately:sudosystemctlstartstartIOtest
# Check the service status:sudosystemctlstatusstartIOtest
Notworking:
# init file:# startIOtest.conf###############################################startonrunlevel[2345]stoponrunlevel[!2345]execbash/home/pi/gwtest/startupScript.sh
###############################################
Linux shell
--------------------------------------------------------------------------------------------
# get line number$cat/var/log/messages|grep-n"text_to_search"|cut-f1-d:
1533# get +-10 lines near "text_to_search"$sed-n'1523,1543p'/var/log/messages
--------------------------------------------------------------------------------------------
Linux unsupported distro mirrors
# 1. modify /etc/apt/sources.list and change ubuntu.com -> old-releases.ubuntu.com# Or automatically:sudosed-i-e's/archive.ubuntu.com/old-releases.ubuntu.com/g'/etc/apt/sources.list
# 2. Update distro:sudoapt-getupdate&&sudoapt-getdist-upgrade
Linux setup private internet access VPN
# Install OpenVPNsudoapt-getinstallopenvpn
# Download PIA VPN settingssudowgethttps://www.privateinternetaccess.com/openvpn/openvpn.zip
# Unzipunzipopenvpn.zip
# Run VPNsudoopenvpnFinland.ovpn
## Enable on boot:# Create auth filetouch/etc/openvpn/auth.txt
# Edit auth.txt:addusernametothefirstline
passwordtothesecondline
# Set permissionssudochmod600auth.txt
# Copy PIA settings to OpenVPN foldercpFinland.ovpn/etc/openvpn/
# Rename PIA settingsmvFindland.ovpnFinlanad.conf
# Edit PIA settingschange'auth-user-pass'->'auth-user-pass auth.txt'# Start VPNsudosystemctlstartopenvpn@Finland.
# Make sure it works:Checkip->wgethttp://ipinfo.io/ip-qO-
# Set autostart onedit/etc/default/openvpnanduncommentline:AUTOSTART="all"
Linux setup git SSH keys
# Create keys:1.ssh-keygen-trsa
# Create config:2.nano~/.ssh/config
pasteinfile:
Hostgitserv
Hostnamegithub.com
IdentityFile~/.ssh/id_rsa
IdentitiesOnlyyes
3.paste~/.ssh/id_rsa.pubcontenttogithubsettings
# If 2fa has been enabled:github.com->Usericon(topright)->Settings->Developersettings->Personalaccesstokens
->Generatenewtoken->Setnameandscope->saveaccesstoken
Useaccesstokenin'Password'fieldwhenpullingfromgithubincommandline
Linux create ssh keypair between machines
# Create keysssh-keygen-trsa-b2048# Set the public key to ssh servercat~/.ssh/id_rsa.pub|sshroot@192.168.1.35"mkdir -p ~/.ssh \ && cat >> ~/.ssh/authorized_keys"# To skip password prompt:scptaissh-oBatchMode=yes
Linux vim
# Create vim config file1.vim~/.vimrc
2.writesomebasicsettingsin:
setrulerlaststatus=2numbertitlehlsearch
syntaxon
3.ESC->:wq
# Alternative way to exit vimShift+ZZ
Linux wipeout disk
# Wipe out an hard drive on Linux.1.Listdisks:
sudofdisk-l
2.Pickadisktoclean
3.Wipeout
# less privacy waysudoddif=/dev/zeroof=/dev/sda
# more privacy waysudoddif=/dev/urandomof=/dev/sda