[root@bogon tmp]# vim /tmp/profile
if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmunge if [ -n "${BASH_VERSION-}" ] ; then if [ -f /etc/bashrc ] ; then #Bash login shells run only /etc/profile #Bash non-login shells run only /etc/bashrc #Check for double sourcing is done in /etc/bashrc. . /etc/bashrc fi fi :%s/^[[:blank:]]\+//g
if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmunge if [ -n "${BASH_VERSION-}" ] ; then if [ -f /etc/bashrc ] ; then # Bash login shells run only /etc/profile # Bash non-login shells run only /etc/bashrc # Check for double sourcing is done in /etc/bashrc. . /etc/bashrc fi fi
[root@bogon tmp]# vim /etc/vimrc
set ts=4 set expandtab set autoindent
:wq [root@bogon tmp]#source /etc/vimrc
[root@bogon data]# cat /data/createuser.sh #!/bin/bash read -p "please input username:" USERNAME if `id $USERNAME &> /dev/null`;then echo "username is exited,userid is:`id $USERNAME`" else `useradd $USERNAME &>/dev/null` echo "username is created,userid is:`id $USERNAME`" fi [root@bogon data]# ./createuser.sh please input username:zhang username is created,userid is:uid=1003(zhang) gid=1003(zhang) groups=1003(zhang) [root@bogon data]# ./createuser.sh please input username:wang username is exited,userid is:uid=1002(wang) gid=1002(wang) groups=1002(wang)
[root@bogon data]# cat /data/systeminfo.sh #!/bin/bash echo "hostname is:" echo `hostname` echo "IPv4 is:" echo `ifconfig ens33 |tr -s ' ' :|cut -d: -f3 |head -n 2 |tail -n 1` echo "os is:" echo `cat /etc/redhat-release` echo "kernel is:" echo `uname -r` echo "CPU is" echo `lscpu|head -n13 |tail -n1` echo "MEM is:" echo `free -h |tr -s " " : |cut -d: -f2 |head -n2 |tail -n1` echo "disk is:" echo `lsblk|tr -s " " : |cut -d: -f5 |head -n2 |tail -n1` [root@bogon data]#chmod a+x /data/systeminfo.sh [root@bogon data]# ./systeminfo.sh hostname is: bogon IPv4 is: 10.0.0.201 os is: CentOS Linux release 8.3.2011 kernel is: 4.18.0-240.el8.x86_64 CPU is Model name: Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz MEM is: 1.7Gi disk is: 200G
[root@bogon data]# cat /data/disk.sh #!/bin/bash echo "disk use max:`df -h |grep "^/dev/s"|tr -s " " %| cut -d% -f5| sort -rn |head -n1`" [root@bogon data]# chmod a+x /data/disk.sh [root@bogon data]# ./disk.sh disk use max:24