1. Print Network interface list
[touch_more]# ifconfig | cut-c-10 | Tr-d ' | Tr-s ' \ n '
Eth0
Lo
www.qixoo.qixoo.com//cut-c-10; The first 10 characters of the output;
Tr-d "; Delete all spaces;
Tr-s ' \ n '; Compress repeated line breaks
2. View Name server
[touch_more]# cat/etc/resolv.conf
# Generated by NetworkManager
Domain Localdomain
Search Localdomain
NameServer 192.168.119.2
3. DNS Lookup
[touch_more]# nslookup www.csdn.net
server:192.168.119.2
address:192.168.119.2#53
Non-authoritative Answer:
Www.csdn.net canonical name = www.csdn.net.aqb.so.
Name:www.csdn.net.aqb.so
address:14.17.69.22
4. Enumerate all the active hosts of the same network segment in the LAN
[program_test]# Cat list_active_hosts.sh
#!/bin/bash
For IP in 192.168.119. {1..255};
Do
Ping $ip-C 2 &>/dev/null;
If [$?-eq 0];
Then
Echo $ip is active!
Fi
Done
[program_test]#./list_active_hosts.sh
192.168.119.1 is active!
192.168.119.2 is active!
5. System Running time monitoring
<pre name= "code" class= "plain" style= "FONT-SIZE:14PX;" >[program_test]# Cat ssh_test.sh
#!/bin/bash
ip_list= "192.168.119.1 192.168.119.2 192.168.119.128"
User= "Yxy"
For IP in $IP _list;
Do
utime=$ (SSH [email protected] $ip Uptime | awk ' {print $} ')
echo $ip Uptime: $utime
Done
Lao Li share: "Linux shell Script Raiders" Essentials (VI)