Scripting

Grep recursively through subdirectories

grep recursively through subdirectories for files that match a specific pattern: grep -l -r –include=*.doc regex * The equivalent command unsing find: find . -name ‘*.doc’ -exec grep -l regex \{\} \; The option after grep is the lowercase letter L, not the number 1). Remove the -l to see the actual matches instead of […]

Read More
Security

Shell script to Finding Accounts with No Password

Shell script to Finding Accounts with No Password listuserwopassword.bash #!/bin/bash # Shell script to Finding Accounts with No Password # Useful to improve system security # Copyright (c) 2005 nixCraft project # This script is licensed under GNU GPL version 2.0 or above # For more info, please visit: # http://cyberciti.biz/shell_scripting/bmsinstall.php # TODO # – […]

Read More
Linux

Shell script for search for no password entries and lock all accounts

Shell script for search for no password entries and lock all accounts find-account-no-password.sh #!/bin/bash # Shell script for search for no password entries and lock all accounts # ————————————————————————- # Copyright (c) 2005 nixCraft project # This script is licensed under GNU GPL version 2.0 or above # ————————————————————————- # This script is part of […]

Read More
Scripting

Strip comments from config files

This is at short script to strip/remove comments from config files #!/bin/bash # Code to cat a config file removing all comments and blank lines. grep -vh ‘^[[:space:]]*#’ “$@” | grep -v ‘^$’ Usage: ./confcat.sh /etc/make.conf Alternativ is to use sed cat filename | sed -e ‘s/#.*//;/^\s*$/d’ “$@” This also strips comments at the end […]

Read More