Blog
bash
Posts: 22
· bash
· bash
find /home/ -type f -mtime +7 -exec rm '{}' \; delete files smaller than 5KB find ./ -size -5k -delete delete files larger than 10MB find ./ -size +10m -delete
· bash
Pr
· bash
· bash
install: example: batch conversion script:
· ActiveDirectory · bash
· bash
· bash
? if [ condition ]; then if the condition is true, execute all commands until else or fi else if the condition is not true, execute all commands until fi fi It is very important to remember that your construct must always end with the word fi! Expressions...
· bash
#!/bin/bash # Script for automating file downloads. LogFile=/var/log/backup_db.log NameDay=$((10#`date +%d`-1)) if [ ${#NameDay}=1 ]; then NameDay=0$NameDay fi temp_name=$(date +%m.%Y) NameDate=$NameDay.$temp_name FulName=$NameDate/BACKUP_SQL-$NameDate'_21.00.7z' #echo $FulName echo $(date) - start copy >> $LogFile aria2c "ftp://lomix.com.ua/$FulName" \ --ftp-user=ftpbackup --ftp-passwd=XXXXX \ --dir='/backup/db' --log='/var/log/aria.log' \ --max-concurrent-downloads=4…
· bash
#!/bin/sh # Mount a network drive from the seo-studio server sudo apt-get install smbfs mkdir /media/sharedisk cp "/etc/fstab" "/etc/fstab.default" echo "//192.168.4.224/sharedisk /media/sharedisk cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,_netdev 0 0" >> /etc/fstab echo "username=sharedisk" > /root/.smbcredentials echo "password=xxxxxxx" >> /root/.smbcredentials cd /etc/rc0.d sudo mv S31umountnfs.sh S19umountnfs.sh
· bash
· bash
Server=192.168.xxx.xxx Username=clientftp Password=xxxxxx Directory=test LDirectory="/test" Filename="index.php" ftp -n $Server <<End-Of-Session user $Username $Password binary bell cd $Directory lcd $LDirectory put $Filename bye End-Of-Session # If you need to copy multiple files, you can use the mput *.php template
· bash
Download the program from the source http://www.datsi.fi.upm.es/~frosal/, then extract it: mw shc-3.x.x.c shc.c make make test OPTIONS
· bash
crontab -e ## block those who are brute-forcing the SSH password 59 * * * * sh ~/ssh_security.sh vim ~/ssh_security.sh
· bash
#!/bin/bash ipban='netstat -an | grep :80 | grep -v 127.0.0.1 | grep -v 0.0.0.0 | awk '{ print $5 }' | sort | awk -F: '{print $1}' | uniq -c | awk '$1 > 20 {print $2}' for ip in $ipban do iptables -A INPUT…
· bash
#!/bin/sh # Uncomment for your system to install the samba component #sudo apt-get install smbfs #(for Ubuntu) #sudo zypper install smbfs # (for openSUSE) #sudo yum install smbfs # (for CentOS) mkdir /media/sharedisk cp "/etc/fstab" "/etc/fstab.default" echo "//192.168.4.224/sharedisk /media/sharedisk cifs credentials=/root/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777,_netdev 0…
· bash
#!bin/bash i=0 diapazon=19 while [ $i -lt 255 ] do i=$[$i+1] K_file2="ifcfg-eth1:"$diapazon$i echo 'DEVICE=eth1:'$diapazon$i>$K_file2 echo 'IPADDR=192.168.'$diapazon'.'$i>>$K_file2 echo 'HWADDR=xx:xx:xx:xx:xx:xx'>>$K_file2 echo 'ONBOOT=yes'>>$K_file2 echo $K_file ' created' done
· bash
#!/bin/bash # replication monitoring script # and sending me an email in case of an issue # Script written by Dmitry Lomaka, Kyiv 2012 # required: yum install mailx # set up the master server's crontab to run once per hour # crontab -e ## 00 *…
· bash
Nested if Statements Inside an if statement, you can use another if statement. You can use as many levels of nesting as you can handle. In this example, leap years are checked:
· bash
The for-in Loop The for-in statement is designed to sequentially access values listed in a list. Each value in the list is assigned to a variable in turn. The syntax is as follows: Let's consider a small example: After executing the example, a line with its number will appear in the first 5 virtual consoles (terminals). In...
Essential cookies are always active. Statistics, external fonts and marketing load only with your consent (GDPR).
Language, session, consent storage
Anonymous visit analytics
Google Fonts and other CDNs
Advertising pixels and trackers
Scan to open this site quickly on your phone