Basic script attempt

Try the script for the first time. Go by and correct it!

syeteminfo system profile command

    #Descrition:show system information
    echo "OS version is:`cat /etc/redhat-release`"
    echo "kernel version is:`uname -r`"
    echo "CPU type :`lscpu|grep 'Model name'|tr -s ' ' |cut -d: -f2`"
    echo "`cat /proc/meminfo |head -n1`"
    echo "`lsblk |grep '^sd'|tr -s ' ' |cut -d' ' -f1,4`"
    echo "My username is $USER"
    echo "My hostname is `hostname`"
    echo "NETwork IP:`ifconfig ens33|grep -w 'inet'|grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'|head -n1`"

After execution, the machine configuration information is displayed.       

Create apache user command

    #Description:Useradd-apache u-80 g-80 home-/var/www shell-/sbin/nologin  
    groupadd -g 80 apache
    useradd -u 80 -g apache -s /sbin/nologin -d /var/www apache
    echo "User apache is created"  
    mkdir -pv /var/www
    chown -R apache:apache /var/www    
    echo "/var/www is ready!"

After execution, you can create user apache according to the above requirements.

Change command line color

    #Description:change root's COMMOND line color (33=yellow)
    cat >> /root/.bash_profile <<EOF
    PS1="\[\e[1;33m\][\u@\h \W]\\$\[\e[0m\]"

After execution, the command line color of root will turn yellow.     

Make a file to add the execution command

    #Description:Add execution permissions to the file
    chmod +x $1
    echo $1 can be excute

To execute a command, simply enter the file name followed by the command to add permissions.     


Make a quick file to Dadda's computer

    #Description:connect Handsome Dadda'computer
    scp $* Dadda@

The execution can be transferred to Dadda host by entering the name followed by the file name.   

Create any user with a password of Dadda and the password modification process is not seen. Force to change the password the next time you log in

    #Desscription:Create the user and change the password the next time use it.
    #create $1
    useradd $1
    echo $1 create success!
    #for $1 create passwd   --No Display
    echo dadda | passwd --stdin $1 &>/dev/null
    #change the password the next time No Display (or:chage -d filename)
    passwd -e $1 &>/dev/null
    echo $1 password is reset!

To execute, just enter the command followed by the user name you want to create, and create successfully.    

Fill in basic information automatically when creating script

    cat >$1 <<EOF
    #Author:                  $name
    #QQ:                      $qq
    #Date:                    `date +%F`
    #FileName:                $1
    #Description:             The script test
    #Copyright(C):            2018 all rights reserved

    chmod +x $1
    vim + $1

When executing, you only need to enter the command followed by the name of the script file to be created and create it successfully.


Tags: Apache network shell vim

Posted on Sun, 12 Jan 2020 12:44:42 -0500 by amedhussaini