Linux basic operation commands

Source: Internet
Author: User
Tags reverse dns

#------------------------
# View Server Information
#------------------------

1. view the version and Kernel
Cat/etc/issue

2. View cpu, mem
Grep "model name"/proc/cpuinfo
Grep MemTotal/proc/meminfo
Free

3. The number of memory slots, the number of slots used, the size of each memory, and the size of memory used
Dmidecode | grep-P-A 5 "Memorys + Device" | grep Size | grep-v Range

Size: 2048 MB
Size: No Module Installed
Size: No Module Installed
Size: No Module Installed

4. Maximum memory capacity supported
Dmidecode | grep-P 'maximums + Capacity'
Maximum Capacity: 64 GB


5. view the memory frequency
Dmidecode | grep-A16 "Memory Device"
Dmidecode | grep-A16 "Memory Device" | grep 'speed'

6. view the number of operating system digits
Getconf LONG_BIT

#------------------------
# Basic settings
#------------------------

# Set the Host Name
Vi/etc/sysconfig/network
HOSTNAME = centos
Reboot system...

# Ifconfig eth0 192.168.4.222 netmask 255.255.255.0
# Ifconfig eth0: 0 10.0.0.1 netmask 255.0.0.0
# Ifconfig eth0 down
# Ifconfig eth0 on

# Changing the nic mac address
Ifconfig eth0 hw ether 00: 37: A6: C4: 68: E3

# Set the gateway using the route command
Route add default gw 192.168.4.3
Route del default gw 192.168.4.1

# View port information
Netstat-atn

# Viewing route tables
Netstat-r

# Viewing network interface status
Netstat-I

# View who occupies port 80
Lsof-I: 80

-----------------------

# Adding Environment Variables

Echo "export PATH = $ PATH:/usr/local/mysql/bin">/etc/profile // permanently modified
Source/etc/profile

-----------------------

The system defaults to the US east time, and changes the Linux time zone to the UTC + 8 zone.
Cp-f/usr/share/zoneinfo/Asia/Shanghai/etc/localtime
Date-s "20090101 ″
Clock-w or hwclock
-----------------------

#------------------------
# Linux traffic monitoring
#------------------------
Iftop Tool

Purpose: monitors the network status and bandwidth used by each ip address in real time.

Run the command (must be root)
Monitor network card Traffic of eth1
# Iftop-I eth1

Traffic is displayed in bytes (by default, bits ):
$ Iftop-B

The IP address is displayed directly without reverse DNS resolution:
$ Iftop-n

The connection port number is displayed directly, but the service name is not displayed:
$ Iftop-N

Display inbound and outbound traffic of a CIDR Block
$ Iftop-F 192.168.1.0/24 or 192.168.1.0/255.255.255.0

For other parameters, see iftop-h.

When you enter the iftop screen, you can press p to switch whether to display the connection port, n to switch to display the IP address or the domain name of the host, N to switch to display the connection port code or name, and p to suspend display, switch B to check whether the display bar is displayed. Switch B to calculate the average traffic in a few seconds. Other buttons can be clicked h to view the description.
Set the region ~ /. Iftoprc. You can refer to the info page of iftop if you set the limit method.

Nload
Purpose: monitors the network status and bandwidth used by each ip address in real time (nonsense)
The default nload is the eth0 Nic. If you want to monitor the traffic of the eth1 Nic
# Nload eth1

By default, nload is divided into two parts: the upper part is: Incoming, that is, the traffic into the NIC, the lower part is: Outgoing, that is, the traffic from this Nic, each part includes the current traffic (Curr), average traffic (Avg), minimum traffic (Min), maximum traffic (Max), and total traffic (Ttl, it looks quite intuitive.
In addition, you can also define the unit of Traffic Value display.
# Nload-help
You can see the specific parameters.

View average network traffic

The following script can monitor the average traffic of your network. You can set the time.
#! /Bin/bash
Echo-n "which nic ?"
Read eth
Echo "the nic is" $ eth
Echo-n "how much seconds :"
Read sec
Echo "duration is" $ sec "seconds, wait please ..."
Infirst = $ (awk '/' $ eth '/{print $1}'/proc/net/dev | sed's/'$ eth '://')
Outfirst = $ (awk '/' $ eth '/{print $10}'/proc/net/dev)
Sumfirst = $ ($ infirst + $ outfirst ))
Sleep $ sec "s"
Inend = $ (awk '/' $ eth '/{print $1}'/proc/net/dev | sed's/'$ eth '://')
Outend = $ (awk '/' $ eth '/{print $10}'/proc/net/dev)
Sumend = $ ($ inend + $ outend ))
Sum = $ ($ sumend-$ sumfirst ))
Echo $ sec "seconds total:" $ sum "bytes"
Aver = $ ($ sum/$ sec ))
Echo "avrage:" $ aver "bytes/sec"

 

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.