7. Network Commands
7.1 send message to user to Ctr+d save end
(1) Write command
Command name |
Write |
Command path |
/user/bin/write |
Execute permissions |
All Users |
Grammar |
Write < user name > |
(2) Precautions
① when the input is wrong, you can press the ctr+ backspace key to delete the character (not the backspace)
② can only be sent to online users
(3) Application example: $write TestUser then enter the content, and finally press Ctrl+d to send and end
7.2 send a broadcast message
(1) Wall command
Command name |
Wall (English intent: Write All) |
Command path |
/user/bin/wall |
Execute permissions |
All Users |
Grammar |
Wall [message] |
(2) Precautions
① will receive the message when it is sent
② can only be sent to online users
(3) Application example: $wall I Love you!
7.3 Test network Connectivity
(1) Ping command
Command name |
Ping |
Command path |
/bin/ping |
Execute permissions |
All Users |
Grammar |
ping [options] IP address -C: Specify the number of times to send |
(2) Application example: $ping-C 4 192.168.32.100//Only PING4 times
7.4 Viewing and setting network card information
(1) Ifconfig command
Command name |
Ifconfig (literal:interfAce configure) |
Command path |
/sbin/ifconfig |
Execute permissions |
Root |
Grammar |
Ifconfig NIC name IP address |
(2) Application examples:
① View network card information: #ifconfig
② changing the NIC IP, mask
A. Immediate effect: #ifconfig192.168. 32.100 255.255. 255.0 B. Restart effective: #vim /etc/sysconfig/network-scripts/ifcfg-eth0 bootproto=static ipaddr=192.168 . 32.100 NETMASK=255.255. 255.0 Restart network card: #services Network restart
③ Modifying the default gateway
192.168. 32.1 /etc/sysconfig/network GATEWAY=192.168. 32.1
④ modifying DNS
Restart effective: vim/etc/resolv.conf 202.96. 134.133
7.5 lists user information currently logged into the system with the past
(1) Last Order
Command name |
Last |
Command path |
/usr/bin/last |
Execute permissions |
All Users |
Grammar |
Last |
(2) Application Example: $last
7.6 check when a user last logged in
(1) Lastlog command
Command name |
Lastlog |
Command path |
/usr/bin/lastlog |
Execute permissions |
All Users |
Grammar |
Lastlog |
(2) Application examples:
① #lastlog
② viewing login information for a specified user
$lastlog –u 502//502 of which represents the UID of a user (available $id testuser view)
7.7 show the path between packets to the host
(1) traceroute command
Command name |
Traceroute |
Command path |
/bin/traceroute |
Execute permissions |
All Users |
Grammar |
Traceroutera |
(2) Application examples:
①# traceroute-i www.baidu.com//When using NAT mode to surf the internet
②# traceroute www.baidu.com//using bridge mode when surfing the Internet
7.8 Display Network-related information
(1) Netstat command
Command name |
Netstat |
Command path |
/bin/netstat |
Execute permissions |
All Users |
Grammar |
netstat [options] -T:TCP protocol -U:UDP protocol -L: Monitor -R: Routing -N: Display IP and port number |
(2) Application examples:
① View Native Listener port: #netstat-tlun
② View all network connections for this computer: #netstat –an
③ View Native routing table: #netstat –rn
7.9 mount Command
(1) Mount command
Command name |
Mount |
Command path |
/bin/mount |
Execute permissions |
All Users |
Grammar |
Mount [-T file system ] device file name mount point |
(2) Application examples:
① Mount Optical Drive:
mkdir /tmp/Mount-t iso9660/dev/sr0/tmp/cdrom (where,- T iso9660 can also be omitted)ls /tmp/cdrom
② unmount Optical drive:#umount/dev/sr0 (/dev/sr0 is the file name of the optical drive device )
3rd Linux Common Commands (5) _ Network command