medium level Linux commands
1) SSH & netstat
C:\Users\51638>ssh -p 22 root@8.137.109.109
Welcome to Alibaba Cloud Elastic Compute Service !
Updates Information Summary: available
50 Security notice(s)
12 Important Security notice(s)
30 Moderate Security notice(s)
8 Low Security notice(s)
Run "dnf upgrade-minimal --security" to apply all updates.More details please refer to:
https://help.aliyun.com/document_detail/416274.html
Last login: Wed Aug 14 14:04:06 2024 from 36.113.32.98
[root@iZ2vc5lqzt23aweti4j777Z ~]# netstat -tuln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:20048 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:38833 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:56379 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:2049 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:42915 0.0.0.0:* LISTEN
tcp6 0 0 :::5355 :::* LISTEN
tcp6 0 0 :::111 :::* LISTEN
tcp6 0 0 :::20048 :::* LISTEN
tcp6 0 0 :::46519 :::* LISTEN
tcp6 0 0 :::2049 :::* LISTEN
tcp6 0 0 :::58695 :::* LISTEN
udp 0 0 127.0.0.1:323 0.0.0.0:*
udp 0 0 0.0.0.0:20048 0.0.0.0:*
udp 0 0 127.0.0.1:659 0.0.0.0:*
udp 0 0 0.0.0.0:57220 0.0.0.0:*
udp 0 0 127.0.0.53:53 0.0.0.0:*
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:44156 0.0.0.0:*
udp 0 0 0.0.0.0:5355 0.0.0.0:*
udp6 0 0 ::1:323 :::*
udp6 0 0 :::20048 :::*
udp6 0 0 :::46721 :::*
udp6 0 0 :::111 :::*
udp6 0 0 :::44225 :::*
udp6 0 0 :::5355 :::*
[root@iZ2vc5lqzt23aweti4j777Z ~]# netstat -tuln | grep :22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep :22
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep "22"
udp UNCONN 0 0 0.0.0.0:57220 0.0.0.0:*
udp UNCONN 0 0 [::]:44225 [::]:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep 22"
>
> ;
> ^C
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep 22
udp UNCONN 0 0 0.0.0.0:57220 0.0.0.0:*
udp UNCONN 0 0 [::]:44225 [::]:*
tcp LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep "8080"
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep "80"
[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tuln | grep "2049"
tcp LISTEN 0 64 0.0.0.0:2049 0.0.0.0:*
tcp LISTEN 0 64 [::]:2049 [::]:*
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 68
dr-xr-x---. 7 root root 4096 Aug 14 15:06 .
dr-xr-xr-x. 18 root root 4096 Aug 12 15:59 ..
-rw------- 1 root root 1449 Aug 14 15:09 .bash_history
-rw-r--r--. 1 root root 18 May 18 2020 .bash_logout
-rw-r--r--. 1 root root 176 May 18 2020 .bash_profile
-rw-r--r--. 1 root root 176 May 18 2020 .bashrc
drwxr-xr-x 3 root root 4096 Aug 14 12:08 .cache
drwx------ 3 root root 4096 Oct 11 2023 .config
-rw-r--r--. 1 root root 100 May 18 2020 .cshrc
-rw-r--r-- 1 root root 569 Aug 14 13:20 id_rsa.pub
drwxr-xr-x 2 root root 4096 Oct 11 2023 .pip
-rw-r--r-- 1 root root 206 Aug 12 15:59 .pydistutils.cfg
drwx------ 3 root root 4096 Aug 14 15:06 .ssh
-rw-r--r--. 1 root root 129 May 18 2020 .tcshrc
-rw------- 1 root root 796 Aug 14 15:06 .viminfo
drwxr-xr-x 5 root root 4096 Aug 14 13:30 .vscode-server
-rw-r--r-- 1 root root 183 Aug 14 12:08 .wget-hsts
[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd
/root
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 68
dr-xr-x---. 7 root root 4096 Aug 14 15:06 .
dr-xr-xr-x. 18 root root 4096 Aug 12 15:59 ..
-rw------- 1 root root 1449 Aug 14 15:09 .bash_history
-rw-r--r--. 1 root root 18 May 18 2020 .bash_logout
-rw-r--r--. 1 root root 176 May 18 2020 .bash_profile
-rw-r--r--. 1 root root 176 May 18 2020 .bashrc
drwxr-xr-x 3 root root 4096 Aug 14 12:08 .cache
drwx------ 3 root root 4096 Oct 11 2023 .config
-rw-r--r--. 1 root root 100 May 18 2020 .cshrc
-rw-r--r-- 1 root root 569 Aug 14 13:20 id_rsa.pub
drwxr-xr-x 2 root root 4096 Oct 11 2023 .pip
-rw-r--r-- 1 root root 206 Aug 12 15:59 .pydistutils.cfg
drwx------ 3 root root 4096 Aug 14 15:06 .ssh
-rw-r--r--. 1 root root 129 May 18 2020 .tcshrc
-rw------- 1 root root 796 Aug 14 15:06 .viminfo
drwxr-xr-x 5 root root 4096 Aug 14 13:30 .vscode-server
-rw-r--r-- 1 root root 183 Aug 14 12:08 .wget-hsts
[root@iZ2vc5lqzt23aweti4j777Z ~]# cd .ssh/
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# ls
14thAug2024 14thAug2024.txt authorized_keys
[root@iZ2vc5lqzt23aweti4j777Z .ssh]#
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# pwd
/root/.ssh
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# ls -al
total 24
drwx------ 3 root root 4096 Aug 14 15:26 .
dr-xr-x---. 7 root root 4096 Aug 14 15:06 ..
drwxr-xr-x 2 root root 4096 Aug 14 15:04 14thAug2024
-rw-r--r-- 1 root root 15 Aug 14 15:06 14thAug2024.txt
-rw------- 1 root root 569 Aug 14 13:27 authorized_keys
-rw-r--r-- 1 root root 17 Aug 14 15:26 test1.txt
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# cat test1.txt
content for test1[root@iZ2vc5lqzt23aweti4j777Z .ssh]# vim test1.txt
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# ls
14thAug2024 14thAug2024.txt authorized_keys test1.txt
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# ls
14thAug2024 14thAug2024.txt authorized_keys test1 test1.txt
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# cat test1/test1.txt
content for test1[root@iZ2vc5lqzt23aweti4j777Z .ssh]# cd test1/
[root@iZ2vc5lqzt23aweti4j777Z test1]# ls -al
total 12
drwxr-xr-x 2 root root 4096 Aug 14 15:45 .
drwx------ 4 root root 4096 Aug 14 15:45 ..
-rw-r--r-- 1 root root 17 Aug 14 15:45 test1.txt
[root@iZ2vc5lqzt23aweti4j777Z test1]# cat test1.txt
[root@iZ2vc5lqzt23aweti4j777Z test1]#
2) SCP & SCP -r,
PS C:\Users\51638> ls
Directory: C:\Users\51638
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 6/27/2024 7:15 PM .codeium
d----- 8/9/2024 10:59 AM .minikube
da---- 8/14/2024 3:17 PM .ssh
d----- 5/17/2024 8:09 PM .vscode
d-r--- 5/17/2024 5:36 PM Contacts
d-r--- 8/14/2024 9:43 AM Desktop
d-r--- 7/18/2024 3:38 PM Documents
dar--- 8/14/2024 10:00 AM Downloads
d-r--- 5/17/2024 5:36 PM Favorites
d-r--- 5/17/2024 5:36 PM Links
d-r--- 5/18/2024 11:11 AM Music
dar--l 6/22/2024 6:29 PM OneDrive
d-r--- 6/20/2024 5:34 PM Pictures
d----- 6/5/2024 3:46 PM Postman
d-r--- 5/17/2024 5:36 PM Saved Games
d-r--- 7/18/2024 3:39 PM Searches
d-r--- 8/3/2024 1:50 PM Videos
d----- 8/2/2024 3:53 PM WeChatProjects
-a---- 6/17/2024 10:21 AM 5 .bash_history
-a---- 7/1/2024 8:15 AM 104 .gitconfig
-a---- 8/1/2024 1:28 PM 20 .lesshst
-a---- 6/16/2024 9:08 AM 297 2024-06-16-01-08-02.023-ABoxHeadless.exe-18672.log
-a---- 5/18/2024 12:01 PM 17521 alter
PS C:\Users\51638> cd .\.ssh\
PS C:\Users\51638\.ssh> scp .\test1.txt root@8.137.109.109:/root/.ssh
test1.txt 100% 17 0.1KB/s 00:00
PS C:\Users\51638\.ssh> ls
Directory: C:\Users\51638\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/14/2024 11:25 AM 154 config
-a---- 8/14/2024 12:23 PM 3381 debian_rsa
-a---- 8/14/2024 12:23 PM 741 debian_rsa.pub
-a---- 5/18/2024 9:42 AM 2602 id_rsa
-a---- 5/18/2024 9:42 AM 569 id_rsa.pub
-a---- 8/14/2024 12:08 PM 932 known_hosts
-a---- 8/14/2024 12:07 PM 188 known_hosts.old
-a---- 8/14/2024 3:18 PM 17 test1.txt
PS C:\Users\51638\.ssh> mkdir test1
Directory: C:\Users\51638\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/14/2024 3:44 PM test1
PS C:\Users\51638\.ssh> ls
Directory: C:\Users\51638\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/14/2024 3:44 PM test1
-a---- 8/14/2024 11:25 AM 154 config
-a---- 8/14/2024 12:23 PM 3381 debian_rsa
-a---- 8/14/2024 12:23 PM 741 debian_rsa.pub
-a---- 5/18/2024 9:42 AM 2602 id_rsa
-a---- 5/18/2024 9:42 AM 569 id_rsa.pub
-a---- 8/14/2024 12:08 PM 932 known_hosts
-a---- 8/14/2024 12:07 PM 188 known_hosts.old
-a---- 8/14/2024 3:18 PM 17 test1.txt
PS C:\Users\51638\.ssh> mv .\test1.txt .\test1\
PS C:\Users\51638\.ssh> ls
Directory: C:\Users\51638\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/14/2024 3:44 PM test1
-a---- 8/14/2024 11:25 AM 154 config
-a---- 8/14/2024 12:23 PM 3381 debian_rsa
-a---- 8/14/2024 12:23 PM 741 debian_rsa.pub
-a---- 5/18/2024 9:42 AM 2602 id_rsa
-a---- 5/18/2024 9:42 AM 569 id_rsa.pub
-a---- 8/14/2024 12:08 PM 932 known_hosts
-a---- 8/14/2024 12:07 PM 188 known_hosts.old
PS C:\Users\51638\.ssh> cd .\test1\
PS C:\Users\51638\.ssh\test1> ls
Directory: C:\Users\51638\.ssh\test1
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 8/14/2024 3:18 PM 17 test1.txt
PS C:\Users\51638\.ssh\test1> cat .\test1.txt
content for test1
PS C:\Users\51638\.ssh\test1> cd ..
PS C:\Users\51638\.ssh> ls
Directory: C:\Users\51638\.ssh
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 8/14/2024 3:44 PM test1
-a---- 8/14/2024 11:25 AM 154 config
-a---- 8/14/2024 12:23 PM 3381 debian_rsa
-a---- 8/14/2024 12:23 PM 741 debian_rsa.pub
-a---- 5/18/2024 9:42 AM 2602 id_rsa
-a---- 5/18/2024 9:42 AM 569 id_rsa.pub
-a---- 8/14/2024 12:08 PM 932 known_hosts
-a---- 8/14/2024 12:07 PM 188 known_hosts.old
PS C:\Users\51638\.ssh> scp .\test1\ root@8.137.109.109:/root/.ssh
./test1: not a regular file
PS C:\Users\51638\.ssh> scp -r .\test1\ root@8.137.109.109:/root/.ssh
test1.txt 100% 17 0.1KB/s 00:00
PS : scp -r
The command scp -r is used in Linux to securely copy directories recursively from one location to another over SSH. The -r option stands for recursive, which means it will copy all files and subdirectories within the specified directory.
3) Linux distinguish letter of uppercase and lowercase;
4) >> : how to use it
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# cat test2.txt
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# CD ..
-bash: CD: command not found
[root@iZ2vc5lqzt23aweti4j777Z .ssh]# cd ..
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 72
dr-xr-x---. 7 root root 4096 Aug 14 16:02 .
dr-xr-xr-x. 18 root root 4096 Aug 12 15:59 ..
-rw------- 1 root root 1449 Aug 14 15:09 .bash_history
-rw-r--r--. 1 root root 18 May 18 2020 .bash_logout
-rw-r--r--. 1 root root 176 May 18 2020 .bash_profile
-rw-r--r--. 1 root root 176 May 18 2020 .bashrc
drwxr-xr-x 3 root root 4096 Aug 14 12:08 .cache
drwx------ 3 root root 4096 Oct 11 2023 .config
-rw-r--r--. 1 root root 100 May 18 2020 .cshrc
-rw-r--r-- 1 root root 569 Aug 14 13:20 id_rsa.pub
drwxr-xr-x 2 root root 4096 Oct 11 2023 .pip
-rw-r--r-- 1 root root 206 Aug 12 15:59 .pydistutils.cfg
drwx------ 4 root root 4096 Aug 14 16:03 .ssh
-rw-r--r--. 1 root root 129 May 18 2020 .tcshrc
-rw-r--r-- 1 root root 26 Aug 14 16:02 test1.txt
-rw------- 1 root root 1492 Aug 14 16:02 .viminfo
drwxr-xr-x 5 root root 4096 Aug 14 13:30 .vscode-server
-rw-r--r-- 1 root root 183 Aug 14 12:08 .wget-hsts
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat test1.txt >> .ssh/test
test1/ test1.txt test2.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat test1.txt >> .ssh/test2.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat test1.txt
edit and add some content
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat .ssh/test2.txt
edit and add some content
##) the command on how to connnect Linux from powershell with password and key already defaulted.
ssh root@8.137.109.109