FILE transfer and sync update

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# download files/apps: wget [args] [URL]

# continue the paused downloading mission: wget -c [mission_name]

# scp (Secure copy) copy file from one computer to another
# scp source_file destination_file
# file can be represented with user@ip:file_name
[mo@mos-computer ~]$ scp name.txt root@192.168.0.120:/root
name.txt 100% 12 6.5KB/s 00:00

# copy from another computer to this computer:
[mo@mos-computer ~]$ scp root@192.168.0.120:/root/name.txt file_changed_name.txt
name.txt 100% 12 6.9KB/s 00:00

[mo@mos-computer ~]$ ls
... file_changed_name.txt

# change the port number: scp -p [port_num]

# ftp & sftp: download from public/private FTP server

# -p means passive mode
[mo@mos-computer ~]$ ftp -p ftp.fr.debian.org
Trying 212.27.32.66...
Connected to ftp.fr.debian.org (212.27.32.66).
220 Welcome to french Debian FTP server
Name (ftp.fr.debian.org:mo): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls
227 Entering Passive Mode (212,27,32,66,88,25).
150 Here comes the directory listing.
drwxr-xr-x 9 1000 1000 4096 Mar 10 08:25 debian
drwxr-xr-x 8 1000 1000 4096 Mar 01 2015 debian-amd64
drwxr-sr-x 5 1000 1000 102 Mar 13 2016 debian-backports
drwxr-xr-x 6 1000 1000 143 Mar 10 04:00 debian-non-US
drwxr-xr-x 7 1000 1000 142 Mar 09 21:22 debian-security
drwxr-sr-x 5 1000 1000 138 Nov 01 2011 debian-volatile
drwxr-xr-x 2 1000 1000 6 Mar 09 23:00 tmp
226 Directory send OK.
ftp> pwd
257 "/"
ftp> cd debian
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (212,27,32,66,42,172).
150 Here comes the directory listing.
-rw-r--r-- 1 1000 1000 1190 Feb 06 09:19 README
-rw-r--r-- 1 1000 1000 1290 Jun 26 2010 README.CD-manufacture
-rw-r--r-- 1 1000 1000 2900 Feb 06 09:19 README.html
-rw-r--r-- 1 1000 1000 291 Mar 04 2017 README.mirrors.html
-rw-r--r-- 1 1000 1000 86 Mar 04 2017 README.mirrors.txt
drwxr-xr-x 19 1000 1000 4096 Feb 06 09:21 dists
drwxr-xr-x 4 1000 1000 4096 Mar 10 07:52 doc
-rw-r--r-- 1 1000 1000 205133 Mar 10 08:15 extrafiles
drwxr-xr-x 3 1000 1000 8192 Mar 10 08:10 indices
-rw-r--r-- 1 1000 1000 13533572 Mar 10 08:10 ls-lR.gz
drwxr-xr-x 5 1000 1000 62 Dec 19 2000 pool
drwxr-xr-x 4 1000 1000 67 Nov 17 2008 project
drwxr-xr-x 3 1000 1000 77 Oct 10 2012 tools
drwxr-xr-x 20 1000 1000 4096 Jul 07 2019 zzz-dists
226 Directory send OK.
# download the README file
ftp> get README
local: README remote: README
227 Entering Passive Mode (212,27,32,66,222,243).
150 Opening BINARY mode data connection for README (1190 bytes).
226 Transfer complete.
1190 bytes received in 1.71 secs (0.70 Kbytes/sec)
ftp> !ls
compression myFIle rar
Desktop name_sorted.txt rarlinux-x64-5.7.0.tar.gz
Documents name.txt README
Downloads newfile redirect
errors.log new_folder repeat.txt
file_changed_name.txt newly_created_file results.txt
file-copy.txt node Templates
grep_log nohup.out test
htop-2.2.0 number.txt unique.txt
htop-2.2.0.tar.gz output_find Videos
Music Pictures
myFile Public
# upload file
ftp> put name.txt
local: name.txt remote: name.txt
227 Entering Passive Mode (212,27,32,66,82,83).
550 Permission denied.
ftp>
# Ctrl d to exit
ftp> 221 Goodbye.

# sftp (secure) use -oProt to change the port
# rsync: remote synchronize, very useful in sync files on two devices
# -arv a: adding r:recursive v:verbose

# further reading: how to use rsync to write backup file...

Network Security

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# IPv4 and IPv6 addresses, hostname (www.), domainname(xxx.com), DNS
[root@mos-computer mo]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
13.229.188.59 github.com

# you can customize some hosts couples to access specific websites, this works for local network
[root@mos-computer mo]# whois github.com
Domain Name: GITHUB.COM
Registry Domain ID: 1264983250_DOMAIN_COM-VRSN
Registrar WHOIS Server: whois.markmonitor.com
Registrar URL: http://www.markmonitor.com
Updated Date: 2020-09-08T09:18:27Z
Creation Date: 2007-10-09T18:20:50Z
Registry Expiry Date: 2022-10-09T18:20:50Z
Registrar: MarkMonitor Inc.
Registrar IANA ID: 292
Registrar Abuse Contact Email: abusecomplaints@markmonitor.com
Registrar Abuse Contact Phone: +1.2083895740
Domain Status: clientDeleteProhibited https://icann.org/epp#clientDeleteProhibited
Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited
Domain Status: clientUpdateProhibited https://icann.org/epp#clientUpdateProhibited
Name Server: DNS1.P08.NSONE.NET
Name Server: DNS2.P08.NSONE.NET
Name Server: DNS3.P08.NSONE.NET
Name Server: DNS4.P08.NSONE.NET
Name Server: NS-1283.AWSDNS-32.ORG
Name Server: NS-1707.AWSDNS-21.CO.UK
Name Server: NS-421.AWSDNS-52.COM
Name Server: NS-520.AWSDNS-01.NET
DNSSEC: unsigned
URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/
>>> Last update of whois database: 2021-03-10T13:35:54Z <<<

For more information on Whois status codes, please visit https://icann.org/epp

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ON
LY .COM, .NET, .EDU domains and
Registrars.

# eth0 : wired network connections, ehthernet ,lo: Local loopback, wlan0: wireless connection.
# You may noticed that some of those names changed, that was because new CentOS version
# use 'systemd' to replace the 'initd' to guide the system. e.g. enp0s3 --> eth0

# Network Analysis
ifconfig interface state

# you can shutdown/ open some specific connection
[root@mos-computer mo]# ifconfig ens33 down
[root@mos-computer mo]# ping 192.168.0.120
connect: Network is unreachable
[root@mos-computer mo]# ifconfig ens33 up
[root@mos-computer mo]# ping 192.168.0.120
PING 192.168.0.120 (192.168.0.120) 56(84) bytes of data.
64 bytes from 192.168.0.120: icmp_seq=1 ttl=128 time=0.783 ms
64 bytes from 192.168.0.120: icmp_seq=2 ttl=128 time=0.691 ms
64 bytes from 192.168.0.120: icmp_seq=3 ttl=128 time=0.624 ms
64 bytes from 192.168.0.120: icmp_seq=4 ttl=128 time=0.703 ms
^C
--- 192.168.0.120 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3001ms
rtt min/avg/max/mdev = 0.624/0.700/0.783/0.059 ms

# Network data
[root@mos-computer mo]# netstat
# interface info: MTU : max transmute unit DRP: drop num OVR: drop because override ...
[root@mos-computer mo]# netstat -i
Kernel Interface table
Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33 1500 10287 0 0 0 2384 0 0 0 BMRU
lo 65536 39 0 0 0 39 0 0 0 LRU
virbr0 1500 0 0 0 0 0 0 0 0 BMU
# udp, tcp (and other protocol) data
[root@mos-computer mo]# netstat -uta
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 mos-computer:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 localhost:ipp 0.0.0.0:* LISTEN
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:ipp [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
udp 0 0 0.0.0.0:34360 0.0.0.0:*
udp 0 0 mos-computer:domain 0.0.0.0:*
udp 0 0 0.0.0.0:bootps 0.0.0.0:*
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 0.0.0.0:sunrpc 0.0.0.0:*
udp 0 0 localhost:323 0.0.0.0:*
udp 0 0 0.0.0.0:929 0.0.0.0:*
udp 0 0 0.0.0.0:mdns 0.0.0.0:*
udp6 0 0 [::]:sunrpc [::]:*
udp6 0 0 localhost:323 [::]:*
udp6 0 0 [::]:929 [::]:*
# only UDP info
[root@mos-computer mo]# netstat -ua
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
udp 0 0 0.0.0.0:34360 0.0.0.0:*
udp 0 0 mos-computer:domain 0.0.0.0:*
udp 0 0 0.0.0.0:bootps 0.0.0.0:*
udp 0 0 0.0.0.0:bootpc 0.0.0.0:*
udp 0 0 0.0.0.0:sunrpc 0.0.0.0:*
udp 0 0 localhost:323 0.0.0.0:*
udp 0 0 0.0.0.0:929 0.0.0.0:*
udp 0 0 0.0.0.0:mdns 0.0.0.0:*
udp6 0 0 [::]:sunrpc [::]:*
udp6 0 0 localhost:323 [::]:*
udp6 0 0 [::]:929 [::]:*

# Port: 80 for HTTP, 21 for FTP, 110 for POP3
# LISTEN connection
[root@mos-computer mo]# netstat -lt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 mos-computer:domain 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:ssh 0.0.0.0:* LISTEN
tcp 0 0 localhost:ipp 0.0.0.0:* LISTEN
tcp 0 0 localhost:smtp 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:sunrpc 0.0.0.0:* LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
tcp6 0 0 localhost:ipp [::]:* LISTEN
tcp6 0 0 localhost:smtp [::]:* LISTEN
tcp6 0 0 [::]:sunrpc [::]:* LISTEN
# Summary
[root@mos-computer mo]# netstat -s
Ip:
2496 total packets received
0 forwarded
0 incoming packets discarded
2308 incoming packets delivered
2343 requests sent out
8 outgoing packets dropped
71 dropped because of missing route
Icmp:
23 ICMP messages received
0 input ICMP message failed.
ICMP input histogram:
destination unreachable: 18
echo requests: 1
echo replies: 4
24 ICMP messages sent
0 ICMP messages failed
ICMP output histogram:
destination unreachable: 19
echo request: 4
echo replies: 1
IcmpMsg:
InType0: 4
InType3: 18
InType8: 1
OutType0: 1
OutType3: 19
OutType8: 4
Tcp:
24 active connections openings
0 passive connection openings
0 failed connection attempts
2 connection resets received
0 connections established
2131 segments received
2072 segments send out
3 segments retransmited
0 bad segments received.
5 resets sent
Udp:
136 packets received
18 packets to unknown port received.
0 packet receive errors
241 packets sent
0 receive buffer errors
0 send buffer errors
UdpLite:
TcpExt:
16 TCP sockets finished time wait in fast timer
15 delayed acks sent
Quick ack mode was activated 1 times
26 packets directly queued to recvmsg prequeue.
6737 bytes directly received in process context from prequeue
1705 packet headers predicted
21 packets header predicted and directly queued to user
26 acknowledgments not containing data payload received
79 predicted acknowledgments
3 congestion windows recovered without slow start after partial ack
3 other TCP timeouts
2 connections reset due to early user close
TCPRcvCoalesce: 43
TCPAutoCorking: 4
TCPSynRetrans: 3
TCPOrigDataSent: 107
IpExt:
InNoRoutes: 4
InMcastPkts: 141
OutMcastPkts: 44
InBcastPkts: 42
InOctets: 13875424
OutOctets: 123651
InMcastOctets: 14149
OutMcastOctets: 8425
InBcastOctets: 4182
InNoECTPkts: 10306