Experimental requirements:
1. Write a login welcome script for root user, report the number of processes in the current host, the number of logged in users, and the disk usage of the root file system.
2, write three scripts: Start,stop and status, used to start, stop various system services
Experimental steps:
[Email protected] ~]# VI welcome.sh
#!/bin/bash
# This is test.by Shengjie
p= ' ps aux | Wc-l '//Set Variable P
echo "Running Processes: $p"
U= ' who | Wc-l '//Set Variable U
echo "Login Users: $u"
D= ' Df-ht | grep "/$" | awk ' {print $6} '//Set Variable D
echo "Usage Of/filesystem: $d"
: Wq Save Exit
[Email protected] ~]# Vi. bash_profile
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/D2/wKiom1RxbvCxK1RzAAEdmZKD-Vo521.jpg "title=" Shell.jpg "alt=" Wkiom1rxbvcxk1rzaaedmzkd-vo521.jpg "/>
Restart the system, you can see the following information
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/53/D0/wKioL1Rxb6-jnrUCAAEGd5R-nUU616.jpg "title=" Shell2.jpg "alt=" Wkiol1rxb6-jnrucaaegd5r-nuu616.jpg "/>
[Email protected] ~]# echo $PATH
/usr/lib/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[Email protected] ~]# Cd/bin
[Email protected] bin]# VI start.sh
#!/bin/bash
# This is test
Service start//$1 is the position variable, call the content after start, if start Crond, then service Crond start
: Wq
[[email protected] bin]# alias start= ' start.sh '
Take Crond as an example, run start Crond (if prompted without permission, you need to switch to the bin directory to add execution permissions to start.sh: chmod +x/bin/start.sh)
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/53/D2/wKiom1RxcdiAm6r8AABJEe_Czok191.jpg "title=" Shell3.jpg "alt=" Wkiom1rxcdiam6r8aabjee_czok191.jpg "/>
Stop and status with start, modify the shell script.
This article is from the "Network growth path of the female kicked" blog, please make sure to keep this source http://shengjie.blog.51cto.com/8734352/1581638
Two simple shell scripts (about startup and service)