--------------------------------------------------------
Etherial winks: It's 09:56 already over here.
--------------------------------------------------------
 [HOME] [ABOUT] [SCRIPTS] [INVISIBLE] [SNIPPETS] [BLOG]
--------------------------------------------------------
  ___________ __  .__                 .__       .__     
  \_   _____//  |_|  |__   ___________|__|____  |  |    
   |    __)_\   __\  |  \_/ __ \_  __ \  \__  \ |  |    
   |        \|  | |   Y  \  ___/|  | \/  |/ __ \|  |__  
  /_______  /|__| |___|  /\___  >__|  |__(____  /____/  
          \/           \/     \/              \/        
--------------------------------------------------------
[rock64@etherial] ~ $ ./snippets

Snippets:
Here you will find one-liners/snippets that I use in my
Linux bash console.

Generate a random 12 character password:
head -c 12 /dev/urandom | md5sum | head -c 12

Conditional checking if program is running:
pidof nginx>/dev/null && echo yes || echo no

Always reclaim or create the same screen session:
Put this line in your .bash_profile, 
replace 'Etherial' with your favorite screen name :)
[ -z "$STY" ] && screen -Rd "Etherial"

Strip empty lines and lines starting with # from file:
Don't forget to use the -i.bak to save a backup!
In this example the main file will be overwritten and 
the original file will be called sshd_config.bak
sed -i.bak '/^#/d;/^$/d' sshd_config

Show the CPU utilization:
ps -eo psr | sort | uniq -c | grep -v PSR |
awk'{print"CPU",$2,":",$1}'

Example output:
CPU 0 : 43
CPU 1 : 37
CPU 2 : 12
CPU 3 : 19

Use grep to find occurences with linenumbers
grep -in "query" *


                              Powered by a Rock64 (4GB)
                                 HTML5 & CSS3 verified!
                                     Generated: 0.0596s