-
Execute the script to check whether the user (DUSHAN) exists, prompt the user to exist and exit. If there is no automatic creation and prompt that the creation is successful, the password is set to 123456
#!/bin/bash #************************************************************************* #Author: Dadda_Du #QQ: 316722220 #Date: 2018-08-04 #FileName: idname_60.sh #URL: https://blog.csdn.net/weixin_40001704 #Description: command idname test user exist? #Copyright(C): 2018 all rights reserved #************************************************************************* name=dushan id $name &>/dev/null && { echo $name is exist!;exit; } || { useradd $name ; echo $name is create!; } && ( `echo 123456 | passwd --stdin $name &>/dev/null` )
(Note: pay attention to the space between each word in brackets; mailbox path / var/spool/mail / user name; home directory path / home / user name)
-
After this pin is executed, the disk will send a broadcast greater than 66% and report the current usage of the index at the same time
#!/bin/bash #************************************************************************* #Author: Dadda_Du #QQ: 316722220 #Date: 2018-08-04 #FileName: checkdisk_60.sh #URL: https://blog.csdn.net/weixin_40001704 #Description: check the disk full? #Copyright(C): 2018 all rights reserved #************************************************************************* Diskuse=`df|grep /dev/sd|egrep -o '[0-9]{1,3}%'|egrep -o '[0-9]{1,3}'|sort -nr|head -n1` InodeNum=`df -i|egrep -o '[0-9]{1,3}%'|egrep -o '[0-9]{1,3}'|sort -nr|head -n1` n=1 [ $Diskuse -gt $n ] && wall "Disk use >(gt) $n%" [ $InodeNum -eq $n ] && wall "Inode use eq $n%"
(Note: spaces between brackets and contents, double quotation marks for variables in brackets to avoid errors)
-
Judge the system version after executing this script
#!/bin/bash #************************************************************************* #Author: Dadda_Du #QQ: 316722220 #Date: 2018-08-04 #FileName: checkversion_60.sh #URL: https://blog.csdn.net/weixin_40001704 #Description: Checkversion 6 or 7? #Copyright(C): 2018 all rights reserved #************************************************************************* ver=` egrep -o "[0-9]+" /etc/redhat-release|head -n1` [ "$ver" -eq 7 ] && echo "Centos7" || echo "Centos6"
-
After executing this script, you can judge whether the typing (191.191.111.111) is a legal IP
#!/bin/bash #************************************************************************* #Author: Dadda_Du #QQ: 316722220 #Date: 2018-08-04 #FileName: checkip_60.sh #URL: https://blog.csdn.net/weixin_40001704 #Description: Legal IP? #Copyright(C): 2018 all rights reserved #************************************************************************* IP=191.191.111.111 [[ "$IP" =~ ^(([1-9]?[0-9]|1[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){3}([1-9]?[0-9]|1[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$ ]] && echo "The $IP is legal!" || echo "The $IP is illegal!!"
(Note: the variables in brackets should be enclosed in double quotes, and the judgment content after regular expressions should not be enclosed in double quotes.)