- Các tùy chọn hay dùng:
-name
: Tìm kiếm theo tên file/folder-type
: Theo kiểu,f
: Folder;d
: Directory-mtime N
: Thời gian tạo/chỉnh sửa.N
: là số ngày-exec
: Thực thi gì đó với các file tìm được-perm
: Tìm theo quyền truy cập (RWX)-user
: Tìm file thuộc sở hữu của user nào đó
-group
: Tìm file sở hữu của group nào đó
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ifs=`ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u` | |
for x in `ifconfig -a | grep "flags=" | cut -d":" -f1 | sort -u` # $ifs | |
do | |
IP=`ip -f inet -o addr show $x | cut -d\ -f 7 | cut -d/ -f 1` | |
if [ -z "$IP" ] | |
then | |
echo "${x}: Not connected." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Renew SSL for domain without deploy | |
server=$(dig +short a `hostname -f`) | |
domain=$(echo "$1" | tr '[:upper:]' '[:lower:]') | |
dom_mx=$(dig +short a mail.$domain) | |
if [ "$dom_mx" = "$server" ] && zmprov gd ${domain} > /dev/null 2>&1 | |
then | |
sudo certbot renew --cert-name mail.$domain | |
zmprov md $domain zimbraSSLCertificate "" zimbraSSLPrivateKey "" | |
chmod 600 /opt/zimbra/conf/domaincerts/$domain.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
file='list.txt' | |
port='25' | |
while getopts "p:f:" arg; | |
do | |
case $arg in | |
p) | |
port=$OPTARG |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
services="dovecot postfix amavisd clamd" | |
tmp="" | |
for ser in $services | |
do | |
stat=`service $ser status | grep -w 'running'` | |
echo $ser $USER >> /tmp/restart-service.log | |
if [ -z "$stat" ] | |
then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## Get login fail in 5m | |
send-notify(){ | |
sudo cat /opt/zimbra/log/audit.log | egrep "${timest}.*(authentication failed|invalid password)" > /tmp/get-audit.tenten | |
# sed -i '1s/^/`date '+%Y-%m-%d %H:%M'`\n/' /tmp/data.tenten | |
cat /tmp/get-audit.tenten | while read -r l | |
do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
IP2=$1 | |
IP=${IP2:-$(echo $(($RANDOM % 256)) $(($RANDOM % 256)) $(($RANDOM % 256)) $(($RANDOM % 256)) | sed 's/ /./g')} | |
if [[ "$IP" =~ ^(([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))\.){3}([1-9]?[0-9]|1[0-9][0-9]|2([0-4][0-9]|5[0-5]))$ ]]; then | |
echo -n "$IP: " | |
curl https://api.iptoasn.com/v1/as/ip/${IP} -s | grep -Eo '\"as_number\"(.+?)([0-9]),' | grep -Eo '[0-9]+' | |
# curl https://api.iptoasn.com/v1/as/ip/${IP} -s | sed 's/,/ /g;s/\"//g' | grep -Eo 'as_number.*' | awk {'print $1'} | cut -d':' -f2 | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
check_port() { | |
sort $1 | uniq -c | sort -nr | awk {'print $2'} | while read -r ip; | |
do | |
if ping -c 1 -w 1 $ip > /dev/null 2>&1; | |
then | |
if nc -vz -w 3 $ip 25 > /dev/null 2>&1; | |
then | |
echo $ip - Port 25 Opened; |