Network commands in linux

Keywords: Linux network yum ftp DBus

write

explain

Command name: write
 Command path / usr/bin/write
 Execute permission: all users
 Function Description: send information to the user, and save with Ctrl+D

grammar

Write < user name >

Example

# Send a message to tenentity
write eternity

[root@izm5e2q95pbpe1hh0kkwoiz ~]# write eternity
write: eternity is logged in more than once; writing to pts/4
hello eternity!!!

[eternity@izm5e2q95pbpe1hh0kkwoiz ~]$ 
Message from root@izm5e2q95pbpe1hh0kkwoiz on pts/0 at 15:32 ...
hello eternity!!!EOF

wall

explain

Command name: wall
 write all
 Command path / usr/bin/wall
 Execute permission: all users
 Function Description: send broadcast information

grammar

vall [message]

Example

# Send broadcast message (it will be received by the user, only the current user can receive it)
wall eternity is a good man!

[root@izm5e2q95pbpe1hh0kkwoiz ~]# wall eternity is a good man!
[root@izm5e2q95pbpe1hh0kkwoiz ~]# 
Broadcast message from root@izm5e2q95pbpe1hh0kkwoiz (pts/0) (Thu Dec  5 15:36:18 2019):

eternity is a good man!

[eternity@izm5e2q95pbpe1hh0kkwoiz ~]$ 
Broadcast message from root@izm5e2q95pbpe1hh0kkwoiz (pts/0) (Thu Dec  5 15:36:18 2019):

eternity is a good man!

ping

explain

Command name: write
 Command path / bin/ping
 Execute permission: all users
 Function Description: test network connectivity

grammar

ping option IP address
    -c specify the number of times to send

Example

# Ping 118.190.208.1 (will ping all the time, press ctrl+c to end)
ping 118.190.208.1

[root@izm5e2q95pbpe1hh0kkwoiz ~]# ping 118.190.208.1
PING 118.190.208.1 (118.190.208.1) 56(84) bytes of data.
64 bytes from 118.190.208.1: icmp_seq=1 ttl=64 time=0.201 ms
64 bytes from 118.190.208.1: icmp_seq=2 ttl=64 time=0.207 ms
64 bytes from 118.190.208.1: icmp_seq=3 ttl=64 time=0.161 ms
64 bytes from 118.190.208.1: icmp_seq=4 ttl=64 time=0.197 ms
--- 118.190.208.1 ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7032ms
rtt min/avg/max/mdev = 0.161/0.189/0.218/0.023 ms


# # Ping - C 4 118.190.208.1 (end of Ping 4 times)
ping 118.190.208.1

ifconfig

explain

Command name: ifconfig
 Command path / sbin/ifconfig
 Execution permission: root
 Function Description: view and set network card information

grammar

ifconfig NIC name IP address

Example

# View current computer network card information
ifconfig

# Temporary change of ip address
ifconfig eth0 192.168.1.1

mail

explain

Command name: mail
 Command path / bin/mail
 Execute permission: all users
 Function Description: View send email

grammar

mail [user name]

mail command does not exist

yum -y install mailx sendmail

Example

# Send mail to root (ctrl+D)
mail root

[root@izm5e2q95pbpe1hh0kkwoiz ~]# mail root
Subject: test
hello root!!!!
EOT


# View mail
mail

last

explain

Command name: mail
 Command path / usr/bin/last
 Execute permission: all users
 Function Description: list the current and past login user information

grammar

last

Example

# List login information
last

[root@izm5e2q95pbpe1hh0kkwoiz ~]# last
eternity pts/5        123.235.166.172  Thu Dec  5 15:32   still logged in   
eternity pts/4        123.235.166.172  Thu Dec  5 15:32   still logged in   
root     pts/3        123.235.166.172  Thu Dec  5 15:32   still logged in   
root     pts/2        123.235.166.172  Thu Dec  5 15:32   still logged in   
root     pts/3        123.235.166.172  Thu Dec  5 15:32 - 15:32  (00:00)    
root     pts/2        123.235.166.172  Thu Dec  5 15:32 - 15:32  (00:00) 

lastlog

explain

Command name: lastlog
 Command path / usr/bin/lastlog
 Execute permission: all users
 Function Description: check the last login time of a specific user

grammar

lastlog options [- u] [uid]
    -u user's uid

Example

# View last login time
lastlog

[root@izm5e2q95pbpe1hh0kkwoiz ~]# lastlog
Username         Port     From             Latest
root             pts/3    123.235.166.172  Thu Dec  5 15:32:14 +0800 2019
bin                                        **Never logged in**
daemon                                     **Never logged in**
adm                                        **Never logged in**
lp                                         **Never logged in**
sync                                       **Never logged in**
shutdown                                   **Never logged in**
halt                                       **Never logged in**
mail                                       **Never logged in**
operator                                   **Never logged in**
games                                      **Never logged in**
ftp                                        **Never logged in**
nobody                                     **Never logged in**
systemd-network                            **Never logged in**
dbus                                       **Never logged in**
polkitd                                    **Never logged in**
postfix                                    **Never logged in**
chrony                                     **Never logged in**
sshd                                       **Never logged in**
ntp                                        **Never logged in**
tcpdump                                    **Never logged in**
nscd                                       **Never logged in**
mysql                                      **Never logged in**
www                                        **Never logged in**
rabbitmq                                   **Never logged in**
eternity         pts/5    123.235.166.172  Thu Dec  5 15:32:17 +0800 2019
saslauth                                   **Never logged in**
mailnull                                   **Never logged in**
smmsp                                      **Never logged in**


# View the last access of the specified user
lastlog -u 502

traceroute

explain

Command name: mail
 Command path / bin/traceroute
 Execute permission: all users
 Function Description: display the path from packet to host

grammar

traceroute

traceroute command does not exist

yum -y install traceroute

Example

# Detect the path to www.baidu.com
traceroute www.baidu.com

[root@izm5e2q95pbpe1hh0kkwoiz ~]# traceroute www.baidu.com
traceroute to www.baidu.com (180.101.49.11), 30 hops max, 60 byte packets
 1  * * *
 2  11.219.4.81 (11.219.4.81)  5.632 ms  5.931 ms  6.313 ms
 3  11.219.4.62 (11.219.4.62)  4.164 ms * 11.219.4.54 (11.219.4.54)  4.114 ms
 4  11.219.68.2 (11.219.68.2)  4.848 ms 11.219.68.18 (11.219.68.18)  4.849 ms 11.219.68.2 (11.219.68.2)  4.853 ms
 5  103.52.86.106 (103.52.86.106)  1.139 ms 103.52.86.118 (103.52.86.118)  0.536 ms 103.41.143.65 (103.41.143.65)  1.240 ms
 6  103.41.143.118 (103.41.143.118)  1.165 ms 116.251.113.221 (116.251.113.221)  0.961 ms 103.41.143.58 (103.41.143.58)  0.963 ms
 7  150.138.130.121 (150.138.130.121)  1.618 ms 150.138.130.117 (150.138.130.117)  0.947 ms  0.641 ms
 8  150.138.128.161 (150.138.128.161)  8.503 ms 150.138.128.41 (150.138.128.41)  1.928 ms 150.138.128.157 (150.138.128.157)  1.594 ms
 9  202.97.19.137 (202.97.19.137)  15.099 ms 202.97.30.129 (202.97.30.129)  13.069 ms 202.97.96.205 (202.97.96.205)  16.943 ms
10  58.213.94.102 (58.213.94.102)  18.576 ms 58.213.94.98 (58.213.94.98)  17.861 ms 58.213.95.102 (58.213.95.102)  17.436 ms
11  * * 58.213.94.86 (58.213.94.86)  18.402 ms
12  58.213.96.94 (58.213.96.94)  21.612 ms 58.213.96.78 (58.213.96.78)  17.852 ms 58.213.96.94 (58.213.96.94)  22.174 ms
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *

netstat

explain

Command name: netstat
 Command path: / bin/netstat
 Execute permission: all users
 Function Description: display network related information

grammar

netstat [options]
    -TCP protocol (transmission control protocol)
    -u UDP protocol (User Datagram Protocol)
    -l monitoring
    -r routing
    -n display IP address and port number

Example

# View the port the local monitor is listening to
netstat -tlun

# View all network connections on this computer
netstat -an

# View local routing table
netstat -rn

setup

explain

Command name: setup
 Command path / usr/bin/setup
 Execute permission: all users
 Function Description: configure network

grammar

setup

Example

Only the redhat series
 Set permanent

mount

explain

Command name: mount
 Command path: / bin/mount
 Execute permission: all users
 Function Description: Mount command

grammar

mount [-t file system] device filename mount point

Example

# Create mount directory first
mkdir /mnt/cdrom
# Mounted CD
mount -t ios9660 /dev/sr0 /mnt/cdrom
    -t ios9660  CD file system(Changeless,Omission)
    /dev/sr0    Device file name(Changeless,System specified)
    /mnt/cdrom  Mount point(Mount directory)
# It is also possible to omit - t IOS 9660
mount /dev/sr0 /mnt/cdrom
    
# Access the data under the CD (that is, the mount directory)
cd /mnt/cdrom
ls

# Uninstall the disc (you must be outside the disc mount directory to uninstall)
umount /dev/sr0

[root@izm5e2q95pbpe1hh0kkwoiz ~]# ll /dev/cdrom
lrwxrwxrwx 1 root root 3 Aug 14  2018 /dev/cdrom -> sr0
    /dev/cdrom It's a soft link that points to sr0

Posted by pdpullmn612 on Wed, 19 Feb 2020 04:49:04 -0800