Lao Li share: "Linux shell Script Raiders" Essentials (VI)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.