My Unix Notes
Those tips and tricks which make my life easier:
1) Search for the text files' content:
grep --include=\*.{ATP,atp} -rnwi ./ -e "PFI13A"
source: http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux
2) Search for a file and then apply some command in it:
find ./ -iname *TrT*DJEQ3*.atp -print | xargs -i cp {} ~/Dropbox/AL/Mestrado\ UNICAMP/Disciplinas/Sobretensões/TRT/
3) Search for a file name and then remove the first 2 lines:
find ./ -iname '*.adf' -print | xargs -i sed -i 1,2d {}
PS: sed is slow as hell doing it, so be careful when manipulating big text files with the -i flag.
4) Purge older kernels in openSUSE:
touch /boot/do_purge_kernels && systemctl start purge-kernels
source: stolen from #opensuse @ freenode: ProhtMeyhet
5) Hide processes from one user to another:
http://www.cyberciti.biz/faq/linux-hide-processes-from-other-users/
6) Restart KDE alt+f2 dialog (krunner)
krunner
7) Remove an installed package and also its unneeded dependencies (openSUSE):
zypper remove --clean-deps package
8) Disable Intel i7 turbo boost (very important for benchmarking!!):
# echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo
source: http://luisjdominguezp.tumblr.com/post/19610447111/disabling-turbo-boost-in-linux
9) Temporaly disable KWIN - Useful to play 3d games.
ALT+SHIFT+F12
source: https://en.opensuse.org/Steam
10) Power management in openSUSE
http://doc.opensuse.org/products/draft/SLES/SLES-tuning_sd_draft/cha.tuning.power.html
11) List all installed version from a specific package with zypper:
zypper info -s package
zypper search -s package
source: manpages
12) Install Google Chrome on openSUSE:
# zypper ar http://dl.google.com/linux/chrome/rpm/stable/x86_64 Google-Chrome # zypper ref # zypper install google-chrome-stable
source: http://anl4u.com/blog/how-to-install-google-chrome-in-opensuse/
13) Enabling magic sysrq keys in openSUSE:
Edit /etc/sysctl.conf change kernel.sysrq = 0 to kernel.sysrq = 1
source: https://www.ictu.nl/archief/wiki.noiv.nl/xwiki/bin/view/OpenAmsterdam/Linux%2BKernel%2BMagic%2BSysRq%2BKeys%2Bin%2BSuse%2Bfor%2Bcrash%2Brecovery.html
more info: https://www.kernel.org/doc/Documentation/sysrq.txt
14) Doing interactively plot and don't let the window close automatically:
gnuplot -persist file.plot
source: http://gnuplot.sourceforge.net/docs_4.2/node442.html
15) Debugging wine and recovering from when it doesn't want to start some application:
https://www.winehq.org/docs/winedev-guide/wine-debugger
16) Discovering the storage device names for udev:
# blkid
17) Gluing together two column based text files:
$ paste file1 file2
Source: http://stackoverflow.com/questions/11160145/merge-two-files-in-linux-with-different-column
18) Building openvpn server over Ubuntu 12.04 or 14.04.
http://www.slsmk.com/getting-started-with-openvpn/installing-openvpn-on-ubuntu-server-12-04-or-14-04-using-tap/
19) Cloning disks with dd:
https://wiki.archlinux.org/index.php/disk_cloning
20) Automatically repairing linux file system at reboot and other tunning options:
http://xmodulo.com/automatic-filesystem-checks-repair-linux.html
21) Setting disk i/o priority with ionice:
http://linux.die.net/man/1/ionice
http://www.cyberciti.biz/tips/linux-set-io-scheduling-class-priority.html
22) Setting linux priorities ionice, cpulimit and cgroups:
http://blog.scoutapp.com/articles/2014/11/04/restricting-process-cpu-usage-using-nice-cpulimit-and-cgroups
23) For some weird reason virtualbox stopped spanning to 1920 x 1080. Doubling the video ram memory seemed to work.
VBoxManage modifyvm "virtualmachine" --vram 256
source: http://ubuntuforums.org/archive/index.php/t-724091.html
24) Using clamav to scan files and verify if they're infected with virus:
clamscan -r –bell -i /dir/
source: https://tomaszzackiewicz.wordpress.com/2013/12/25/clamav-on-opensuse/
25) Many useful cheat sheets: http://www.nixtutor.com/linux/all-the-best-linux-cheat-sheets/
26) Letting users open ports below 1024 into FreeBSD:
sysctl net.inet.ip.portrange.reservedhigh=0
better indeed, insert this parameter in /etc/sysctl.conf
source http://yaws.hyber.org/privbind.yaws
http://lwn.net/Articles/524606/
27) Linux performance tools: http://techblog.netflix.com/2015/08/netflix-at-velocity-2015-linux.html
29) Sorting text files:
sort -kColuna -n
source: https://en.wikipedia.org/wiki/Sort_%28Unix%29
30) A lof of sysadmins interesting tools:
http://www.linuxdescomplicado.com.br/2015/09/30-ferramentas-que-todo-sysadmin-linux-deve-conhecer.html
31) Priorizing network usage by PID, iptables and tc. Good links:
http://unix.stackexchange.com/questions/34116/how-can-i-limit-the-bandwidth-used-by-a-process
http://www.cyberciti.biz/faq/linux-traffic-shaping-using-tc-to-control-http-traffic/
https://www.frozentux.net/iptables-tutorial/iptables-tutorial.html#OWNERMATCH
http://serverfault.com/questions/177554/higher-traffic-priority-for-fps-game-in-linux
32) Fixing file names with unsupported enconding
https://medium.com/on-archivy/invisible-defaults-and-perceived-limitations-processing-the-juan-gelman-files-4187fdd36759#.sqleodk5f