Bash Commands

This post will always be updated.

Converts key file to 1 line JSON key.
awk -v ORS=’\n’ ‘1’ public_key.pem | pbcopy

Grep Examples

Grep all of the files in the current directory

grep -rnw '.' -e 'text'

r: Recursively search
n: Line Number
w: word-regexp

Grep with file


while read p; do grep $p --exclude=file\.txt -inrH . --color; done <file.txt

Nagios NRPE Check Examples

./check_http -H {host} -u "/{ur}" -S --expect=200

command[check_service]=/usr/lib64/nagios/plugins/check_http -I '{ipaddress}' -k 'Host: {host}' -S -s Dashboard -u '/{ur}'

/usr/local/nagios/libexec/check_http -H {host} -S -r '"failure":[1-9]' --invert-regex -u '/health-check'

Curl Examples

curl -kv 'https://{ipaddress}/{url}' -H "Host: {host}"

curl -kv -H 'Host: api.example.com' '192.168.1.1'

Cat Examples

Cat Without ‘# lines’

cat file |egrep -v "^#" |egrep .

Find Examples

find {directory} | xargs chown -R nginx:nginx

find / -name '*tar.gz' | tr '\n' '\0' | du -ch --files0-from=-

Rename Examples

rename -f "s/JPG/jpg/" *.JPG

ls Examples

ls |grep -v _[2-9].jpg | wc -l

PowerShell Commands

List the jobs

tasklist /s {remoteip} /u {username} /p {password} /svc

Kill the job in the remote computer via taskkill

taskkill /s {remoteip} /u {username} /p {password} /PID {PID}

 

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x