Bootstrap

TDL: 十分钟讲完 60 个你需要的 Linux 命令,60 Linux Commands you NEED to know GPT

small_Medium synopsis on 60 Linux commands

I) webpage address/route/path

URL Resource

II) text content & exception

Here are the top 60 Linux commands you need to know, and we’re gonna do this in minutes. Our first command can be used anywhere.

Part I ) File and folders/Directories Series

2.1) command 1 : ssh : secure shell

  It is SSH because you can’t use Linux unless you can get to it. To connect to your Linux machine, you’ll specify your user it (指定您的用户). Then the ad (@) symbol and then the server you’re gonna connect to.
在这里插入图片描述
  So I 'll copy the IP address of my linnode that I just set up, paste that in here. (复制刚刚设置的Lin节点的IP地址,然后粘贴)
  Hit enter. Accept all fingerprinits. (按Enter,接受所有指纹)
在这里插入图片描述
  Put your password in

2.2)ls: List

  • LS command will list all the files in your current working directory. (LS命令列出当前工作目录中的所有文件)
  • We can add the L switch to give us a nice list and we can add the A switch to see the hidden stuff.
    添加**ls -L (ie, ll )**选项获得一个漂亮的列表,添加-A(ls -al)选项来查看隐藏的文件,
    在这里插入图片描述
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 168
drwxr-xr-x  2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1
drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.1
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.2
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.3
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.4
drwxr-xr-x 11 root root  4096 Dec 21 14:23  PbootCMS
drwxr-xr-x  3 root root  4096 Jan  3 15:21  src
drwxr-xr-x  2 root root  4096 Jan  9 20:21  test_a_Jan9th2023
-rw-r--r--  1 root root  1292 Dec 25 17:13 'udo systemctl start mysqld.service'
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 168
drwxr-xr-x  2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1
drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.1
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.2
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.3
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.4
drwxr-xr-x 11 root root  4096 Dec 21 14:23  PbootCMS
drwxr-xr-x  3 root root  4096 Jan  3 15:21  src
drwxr-xr-x  2 root root  4096 Jan  9 20:21  test_a_Jan9th2023
-rw-r--r--  1 root root  1292 Dec 25 17:13 'udo systemctl start mysqld.service'
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 296
dr-xr-x---. 11 root root  4096 Jan 10 20:36  .
dr-xr-xr-x. 18 root root  4096 Dec 19 10:22  ..
-rw-------   1 root root 31545 Jan 10 20:36  .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
drwx------   3 root root  4096 Oct 11 11:49  .config
-rw-r--r--.  1 root root   100 May 18  2020  .cshrc
drwxr-xr-x   2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
  • update: the command ‘ls -l’ equals ll, which is the abbreviation of the former one.

2.3) pwd : print working directory

  Elix is a big place. Where are you with the PWD command? (你在哪里使用PWD命令) You can find out print working directory. It’ll tell you where you are.

[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd
/root

2.4) cd (slash) /specified path : change directory

  But if you don’t wanna be there, we can change that with the CD command. Just after CD will tell it where you want to go. Who make it (root of file system—A: should be Linus Torvalds)? Guess?
  Or we can specify a path.我们可以指定一个路径

[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd

/root

[root@iZ2vc5lqzt23aweti4j777Z ~]# cd /

[root@iZ2vc5lqzt23aweti4j777Z /]# pwd

/

[root@iZ2vc5lqzt23aweti4j777Z /]# cd home

[root@iZ2vc5lqzt23aweti4j777Z home]# cd ..

[root@iZ2vc5lqzt23aweti4j777Z /]# pwd

/

2.5) CD … : cd dot dot

  With cd dot dot, we can *** jump back one directory ***

[root@iZ2vc5lqzt23aweti4j777Z /]# pwd
/
[root@iZ2vc5lqzt23aweti4j777Z /]# cd /usr/bin
[root@iZ2vc5lqzt23aweti4j777Z bin]# cd ..
[root@iZ2vc5lqzt23aweti4j777Z usr]# pwd
/usr
[root@iZ2vc5lqzt23aweti4j777Z usr]# cd ..
[root@iZ2vc5lqzt23aweti4j777Z /]# pwd
/

2.6) CD space nothing or CD ~ : get back to home (different users, not work now)

  And with CD space nothing, we can click our heels 1 and get back, home

[root@iZ2vc5lqzt23aweti4j777Z src]# cd
[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd
/root
[root@iZ2vc5lqzt23aweti4j777Z ~]# cd ..
[root@iZ2vc5lqzt23aweti4j777Z /]# pwd
/
[root@iZ2vc5lqzt23aweti4j777Z /]# cd ~
[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd
/root

+update: ‘cd -’ means pwd will go/jump back to former pwd before we make a change directory

[root@iZ2vc5lqzt23aweti4j777Z ~]# cd /
[root@iZ2vc5lqzt23aweti4j777Z /]# pwd
/
[root@iZ2vc5lqzt23aweti4j777Z /]# cd root/myNewDirectory/
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# pwd
/root/myNewDirectory
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# cd -
/

2.7) touch fileName.txt : the quickest and easiest way to create a file

  Touch is the quickest and easiest way to create a file, type in “touch with a file name”.in it, and you got yourself a file.

  • sample one:
[root@iZ2vc5lqzt23aweti4j777Z ~]# pwd
/root
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch JanTwelfth2024_a.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 168
drwxr-xr-x  2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1
drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a
-rw-r--r--  1 root root     0 Jan 12 19:37  JanTwelfth2024_a.txt

  You can create more than one file. Every one of those words in that sentence will be its own file

  • sample two:
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch Thanks for sponsoring this video on ECS
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 168
-rw-r--r--  1 root root     0 Jan 13 11:20  ECS
drwxr-xr-x  2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1
drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a
-rw-r--r--  1 root root     0 Jan 13 11:20  for
-rw-r--r--  1 root root     0 Jan 12 19:37  JanTwelfth2024_a.txt
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.1
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.2
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.3
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.4
-rw-r--r--  1 root root     0 Jan 13 11:20  on
drwxr-xr-x 11 root root  4096 Dec 21 14:23  PbootCMS
-rw-r--r--  1 root root     0 Jan 13 11:20  sponsoring
drwxr-xr-x  3 root root  4096 Jan  3 15:21  src
drwxr-xr-x  2 root root  4096 Jan  9 20:21  test_a_Jan9th2023
-rw-r--r--  1 root root     0 Jan 13 11:20  Thanks
-rw-r--r--  1 root root     0 Jan 13 11:20  this
-rw-r--r--  1 root root  1292 Dec 25 17:13 'udo systemctl start mysqld.service'
-rw-r--r--  1 root root     0 Jan 13 11:20  video

  Or we can so something weird like this with math formula

  • sample three:
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch Linode{1,10}
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls
 ECS                        Linode1                                         mysql57-community-release-el7-10.noarch.rpm.4   Thanks
 Folder_Dec19th2023         Linode10                                        on                                              this
 Folder_Dec21th2023_test1   mysql57-community-release-el7-10.noarch.rpm     PbootCMS                                       'udo systemctl start mysqld.service'
 Folder_Dec30th2023_a       mysql57-community-release-el7-10.noarch.rpm.1   sponsoring                                      video
 for                        mysql57-community-release-el7-10.noarch.rpm.2   src
 JanTwelfth2024_a.txt       mysql57-community-release-el7-10.noarch.rpm.3   test_a_Jan9th2023
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch Linode{1~10}
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls
 ECS                        Linode1                                         mysql57-community-release-el7-10.noarch.rpm.3   test_a_Jan9th2023
 Folder_Dec19th2023         Linode10                                        mysql57-community-release-el7-10.noarch.rpm.4   Thanks
 Folder_Dec21th2023_test1   Linode{1~10}                                    on                                              this
 Folder_Dec30th2023_a       mysql57-community-release-el7-10.noarch.rpm     PbootCMS                                       'udo systemctl start mysqld.service'
 for                        mysql57-community-release-el7-10.noarch.rpm.1   sponsoring                                      video
 JanTwelfth2024_a.txt       mysql57-community-release-el7-10.noarch.rpm.2   src
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch Linode{1..10}
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 168
-rw-r--r--  1 root root     0 Jan 13 11:20  ECS
drwxr-xr-x  2 root root  4096 Dec 19 19:52  Folder_Dec19th2023
drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1
drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a
-rw-r--r--  1 root root     0 Jan 13 11:20  for
-rw-r--r--  1 root root     0 Jan 12 19:37  JanTwelfth2024_a.txt
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode1
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode10
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode{1~10}
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode2
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode3
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode4
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode5
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode6
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode7
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode8
-rw-r--r--  1 root root     0 Jan 13 17:23  Linode9
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.1
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.2
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.3
-rw-r--r--  1 root root 25548 Apr  7  2017  mysql57-community-release-el7-10.noarch.rpm.4
-rw-r--r--  1 root root     0 Jan 13 11:20  on
drwxr-xr-x 11 root root  4096 Dec 21 14:23  PbootCMS
-rw-r--r--  1 root root     0 Jan 13 11:20  sponsoring
drwxr-xr-x  3 root root  4096 Jan  3 15:21  src
drwxr-xr-x  2 root root  4096 Jan  9 20:21  test_a_Jan9th2023
-rw-r--r--  1 root root     0 Jan 13 11:20  Thanks
-rw-r--r--  1 root root     0 Jan 13 11:20  this
-rw-r--r--  1 root root  1292 Dec 25 17:13 'udo systemctl start mysqld.service'
-rw-r--r--  1 root root     0 Jan 13 11:20  video

  Or we could even create a file in future by using the dash D switch and specifing the data it’s created a file.

  • sample four:
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch -d tomorrow CreateforUs.txt

[root@iZ2vc5lqzt23aweti4j777Z ~]# ll

total 168

-rw-r--r--  1 root root     0 Jan 14  2024  CreateforUs.txt

  And seriously shout out Linode, for sponsoring this video.感谢Linode赞助了这个视频Whenever I need to do anything in Linux, I go to Linode and spread out the quick virtual machine to do stuff like this.使用Linode节点并创建一个快速的虚拟机来执行执行这样的操作. And it only costs me 0.01 cents an hour.每小时0.01美分. When I’m done, I destroy it and that’s all I’m charged. Checked it our. 我删除它,我被收取了所有的费用,check it out看看吧,link below查看下方链接

2.8) echo : self taking or add stuff to new file or existing file

  The Echo command allows you to talk to yourself or we can use it to add stuff to a file really quickly. We’ll specify the right arrow and then a name of a file, a new or existing file.

  • sample one: add stuff to new file
[root@iZ2vc5lqzt23aweti4j777Z ~]# echo Hello me! talk to yourself yet.
Hello me! talk to yourself yet.
[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "Added some stuff, stuff and stuff" > JanFourteenth2024.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFourteenth2024.awesome 
Added some stuff, stuff and stuff
  • sample two: add stuff to existing file
[root@iZ2vc5lqzt23aweti4j777Z ~]# touch JanFifteeth2023.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "add some new stuffs as content" > JanFifteeth2023.txt 
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFifteeth2023.txt 
add some new stuffs as content

2.9) Nano (not work, but vi comamnd works) – vi fileName: edit file content

  But if you want to edit a file like Linux pro (Linux professor), you’ll use Nano and file name, and boom, we’re editing a file. To save your file with Nano, you’ll hit control x, y and enter to save.

  • esc+i: edit the chosen file -> esc+shift+: + wq! : write/save and quit
  • esc+i: edit the chosen file-> esc+shift+: + wq! : quit
[root@iZ2vc5lqzt23aweti4j777Z ~]# vi JanTwelfth2024_a.txt 
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanTwelfth2024_a.txt 
we are editing this file!!!
[root@iZ2vc5lqzt23aweti4j777Z ~]# 

2.10) Vim fileName.txt : edit a fileName content

  Now if you’re Linux pro (professor) that thinks you’re better than everybody else, 你自以为比其他人都优秀的Linux Pro (professor专家), you‘ll use vim, vim the file name and now you can try to edit a file. The best way is to hit i (key) to start inserting text and once you’re done, hit esc, colon(冒号) 2 and wq to write and quit.

  • demo 1) use ‘vi newFileName.txt’ to create new file.
root@iZ2vc5lqzt23aweti4j777Z ~]# vi JanFifteeth2023_a.txt 

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanF

JanFifteeth2023_a.txt      JanFifteeth2023.txt        JanFourteenth2024.awesome  

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFifteeth2023_a.txt 

new stuffs
  • demo 2) vim fileName to edit a file content
[root@iZ2vc5lqzt23aweti4j777Z ~]# vim JanFifteeth2023.txt 
:wq!
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFifteeth2023.txt 
add some new stuffs as content
edit the file again
edit content once again

2.11)cat fileName.txt : see what’s inside a file super fast

  Now if you want to see what’s inside a file really quickly, use cat command, cat and then file name, super fast

2.12) shred fileName

  And if you don’t want anyone to ever see what’s in that file, you can shred 3 it. (粉碎). Nothing looks like a cat road.(不像一条猫路)

  • sample
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
-rw-r--r--  1 root root    34 Jan 14 22:22  JanFourteenth2024.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFourteenth2024.awesome 
Added some stuff, stuff and stuff
[root@iZ2vc5lqzt23aweti4j777Z ~]# shred JanFourteenth2024.awesome 
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanFourteenth2024.awesome 
��۾���e��=���}��[��`e��~���?���s�n�ί.ښ =��ؑ��6M��)m��lD"�m
                                                         zBH&��'i       c�C煮.��E��7��+�u�.D�d��5F      �u�~�|��D�Db/�n[���
                                                                                                                           ���z�B�Ca��7V���=d�o��3,T�����A�p�4��-�ڽWx�ϐWz�T2`�q�?���S       |�������y��K�;���ˁ}���AZ�

2.13) mkdir

  We can make a new directory with the MKDIR command.使用mkdir创建新目录,but right now he’s empty,. It’s lonely, so let’s copy something in there.

[root@iZ2vc5lqzt23aweti4j777Z ~]# mkdir myNewDirectory
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 188
drwxr-xr-x  2 root root  4096 Jan 16 20:44  myNewDirectory

2.14)cp fileName path : copy file to a directory/folder

  We can copy a file with CP command, we’ll specify our file and then where we want it to go.

[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 316
-rw-r--r--  1 root root     0 Jan 17 08:31  JanSeventeeth2023.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# rename JanSeventeeth2023.awesome JanSeventeenth2023.awesome JanSeventeeth2023.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -al
total 316
-rw-r--r--   1 root root     0 Jan 17 08:31  JanSeventeenth2023.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# cp JanSeventeenth2023.awesome myNewDirectory/
[root@iZ2vc5lqzt23aweti4j777Z ~]# cd myNewDirectory/
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# ls -l
total 0
-rw-r--r-- 1 root root 0 Jan 17 08:39 JanSeventeenth2023.awesome

2.15) mv fileName directoryRoute : move file to designated directory path

  if you don’t wanna copy, you can use mv command to move the file, specify the file you wanna move, and where you wanna put it,

[root@iZ2vc5lqzt23aweti4j777Z ~]# mv JanFourteenth2024.awesome myNewDirectory/
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls myNewDirectory/
JanFourteenth2024.awesome  JanSeventeenth2023.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll myNewDirectory/
total 4
-rw-r--r-- 1 root root 4096 Jan 16 20:29 JanFourteenth2024.awesome
-rw-r--r-- 1 root root    0 Jan 17 08:39 JanSeventeenth2023.awesome
  • PS: mv can be used to rename/cover the former fileName with new file name in the seacond place

format: mv oldFileName newFileName

[root@iZ2vc5lqzt23aweti4j777Z bash]# ll
total 12
-rwxr-xr-x 1 Dyan root 276 Feb 29 15:56 4t1.sh
-rwxr-xr-x 1 root root  71 Feb 29 16:18 cdNoUse.sh
-rw-r--r-- 1 root root 240 Feb 29 16:48 function.sh
[root@iZ2vc5lqzt23aweti4j777Z bash]# mv function.sh ./root
[root@iZ2vc5lqzt23aweti4j777Z bash]# ll
total 12
-rwxr-xr-x 1 Dyan root 276 Feb 29 15:56 4t1.sh
-rwxr-xr-x 1 root root  71 Feb 29 16:18 cdNoUse.sh
-rw-r--r-- 1 root root 240 Feb 29 16:48 root
[root@iZ2vc5lqzt23aweti4j777Z bash]# cat root
#!/root/bash

check_even () {
        local mod=2
        echo "The value of mod is $mod"
        if [ $(("$1" % $mod)) -eq 0]
        then
          echo "The number $1 is even!";
        else 
          echo "The number $1 is odd!"
        fi
}

number=2344
two=2

check_even $number
echo $mod
[root@iZ2vc5lqzt23aweti4j777Z bash]# 

2.16) rm fileName

  we can remove or delete a file with rm command

[root@iZ2vc5lqzt23aweti4j777Z ~]# rm Linode{1..10}
rm: remove regular empty file 'Linode1'? y
rm: remove regular empty file 'Linode2'? y
rm: remove regular empty file 'Linode3'? y


[root@iZ2vc5lqzt23aweti4j777Z ~]# rm html javascript learn Linux mysql on sponsoring src this video
rm: remove regular empty file 'html'? y
rm: remove regular empty file 'javascript'? y
rm: cannot remove 'learn': No such file or directory
rm: remove regular empty file 'Linux'? 
rm: remove regular empty file 'mysql'? y

2.17) rmdir folderName; or rm -r notEmptyFolerName (-r: recursive)

  And we can remove the directory with rmdir command. But if it is not empty, we can go back to RM command and do a dash R for recursive and try that. Done (做好了)

[root@iZ2vc5lqzt23aweti4j777Z ~]# rm -r Folder_Dec19th2023/

rm: descend into directory 'Folder_Dec19th2023/'? y

rm: remove regular empty file 'Folder_Dec19th2023/test1.txt'? y

rm: remove directory 'Folder_Dec19th2023/'? y
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll

total 180

-rw-r--r--  1 root root     0 Jan 14 18:00  CreateforUs.txt

drwxr-xr-x  3 root root  4096 Jan  7 21:54  Folder_Dec21th2023_test1

drwxr-xr-x  2 root root  4096 Dec 30 08:41  Folder_Dec30th2023_a

2.18)ln -s fileName aLinkToThisFile : create a link to a file (-s: swich)(ln:link)

  We can create a link to a file with the ln command, using the S switch for soft,(用LN命令创建一个指向文件的链接,使用S开关进行软链接,), we’ll specify the file and then the link. Now w’ll specify the file and then the link.

[root@iZ2vc5lqzt23aweti4j777Z ~]# ln -r JanSeventeenth2023.awesome aLinktoThisFile
ln: cannot do --relative without --symbolic
[root@iZ2vc5lqzt23aweti4j777Z ~]# ln -s JanSeventeenth2023.awesome aLinktoThisFile
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 180
lrwxrwxrwx  1 root root    26 Jan 17 15:44  aLinktoThisFile -> JanSeventeenth2023.awesome

2.19) clear : clear the terminal screen

  Now if your terminal’s a bit dirty, you can clean it off, type in clear. So much better

[root@iZ2vc5lqzt23aweti4j777Z ~]# clear

2.20) whoami

  you don’t know who you are, you can type in ‘whoami’ and it’ll tell you. Existential crisis over.(输入后,就解决‘’存在危机‘’)

[root@iZ2vc5lqzt23aweti4j777Z ~]# whoami
root

2.21) useradd/adduser nickname, or sudo useradd/adduser nickname

  if you don’t like who you are, you can change that. Let’s first create a new person. We’ll use the ad user command and then the username, oh, too bad, we don’t have permission.
  But we have pseudo or sudo specify pseudo before your command; enter your pseudo password and you’re good to go

  • sample one
[root@iZ2vc5lqzt23aweti4j777Z ~]# useradd Dyan
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo useradd Dyan
useradd: user 'Dyan' already exists
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo useradd Dian

  We can also reverse the command by doing adduser instead of useradd, and we will be able to set some parameters like password and stuffs (no found this features on ECS server)

  • demo two
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo useradd Dian
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo adduser Chenyen

2.22) su : switch user

  Now if wanna become Nick or Austin, I can do that with su (switch user) command, switch user

[root@iZ2vc5lqzt23aweti4j777Z home]# su Dyan
[Dyan@iZ2vc5lqzt23aweti4j777Z home]$ exit

[root@iZ2vc5lqzt23aweti4j777Z home]# su Dian
[Dian@iZ2vc5lqzt23aweti4j777Z home]$ su dikens/
[Dian@iZ2vc5lqzt23aweti4j777Z home]$ exit
exit
[root@iZ2vc5lqzt23aweti4j777Z home]# useradd Dave

2.23) exit : can be used in many places

  SU specify user name and I am Austin, and I don’t wanna be Austin anymore, I can use the exit command, type in exit, back to you and me (home?!), By the way the exit comand can be used to exit at a lot of places,

[Dave@iZ2vc5lqzt23aweti4j777Z home]$ exit
exit
[root@iZ2vc5lqzt23aweti4j777Z home]# ll
total 28
drwx------ 2 Chenyen Chenyen 4096 Jan 17 17:13 Chenyen
drwx------ 2 Dadian  Dadian  4096 Jan 17 17:06 Dadian
drwx------ 2 Dave    Dave    4096 Jan 17 17:22 Dave
drwx------ 2 Dian    Dian    4096 Jan 17 17:01 Dian
drwx------ 2 dikens  dikens  4096 Jan 17 16:39 dikens
drwx------ 2 Dikes   Dikes   4096 Jan 17 17:03 Dikes
drwx------ 2 Dyan    Dyan    4096 Jan 17 16:45 Dyan

2.24) passwd : su passwd nickname (under home of many users)

  Now Nick(Chenyen) didn’t have a password but I can cange that with the password command, p a s s w d, and then the username.

  • demo : su passwd nickname
[root@iZ2vc5lqzt23aweti4j777Z home]# sudo passwd Chenyen 
Changing password for user Chenyen.
New password: 
BAD PASSWORD: The password is a palindrome
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@iZ2vc5lqzt23aweti4j777Z home]# su Chenyen

  If you wanna change your password, just type in password or password. Type into terminal, pseudo password, milli password, but it’s so it’s just password,

  • more than one directory paths to change password of root user.
[root@iZ2vc5lqzt23aweti4j777Z ~]# passwd
Changing password for user root.
New password: 

[root@iZ2vc5lqzt23aweti4j777Z /]# cd home
[root@iZ2vc5lqzt23aweti4j777Z home]# passwd
Changing password for user root.
New password: 

2.25)sudo apt update : not work (probably ECS use the Yum package, on Arch or anything else (many different Linux Versions) )

  Now the next command is kinda weird, and you have to install. It’s called finger. It’s really strange, trust me. But to install that we will needto learn a new command on Debbie and Base machines. We will use apt, but hold on, before we could install anything, we have to update our repositories, so we 'll do sudo apt update. Whilist doing, that’ll take a coffee break
  If you’re on Red Hat or Sent to West, You’ll use the Yum package manager and if your’re on Arch or anything else, you’re on your own. After an update, We’ll do a pseudo apt install and the name of our package which will be finge.
  Done and now we can use that command, Finger can be used to inspect another user. So I might want to inspect Austin. It’s pretty handy. (谐音、同音词:haha cuz finger on handy)

[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo apt install finger
sudo: apt: command not found

2.26) man command_name

  The man command will help you with the things you don’t know, which is a lot, at least for me. You find out what finger command does by doing man finge

  • man finger: finger not applicable in this Linux system
[root@iZ2vc5lqzt23aweti4j777Z ~]# man finger
No manual entry for finger

  That sounds werid. It will tell us all about it and how to use it. Hit Q to get outta there.
  We can man cat. We can man man, so in doubt consult your manual,

[root@iZ2vc5lqzt23aweti4j777Z ~]# man l
       -f, --force
 Manual page ln(1) line 1 (press h for help or q to quit)
[root@iZ2vc5lqzt23aweti4j777Z ~]# man cat
[root@iZ2vc5lqzt23aweti4j777Z ~]# man man

2.27) whatis : not applicable in ECS platform

  Now a faster man is whatis, type in Finger. I’ll tell you real quick

[root@iZ2vc5lqzt23aweti4j777Z ~]# whatis finger
finger: nothing appropriate.
[root@iZ2vc5lqzt23aweti4j777Z ~]# whatis ls
ls: nothing appropriate.

2.28) where , whereis, , , not applicable here probably

  or maybe yu wanna know where finger is. You can type in which finger,

2.29) wget url of download : download the resource from url

  wget can help you get stuff from Internet, like maybe you wanna download the entire bible in text form. We can do that right now. And there is, the entire Bible.

  • sample index
[root@iZ2vc5lqzt23aweti4j777Z ~]# wget https://www.baidu.com/
--2024-01-19 10:30:06--  https://www.baidu.com/
Resolving www.baidu.com (www.baidu.com)... 183.2.172.42, 183.2.172.185, 240e:ff:e020:966:0:ff:b042:f296, ...
Connecting to www.baidu.com (www.baidu.com)|183.2.172.42|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2443 (2.4K) [text/html]
Saving to: ‘index.html’

index.html                           100%[====================================================================>]   2.39K  --.-KB/s    in 0s      

2024-01-19 10:30:06 (28.8 MB/s) - ‘index.html’ saved [2443/2443]
  • sample txt download
[root@iZ2vc5lqzt23aweti4j777Z ~]# wget http://m.luoqiuzww.cc/novel/39142/download
--2024-01-19 10:45:37--  http://m.luoqiuzww.cc/novel/39142/download
Resolving m.luoqiuzww.cc (m.luoqiuzww.cc)... 23.225.30.59
Connecting to m.luoqiuzww.cc (m.luoqiuzww.cc)|23.225.30.59|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: /upload/42/%E9%9D%92%E8%91%AB%E5%89%91%E4%BB%99.txt [following]
--2024-01-19 10:45:37--  http://m.luoqiuzww.cc/upload/42/%E9%9D%92%E8%91%AB%E5%89%91%E4%BB%99.txt
Reusing existing connection to m.luoqiuzww.cc:80.
HTTP request sent, awaiting response... 200 OK
Length: 511576 (500K) [text/plain]
Saving to: ‘download.1’

download.1                           100%[====================================================================>] 499.59K   361KB/s    in 1.4s    

2024-01-19 10:45:39 (361 KB/s) - ‘download.1’ saved [511576/511576]

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat download.1 
五月份加更提示以及作者的一些话
开书到现在,没有写过类似的东西,可能我不太会和读者交流吧,不过心里其实还是有些话想对你们说的。(假装有人在听的认真样子!)

2.30)curl urlAddress > customizedFileName : similar to wget command for download resource on Internet

  Another way to download is with curl, my personal favor, type in curl and url you wanna download from and then using the right arrow to direct that to something else like a file, done

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat Fantasy.Novel 
Redirecting to <a href="/upload/54/%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C.txt">/upload/54/%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C.txt</a>.[root@iZ2vc5l

2.31) zip newZipName formerFileName

  Now the bible is kinda big, what do yu say? we make that file smaller.We can zip it up. Zip the zip file you wanna create, and what you wanna zip inside.

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat Fantasy.Novel 

Redirecting to <a href="/upload/54/%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C.txt">/upload/54/%E5%AE%8C%E7%BE%8E%E4%B8%96%E7%95%8C.txt</a>.[root@iZ2vc5lqzt23aweti4j777Z ~]# zip Fantasy.zip Fantasy.Novel 

  adding: Fantasy.Novel (deflated 38%)

-rw-r--r--  1 root root 74132360 Jan  5 15:34  QQMusic_YQQWinPCDL.exe

-rw-r--r--  1 root root 73270927 Jan 19 11:40  QQ_Music.zip

2.32) unzip oldZipFile + otherOptiions

  Now often you might want to unzip something with the unzip command,specify the file name and some other options and you’re good to go.

-rw-r--r--  1 root root      169 Jan 19 11:34  ShuLone.MartialSoul
-rw-r--r--  1 root root      169 Jan 19 11:34  ShuLone.unzip
-rw-r--r--  1 root root      284 Jan 19 11:34  ShuLone.zip

2.33) less fileName : read the content of file, one line or several lines at each time by up-or-down arrow, or idler wheer respectively.

  Now if you wanna read our file, we could cat it, but that’s crazy. Come on, a better way is to use the less command, giving you one page at a time, just the way I like.

  • sample: read the content of file, one line or several lines at each time by up-or-down arrow, or idler wheer respectively.
less download.1
第1769章 皇城风景!
“伯母,你第一次来帝月皇城,今夜带你出去吃饭可好?”

2.34)head fileName

  if you wanna see the begining of your file, type in head

[root@iZ2vc5lqzt23aweti4j777Z ~]# head download.2

第1769章 皇城风景!

“伯母,你第一次来帝月皇城,今夜带你出去吃饭可好?”

凌云霆笑容和煦,目光悄然看向了一旁的慕芷晴,算是回应了她当初的问题。

慕芷晴顿时就明白了过来,原来尊上今天这么早就从帝云宫来了,为的就是带娘出去吃饭啊!

“皇城的夜景不错,如果伯母感兴趣,用过晚膳之后便在城中四处转转,看看风景,如何?”

慕锦岚的眼中漫上了兴趣之色,早在来帝月皇城之前,她就已经听说过这里的风景有多美,街道上有多热闹。

当初便想着自己来了之后也得好好看一看这风景,见识一番。

只是没想到云霆想的这么周到,今天竟然亲自陪她去。

看着小两口的眼神交汇,她笑而不语。

看来不论是芷晴还是云霆,之前说的都是真的,二人的感情很好,就冲着这和谐的模样,也知道芷晴在云霆的身边从来就没有受过委屈。

2.35)tail filename

What about the end? Type in tail and fileName

[root@iZ2vc5lqzt23aweti4j777Z ~]# tail download.2

“我竟不知夫人为我做了这么多,我很感动。”

温醇暧昧的嗓音在她的头顶响起,温热而清爽的男子气息将她笼罩,而那话语的深意却让她如遭雷击!

“夫……夫人?”

“夫人已为我断了所有后路,我向来负责任,定不会让你失望。”凌云霆神色坦然,“就看夫人何时为我正名,好满足你亲朋好友的好奇心了。”

慕芷晴:“……”这是在向她讨要名分吗?

不该是这么发展的啊!

小妖精瞧着自家主人那懊恼的表情就明白她这是搬起石头砸自己的脚了,之前在门派的时候,但凡有男子示好,小晴晴就借有未婚夫的名头来婉拒。

只是没想到一语成谶,真的出现了个未婚夫。

刚才分明就是顺口说习惯了,完全忘了凌公子也在这里了,不过它觉得……这样也挺好的!

轩辕瑶一回过头来便瞧见凌云霆与慕芷晴窃窃私语的模样,眼中的嫉恨之色也愈发浓郁。

2.36)cmp fileOneName fileTwoName

  If you wanna compare two files to see if there are the same. Like this guy and this guy, use the cpm command for compare, specifiy your two files

[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# cp JanTwelfth2024.txt JanTwelfth2024Copy.txt 
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# vi JanTwelfth2024Copy.txt 
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# cmp JanTwelfth2024.txt JanTwelfth2024Copy.txt 
cmp: EOF on JanTwelfth2024.txt after byte 28, line 1

2.37)diff command

  and he, we do have difference, but it didn’t tell what; it only tell us where. For that we can use the diff command, specify files, and it will tell us exactly what;s difference.You decide what’s true.

[root@iZ2vc5lqzt23aweti4j777Z ~]# ll myNewDirectory/
total 12
-rw-r--r-- 1 root root   53 Jan 22 12:10 JanTwelfth2024Copy.txt
-rw-r--r-- 1 root root   28 Jan 22 12:05 JanTwelfth2024.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# cd myNewDirectory/
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# diff JanTwelfth2024.txt JanTwelfth2024Copy.txt 
1a2
> Repeating for polishing.

2.28) cat fileName | sort

  The sort command will sort your staff alphabetically. For example, I can cat bible.txt, do a pipe(管道符) and type in sort at the end. The entire bible in alphabetical order. Ending with Zephaniah.

[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# cat JanSeventeenth2023.awesome 
b
c
f
ef
eter
k
2
7

7
[root@iZ2vc5lqzt23aweti4j777Z myNewDirectory]# cat JanSeventeenth2023.awesome | sort

2
7
7
b
c
ef
eter
f
k

2.29) sudo find / -name “fileName” (blur match)

  The find command is nuts and will help you well find things; type in find, specify what directory you wanna look in. I am gonna look in all of them and then specify the name of the file with a regular express(快速模糊查找方法), Bang, files’ found

[root@iZ2vc5lqzt23aweti4j777Z ~]# ll myNewDirectory/
total 24
-rw-r--r-- 1 root root 4096 Jan 16 20:29 JanFourteenth2024.awesome
-rw-r--r-- 1 root root   23 Jan 23 19:40 JanSeventeenth2023.awesome
-rw-r--r-- 1 root root   53 Jan 22 12:10 JanTwelfth2024Copy.txt
-rw-r--r-- 1 root root   28 Jan 22 12:05 JanTwelfth2024.txt
-rw-r--r-- 1 root root 7105 Jan 23 19:51 loren.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo find / -name "JanT*"
/root/myNewDirectory/JanTwelfth2024Copy.txt
/root/myNewDirectory/JanTwelfth2024.txt
/root/JanTwelfth2024_a.txt
/root/JanTwentySecond_a.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# pseudo find / -name "JanF"
-bash: pseudo: command not found
[root@iZ2vc5lqzt23aweti4j777Z ~]# pseudo find / -name "JanF*"
-bash: pseudo: command not found
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo find / -name "JanF*"
find: ‘/proc/54745’: No such file or directory
/root/myNewDirectory/JanFourteenth2024.awesome
/root/JanFifteeth2023.txt
/root/JanFifteeth2023_a.txt

2.30) sudo find . -type f -name “.*” : find hidden file or folders(starts with dot.)

  find all hidden files

[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo find . -type f -name ".*" 
./.bash_logout
./.bashrc
./.lesshst
./.tcshrc
./.mysql_history
./.pydistutils.cfg
./.bash_profile
./.wget-hsts
./PbootCMS/template/default/fileinput/.gitignore
./PbootCMS/.gitattributes
./PbootCMS/.gitignore
./PbootCMS/rewrite/.htaccess
./.cshrc
./.viminfo
./.bash_history

2.31) find . -type f -empty :find the empty folder or files under folder

  Find empty files or folder under the specified folder

[root@iZ2vc5lqzt23aweti4j777Z ~]# find . -type f -empty
./NovelTxt.Test
./.ssh/authorized_keys
./CreateforUs.txt
./QQ.Music
./Folder_Dec21th2023_test1/READ.MD
./MingDynasty.VeggetableRootsPonds
./video
./Thanks
./JanTwentySecond_a.txt
./test_a_Jan9th2023/file_a_Jan9th2023.txt
./src/java/main.java
./JanSeventeenth2023.awesome
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat CreateforUs.txtreat
cat: CreateforUs.txtreat: No such file or directory
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat CreateforUs.txt 
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat JanSeventeenth2023.awesome 
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat /test_a_Jan9th2023/file_a_Jan9th2023.txt
cat: /test_a_Jan9th2023/file_a_Jan9th2023.txt: No such file or directory
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat test_a_Jan9th2023/file_a_Jan9th2023.txt
[root@iZ2vc5lqzt23aweti4j777Z ~]# cat MingDynasty.VeggetableRootsPonds 
[root@iZ2vc5lqzt23aweti4j777Z ~]# 
[root@iZ2vc5lqzt23aweti4j777Z ~]# 

2.32) find . -perm /a=x :

  or all excutable files 4

  explaination: 在linux中,执行文件是指的是该文件可以被运行,文件有“x”权限;执行文件可以是一个代码文件(脚本文件),也可以是一个二进制文件。一个文件运行有两种方式:1、用解释器直接去运行文件;2、利用“./”运行文件,语法“./ 文件名”。

[root@iZ2vc5lqzt23aweti4j777Z ~]# find . -perm /a=x
.
./aLinktoThisFile
./myNewDirectory
./.pip
./.config
./.config/procps
./.ssh
./Folder_Dec21th2023_test1
./Folder_Dec21th2023_test1/Folder_6thJan2024
./Folder_Dec21th2023_test1/Folder_6thJan2024/Folder_Dec27th2023
./Folder_Dec21th2023_test1/Folder_6thJan2024/Folder_Dec27th2023/BackEnd
./Folder_Dec21th2023_test1/Folder_6thJan2024/Folder_Dec27th2023/BackEnd/Java
./Folder_Dec21th2023_test1/Folder_6thJan2024/Folder_Dec27th2023/BackEnd/PHP
./Folder_Dec21th2023_test1/Folder_6thJan2024/Folder_Dec27th2023/FrontEnd
./Folder_Dec30th2023_a
./PbootCMS

2.33) chmod +x 4t1.sh

  Speaking of executable, how do yu make a file executable? We will change the attributes with chmod comand and do a plus x 5 and then the file name and now it executes. (x attributes means the file will be executable)

[root@iZ2vc5lqzt23aweti4j777Z ~]# chmod +x 4t1.sh 
[root@iZ2vc5lqzt23aweti4j777Z ~]# ls -l
total 345788
-rwxr-xr-x  1 root root      242 Jan 24 10:00  4t1.sh
  • PS: vim new.sh, the file is not executable only after using command “chmod +x xx.sh” to turn new file green

Part II ) Network series

2.34) chown Dyan fileName : who owns this file

  We can change the ownership of that file with chown command or change ownership, specif the user and the file, congras Austin, you own the

[root@iZ2vc5lqzt23aweti4j777Z ~]# chown Dyan 4t1.sh
[root@iZ2vc5lqzt23aweti4j777Z ~]# ll
total 345788
-rwxr-xr-x  1 Dyan root      242 Jan 24 10:00  4t1.sh

2.35) ifconfig : retrieve/get ip address

  Time for some network stuff, coffee break. What’s your IP address? ifconfig. I have ifconfig, If you don’t have it, install it. Let’s try it again; ifconfig, there it is ( inet 172.23.95.44)

[root@iZ2vc5lqzt23aweti4j777Z ~]# ifconfig

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.23.95.44  netmask 255.255.240.0  broadcast 172.23.95.255
        inet6 fe80::216:3eff:fe03:e1cc  prefixlen 64  scopeid 0x20<link>
        ether 00:16:3e:03:e1:cc  txqueuelen 1000  (Ethernet)
        RX packets 1251161  bytes 711277436 (678.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 846487  bytes 131673419 (125.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 100  bytes 5632 (5.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 100  bytes 5632 (5.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.36) ip address : the same ip information, just better

  You can also try ip address, which makes more sense; same information, just better. (inet 172.23.95.44)

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:16:3e:03:e1:cc brd ff:ff:ff:ff:ff:ff
    altname enp0s5
    altname ens5
    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0
       valid_lft 314159226sec preferred_lft 314159226sec
    inet6 fe80::216:3eff:fe03:e1cc/64 scope link 
       valid_lft forever preferred_lft forever

2.37) ip address | grep eth0 “or” ip address | grep lo

  Now what if you only wanna see it for one interface? For that we can use grep, grep is crazy, I love grep, same command ip address. For this time, I will use a pipe, type in grep, say ether?? nets zero, to only see, Ethen at zero’s IP address, Bang

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

       valid_lft forever preferred_lft forever

    inet6 ::1/128 scope host 

       valid_lft forever preferred_lft forever

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000

    link/ether 00:16:3e:03:e1:cc brd ff:ff:ff:ff:ff:ff

    altname enp0s5

    altname ens5

    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0

       valid_lft 314155861sec preferred_lft 314155861sec

    inet6 fe80::216:3eff:fe03:e1cc/64 scope link 

       valid_lft forever preferred_lft forever

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep eth0

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000

    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep lo

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 scope host lo

    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0

2.38) ip address | grep eth0 | grep inet : grep again

We could grep again, do another pipe grep for inet, it only shows you that line

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep eth0 | grep inet

    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0
    
[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep lo | grep inet

    inet 127.0.0.1/8 scope host lo

    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0

2.39) ip address | grep th0 | grep inet | awk ‘{print $2}’ : exactly ip only

What if we can only wanna see the IP address? For that, we can use awk, awk is even crazier than grep. Just After our greps, I’ll awk this in a crazier regular expression and get exactly what I want

[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep th0 
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0
[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep th0 | grep inet
    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0
[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep th0 | grep inet | awk "{print $2}"
    inet 172.23.95.44/20 brd 172.23.95.255 scope global dynamic noprefixroute eth0
[root@iZ2vc5lqzt23aweti4j777Z ~]# ip address | grep th0 | grep inet | awk '{print $2}'
172.23.95.44/20

2.40) cat /etc/resolv.conf

Now what about DNS? What is our DNS, Sir? One way is we cat, cat slash etc slash resolve with no e, then dot conf.
But if you’re on newer version of things like Ubuntu (as below), you might see something like this, not very informative (Ubuntu doesn’t contain much information)

[root@iZ2vc5lqzt23aweti4j777Z ~]# cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 100.100.2.136
nameserver 100.100.2.138

just author's DNS server

2.41) resolvectl status : alternatively to check DNS (not related to Linux version)

Instead we can type in resolve with an e, ctl 6 , status, and there it is (that commands work).

[root@iZ2vc5lqzt23aweti4j777Z ~]# resolvectl status
Global
       LLMNR setting: yes
MulticastDNS setting: yes
  DNSOverTLS setting: no
      DNSSEC setting: allow-downgrade
    DNSSEC supported: yes
  Current DNS Server: 100.100.2.136
         DNS Servers: 100.100.2.136
                      100.100.2.138
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa

2.42) ping wwww.baidu.com : to check if we can ping through website or not

Now is your website up? We can find out with ping, we can find out anything with ping, ping and then then name of the website. Get responses forever. Hit control c to stop,

[root@iZ2vc5lqzt23aweti4j777Z ~]# ping wwww.baidu.com
PING ps_other.a.shifen.com (220.181.38.148) 56(84) bytes of data.
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=49 time=33.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=49 time=33.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=49 time=33.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=49 time=33.1 ms
64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=49 time=33.1 ms
^C
--- ps_other.a.shifen.com ping statistics ---

2.43) ping website -c number websites : how many lines of result we need to ping

We can limit that with dash c specifing the count of things you wanna send, just five

[root@iZ2vc5lqzt23aweti4j777Z ~]# ping -c 6 www.baidu.com
PING www.a.shifen.com (183.2.172.185) 56(84) bytes of data.
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=1 ttl=48 time=29.7 ms
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=2 ttl=48 time=29.7 ms
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=3 ttl=48 time=29.7 ms
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=4 ttl=48 time=29.7 ms
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=5 ttl=48 time=29.7 ms
64 bytes from 183.2.172.185 (183.2.172.185): icmp_seq=6 ttl=48 time=29.7 ms

--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 29.679/29.703/29.727/0.173 ms

2.44) ping -c 6 -s 500 www.baidu.com : specify the size of package

We can specify the size of the packages,

[root@iZ2vc5lqzt23aweti4j777Z ~]# ping -c 6 -s 500  www.baidu.com
PING www.a.shifen.com (183.2.172.42) 500(528) bytes of data.
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=1 ttl=48 time=28.9 ms
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=2 ttl=48 time=28.8 ms
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=3 ttl=48 time=28.9 ms
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=4 ttl=48 time=28.8 ms
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=5 ttl=48 time=28.8 ms
508 bytes from 183.2.172.42 (183.2.172.42): icmp_seq=6 ttl=48 time=28.9 ms

--- www.a.shifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5008ms
rtt min/avg/max/mdev = 28.823/28.847/28.891/0.197 ms

2.45) traceroute www.baidu.com (unsure, right now it is not working)

If you wanna see the path through the Internet you’re taking to get to the website, you can use trace route command, which is so cool; trace route and the name of the site, telling you every haw and that latency.

[root@iZ2vc5lqzt23aweti4j777Z ~]# traceroute www.baidu.com
-bash: traceroute: command not found

在这里插入图片描述

2.46) netstat : what ports are open in your Linux Machine (Proto Recv-Q Send-Q Local Address Foreign Address State )

Now what ports are open in you Linux machine? We can check it out with netstat, net statistics, this gives you a lot

[root@iZ2vc5lqzt23aweti4j777Z ~]# netstat
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0     36 iZ2vc5lqzt23aweti4j:ssh 47.96.60.217:34984      ESTABLISHED
tcp        0      0 iZ2vc5lqzt23aweti:45102 100.100.0.42:http       TIME_WAIT  
tcp        0      0 iZ2vc5lqzt23aweti:51602 100.100.30.27:http      ESTABLISHED
udp        0      0 iZ2vc5lqzt23awet:bootpc _gateway:bootps         ESTABLISHED
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ]         DGRAM                    1413429  /run/user/0/systemd/notify
unix  3      [ ]         DGRAM                    237      /run/systemd/notify
unix  2      [ ]         DGRAM                    238      /run/systemd/cgroups-agent
unix  15     [ ]         DGRAM                    249      /run/systemd/journal/dev-log
unix  7      [ ]         DGRAM                    253      /run/systemd/journal/socket
unix  2      [ ]         DGRAM                    18665    /var/run/nscd/socket
unix  2      [ ]         DGRAM                    19874    /run/chrony/chronyd.sock
unix  3      [ ]         STREAM     CONNECTED     20791    
unix  3      [ ]         STREAM     CONNECTED     24491    
unix  3      [ ]         STREAM     CONNECTED     18594    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     869612   /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix  3      [ ]         STREAM     CONNECTED     18671    
unix  3      [ ]         STREAM     CONNECTED     22879    
unix  3      [ ]         STREAM     CONNECTED     1414257  
unix  3      [ ]         STREAM     CONNECTED     21524    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     19778    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     18431    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     25369    /run/rpcbind.sock
unix  3      [ ]         STREAM     CONNECTED     1414260  /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    1355282  
unix  3      [ ]         STREAM     CONNECTED     27004    
unix  3      [ ]         STREAM     CONNECTED     27005    
unix  3      [ ]         STREAM     CONNECTED     23823    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     21198    
unix  3      [ ]         STREAM     CONNECTED     19852    
unix  2      [ ]         DGRAM                    25125    
unix  2      [ ]         DGRAM                    18240    
unix  3      [ ]         DGRAM                    239      
unix  3      [ ]         DGRAM                    1413430  
unix  2      [ ]         DGRAM                    22899    
unix  3      [ ]         STREAM     CONNECTED     19175    
unix  3      [ ]         STREAM     CONNECTED     18432    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     18428    
unix  3      [ ]         STREAM     CONNECTED     22660    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     21011    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    22840    
unix  2      [ ]         STREAM     CONNECTED     1414412  
unix  3      [ ]         STREAM     CONNECTED     18606    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    19236    
unix  3      [ ]         STREAM     CONNECTED     17672    
unix  3      [ ]         STREAM     CONNECTED     18990    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     26046    
unix  3      [ ]         STREAM     CONNECTED     1414438  
unix  3      [ ]         STREAM     CONNECTED     869274   
unix  3      [ ]         STREAM     CONNECTED     24731    
unix  3      [ ]         STREAM     CONNECTED     1413433  
unix  3      [ ]         STREAM     CONNECTED     19742    
unix  3      [ ]         STREAM     CONNECTED     20987    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     18926    
unix  3      [ ]         STREAM     CONNECTED     27002    
unix  3      [ ]         STREAM     CONNECTED     1414437  
unix  3      [ ]         STREAM     CONNECTED     21793    
unix  3      [ ]         STREAM     CONNECTED     23114    
unix  2      [ ]         DGRAM                    17679    
unix  3      [ ]         STREAM     CONNECTED     21428    
unix  3      [ ]         STREAM     CONNECTED     27003    
unix  3      [ ]         STREAM     CONNECTED     20986    
unix  2      [ ]         DGRAM                    20781    
unix  3      [ ]         STREAM     CONNECTED     1414276  /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     18429    
unix  3      [ ]         STREAM     CONNECTED     21519    
unix  3      [ ]         STREAM     CONNECTED     18154    
unix  2      [ ]         DGRAM                    1414435  
unix  3      [ ]         STREAM     CONNECTED     22880    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     19176    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     27146    /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)>
unix  3      [ ]         STREAM     CONNECTED     21195    
unix  3      [ ]         STREAM     CONNECTED     22836    
unix  2      [ ]         DGRAM                    25107    
unix  3      [ ]         STREAM     CONNECTED     21429    /run/dbus/system_bus_socket
unix  2      [ ]         DGRAM                    1414271  
unix  3      [ ]         STREAM     CONNECTED     19854    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     22385    
unix  3      [ ]         STREAM     CONNECTED     22826    
unix  2      [ ]         DGRAM                    19595    
unix  2      [ ]         DGRAM                    16014    
unix  3      [ ]         STREAM     CONNECTED     21795    
unix  3      [ ]         STREAM     CONNECTED     21196    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     19775    
unix  3      [ ]         STREAM     CONNECTED     23646    
unix  2      [ ]         DGRAM                    36428    
unix  2      [ ]         DGRAM                    25236    
unix  3      [ ]         STREAM     CONNECTED     22827    /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    21202    
unix  3      [ ]         STREAM     CONNECTED     18694    
unix  2      [ ]         DGRAM                    1414274  
unix  3      [ ]         DGRAM                    1413431  
unix  3      [ ]         STREAM     CONNECTED     19774    
unix  3      [ ]         STREAM     CONNECTED     21013    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     21199    /run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     1355266  /run/systemd/journal/stdout
unix  2      [ ]         DGRAM                    15092    
unix  2      [ ]         DGRAM                    19779    
unix  3      [ ]         STREAM     CONNECTED     18237    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     24492    
unix  3      [ ]         STREAM     CONNECTED     22386    
unix  2      [ ]         DGRAM                    19526    
unix  3      [ ]         DGRAM                    17690    
unix  3      [ ]         DGRAM                    17689    
unix  3      [ ]         DGRAM                    240      
unix  2      [ ]         DGRAM                    19241    
unix  3      [ ]         STREAM     CONNECTED     24732    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     20776    /run/systemd/journal/stdout
unix  3      [ ]         STREAM     CONNECTED     1354462  
unix  3      [ ]         STREAM     CONNECTED     19776    /run/dbus/system_bus_socket
Active Bluetooth connections (w/o servers)
Proto  Destination       Source            State         PSM DCID   SCID      IMTU    OMTU Security
Proto  Destination       Source            State     Channel

2.47) netstat -tulpn : ports/addresses/pid/switches related auguments/parameters/arguments,(Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name )

Do not you wanna try netstat dash tulpn, all those switches, which is much better,

[root@iZ2vc5lqzt23aweti4j777Z ~]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1187/sshd           
tcp        0      0 0.0.0.0:37271           0.0.0.0:*               LISTEN      1240/rpc.statd      
tcp        0      0 0.0.0.0:2049            0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:5355            0.0.0.0:*               LISTEN      592/systemd-resolve 
tcp        0      0 0.0.0.0:34383           0.0.0.0:*               LISTEN      -                   
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1/systemd           
tcp        0      0 0.0.0.0:20048           0.0.0.0:*               LISTEN      1241/rpc.mountd     
tcp6       0      0 :::48661                :::*                    LISTEN      1240/rpc.statd      
tcp6       0      0 :::443                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::45697                :::*                    LISTEN      -                   
tcp6       0      0 :::2049                 :::*                    LISTEN      -                   
tcp6       0      0 :::5355                 :::*                    LISTEN      592/systemd-resolve 
tcp6       0      0 :::111                  :::*                    LISTEN      1/systemd           
tcp6       0      0 :::20048                :::*                    LISTEN      1241/rpc.mountd     
tcp6       0      0 :::80                   :::*                    LISTEN      1/systemd           
udp        0      0 0.0.0.0:57373           0.0.0.0:*                           -                   
udp        0      0 127.0.0.53:53           0.0.0.0:*                           592/systemd-resolve 
udp        0      0 0.0.0.0:111             0.0.0.0:*                           1/systemd           
udp        0      0 0.0.0.0:5355            0.0.0.0:*                           592/systemd-resolve 
udp        0      0 127.0.0.1:323           0.0.0.0:*                           662/chronyd         
udp        0      0 0.0.0.0:20048           0.0.0.0:*                           1241/rpc.mountd     
udp        0      0 0.0.0.0:37521           0.0.0.0:*                           1240/rpc.statd      
udp        0      0 127.0.0.1:1001          0.0.0.0:*                           1240/rpc.statd      
udp6       0      0 :::44135                :::*                                -                   
udp6       0      0 :::111                  :::*                                1/systemd           
udp6       0      0 :::5355                 :::*                                592/systemd-resolve 
udp6       0      0 ::1:323                 :::*                                662/chronyd         
udp6       0      0 :::57906                :::*                                1240/rpc.statd      
udp6       0      0 :::20048                :::*                                1241/rpc.mountd    

2.48) ss : show (Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port Process ) : similar with command: netstat

A more modern version is the ss comand, which is basically the same thing

[root@iZ2vc5lqzt23aweti4j777Z ~]# ss

Netid  State  Recv-Q   Send-Q                                                           Local Address:Port         Peer Address:Port     Process  

u_str  ESTAB  0        0                                                                            * 20791                   * 21524             

u_str  ESTAB  0        0                                                                            * 24491                   * 24492             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18594                   * 17672             

u_str  ESTAB  0        0          /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> 869612                  * 869274            

u_str  ESTAB  0        0                                                                            * 18671                   * 18237             

u_str  ESTAB  0        0                                                                            * 22879                   * 22880             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 21524                   * 20791             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 19778                   * 19742             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18431                   * 18428             

u_str  ESTAB  0        0                                                            /run/rpcbind.sock 25369                   * 23114             

u_str  ESTAB  0        0                                                                            * 27004                   * 27005             

u_str  ESTAB  0        0                                                                            * 27005                   * 27004             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 23823                   * 22836             

u_str  ESTAB  0        0                                                                            * 21198                   * 21199             

u_str  ESTAB  0        0                                                                            * 19852                   * 19854             

u_str  ESTAB  0        0                                                                            * 1445126                 * 0                 

u_str  ESTAB  0        0                                                                            * 19175                   * 19176             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18432                   * 18429             

u_str  ESTAB  0        0                                                                            * 18428                   * 18431             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 22660                   * 23646             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 21011                   * 21793             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18606                   * 18154             

u_str  ESTAB  0        0                                                                            * 1445146                 * 1445147           

u_str  ESTAB  0        0                                                                            * 17672                   * 18594             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18990                   * 18926             

u_str  ESTAB  0        0                                                                            * 26046                   * 27146             

u_str  ESTAB  0        0                                                                            * 869274                  * 869612            

u_str  ESTAB  0        0                                                                            * 24731                   * 24732             

u_str  ESTAB  0        0                                                                            * 19742                   * 19778             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 20987                   * 20986             

u_str  ESTAB  0        0                                                                            * 18926                   * 18990             

u_str  ESTAB  0        0                                                                            * 27002                   * 27003             

u_str  ESTAB  0        0                                                                            * 21793                   * 21011             

u_str  ESTAB  0        0                                                                            * 23114                   * 25369             

u_str  ESTAB  0        0                                                                            * 21428                   * 21429             

u_str  ESTAB  0        0                                                                            * 27003                   * 27002             

u_str  ESTAB  0        0                                                                            * 20986                   * 20987             

u_str  ESTAB  0        0                                                                            * 18429                   * 18432             

u_str  ESTAB  0        0                                                                            * 21519                   * 20776             

u_str  ESTAB  0        0                                                                            * 18154                   * 18606             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 1444448                 * 1444954           

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 22880                   * 22879             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 19176                   * 19175             

u_str  ESTAB  0        0          /usr/local/aegis/Aegis-<Guid(5A2C30A2-A87D-490A-9281-6765EDAD7CBA)> 27146                   * 26046             

u_str  ESTAB  0        0                                                                            * 21195                   * 21196             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 1444425                 * 1444422           

u_str  ESTAB  0        0                                                                            * 22836                   * 23823             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 21429                   * 21428             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 19854                   * 19852             

u_str  ESTAB  0        0                                                                            * 22385                   * 22386             

u_str  ESTAB  0        0                                                                            * 22826                   * 22827             

u_str  ESTAB  0        0                                                                            * 21795                   * 21013             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 21196                   * 21195             

u_str  ESTAB  0        0                                                                            * 19775                   * 19774             

u_str  ESTAB  0        0                                                                            * 23646                   * 22660             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 22827                   * 22826             

u_str  ESTAB  0        0                                                                            * 18694                   * 19776             

u_str  ESTAB  0        0                                                                            * 1445147                 * 1445146           

u_str  ESTAB  0        0                                                                            * 19774                   * 19775             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 21013                   * 21795             

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 21199                   * 21198             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 1355266                 * 1354462           

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 18237                   * 18671             

u_str  ESTAB  0        0                                                                            * 24492                   * 24491             

u_str  ESTAB  0        0                                                                            * 22386                   * 22385             

u_str  ESTAB  0        0                                                                            * 1444954                 * 1444448           

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 24732                   * 24731             

u_str  ESTAB  0        0                                                  /run/systemd/journal/stdout 20776                   * 21519             

u_str  ESTAB  0        0                                                                            * 1444422                 * 1444425           

u_str  ESTAB  0        0                                                                            * 1354462                 * 1355266           

u_str  ESTAB  0        0                                                  /run/dbus/system_bus_socket 19776                   * 18694             

udp    ESTAB  0        0                                                            172.23.95.44%eth0:bootpc      172.23.95.253:bootps            

tcp    ESTAB  0        36                                                                172.23.95.44:ssh          47.96.60.215:zmp               

tcp    ESTAB  0        0                                                                 172.23.95.44:51602       100.100.30.27:http 

2.49) ss -tulpn : similar with commands netstat -tulpin

Use a topen switches(), and it’s nice and pretty

[root@iZ2vc5lqzt23aweti4j777Z ~]# ss -tulpn
Netid             State              Recv-Q             Send-Q                          Local Address:Port                            Peer Address:Port             Process                                                                                                                                                             
udp               UNCONN             0                  0                                     0.0.0.0:57373                                0.0.0.0:*                                                                                                                                                                                    
udp               UNCONN             0                  0                               127.0.0.53%lo:53                                   0.0.0.0:*                 users:(("systemd-resolve",pid=592,fd=16))                                                                                                                          
udp               UNCONN             0                  0                                     0.0.0.0:111                                  0.0.0.0:*   

2.50) iptables : work with no effect

Now what about your firewall? Are things getting through or do you wanna block’em? if you wanna to allow pour 80, you could run something like this, which is honestly kind of complex

[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT

2.51) sudo ufw allow 80 : not applicable on ECS

That’s why UFW is way easier, this sits on top of ip tables and makes it so much easier. If I want to allow pour 80, ufw allow 80 as sudo
在这里插入图片描述
See what you’re allowing with ufw status, which right now it’s not even enabled, so we can enable it with ufw enable, then check our status one more, beautiful
在这里插入图片描述

2.52) uname or uname -a

Now if you wanna know a bit more about your system, you can use the uname command, uname, it just tells you a little bit. If you type in dash a, it will tell you a lot

[root@iZ2vc5lqzt23aweti4j777Z ~]# uname
Linux
[root@iZ2vc5lqzt23aweti4j777Z ~]# uname -a
Linux iZ2vc5lqzt23aweti4j777Z 5.10.134-16.1.al8.x86_64 #1 SMP Thu Dec 7 14:11:24 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

2.53) neofetch : CAN NOT INSTALL

Now if you wanna a prettier version of all this, try neofetch, go install that real quick, apt install neofetch, then simply run neofetch, how pretty is that!
在这里插入图片描述

2.54) cal

The cal command will give you a quick little calendar here. I don’t know why you want it, but it is kinda cool. If yoou don’t have it, you can install it with sudo install apt n cal

[root@iZ2vc5lqzt23aweti4j777Z ~]# cal
    January 2024    
Su Mo Tu We Th Fr Sa
    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

2.55) echo “math expression” | calculate

If you wanna do some math right here in your terminal (终端进行一些数学运算),you can echo a problem out to bc 7, and bc will tell you what the answer is.

[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "9-13"| bc 
-4
[root@iZ2vc5lqzt23aweti4j777Z ~]# echo "9*13" | bc
117

2.56) free : how much memory is available on your system

If you wanna check your memory and see how much memory you have available on your system, just type in free and what’s going on with your swap (交换空间)

[root@iZ2vc5lqzt23aweti4j777Z ~]# free
              total        used        free      shared  buff/cache   available
Mem:        1934308      259240      560256        6532     1114812     1493608
Swap:             0           0           0

在这里插入图片描述

2.57) df or df -H : how much is disk space free?

How much disk space do you have? you can use the df command and more specifically df -H comand, you gonna use that all the time

fs (filesystem, to wit, disk name on Windows)

[root@iZ2vc5lqzt23aweti4j777Z ~]# df
Filesystem     1K-blocks    Used Available Use% Mounted on
devtmpfs          948968       0    948968   0% /dev
tmpfs             967152       0    967152   0% /dev/shm
tmpfs             967152     452    966700   1% /run
tmpfs             967152       0    967152   0% /sys/fs/cgroup
/dev/vda1       41103804 5636248  33563848  15% /
tmpfs             967152       0    967152   0% /tmp
tmpfs             193428       0    193428   0% /run/user/0

[root@iZ2vc5lqzt23aweti4j777Z ~]# df -H
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        972M     0  972M   0% /dev
tmpfs           991M     0  991M   0% /dev/shm
tmpfs           991M  463k  990M   1% /run
tmpfs           991M     0  991M   0% /sys/fs/cgroup
/dev/vda1        43G  5.8G   35G  15% /
tmpfs           991M     0  991M   0% /tmp
tmpfs           199M     0  199M   0% /run/user/0

2.58) ps or ps -aux : check the process

What about the stuff running n your ystem? the process. We can use the ps comamand, which won’t tell you much unless you use ps dash aux switch, then we’ll get all the goodies

[root@iZ2vc5lqzt23aweti4j777Z ~]# ps
    PID TTY          TIME CMD
  79922 pts/0    00:00:00 bash
  79977 pts/0    00:00:00 ps

[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -aux
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.4 103480  9436 ?        Ss   Jan12   1:27 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
root           2  0.0  0.0      0     0 ?        S    Jan12   0:00 [kthreadd]
root           3  0.0  0.0      0     0 ?        I<   Jan12   0:00 [rcu_gp]
root           4  0.0  0.0      0     0 ?        I<   Jan12   0:00 [rcu_par_gp]
root           6  0.0  0.0      0     0 ?        I<   Jan12   0:00 [kworker/0:0H-events_highpri]

2.59) top : the processes eating all your stuffs

If you wanna see the processes eating all your stuffs, type in top; If you wanna see in a prettier way, type in htop (not worl now), that is sleek

top - 20:25:24 up 18 days, 52 min,  1 user,  load average: 0.00, 0.00, 0.00
Tasks: 131 total,   1 running, 130 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.5 us,  0.2 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
MiB Mem :   1889.0 total,    544.8 free,    254.4 used,   1089.8 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.   1457.1 avail Mem 

    PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND                                                                    
   1473 root      10 -10  211144  44320  17152 S   0.7   2.3 135:23.79 AliYunDunMonito                                                            
    762 root      20   0  474984  25112  11524 S   0.3   1.3  44:14.58 tuned                                                                      
   1462 root      10 -10  113516  20964  11868 S   0.3   1.1  89:09.95 AliYunDun                                                                  
  49806 root      10 -10   43320   7468   5704 S   0.3   0.4   6:05.64 AliYunDunUpdate                                                            
  80276 root      20   0  227200   4744   4096 R   0.3   0.2   0:00.07 top                                                                        
      1 root      20   0  103480   9436   6596 S   0.0   0.5   1:28.03 systemd              

NOT WORK: HTOP
在这里插入图片描述

2.60) kill -9 pid or pkill -f file_name (not work, maybe differet process)

If you have a process that you want to kill, stop it. We can do that with kill command; first we have to find the prcess id. I’ll do that with ps. I’ll grep for that script I wanna kill, there it is

There is the process id and I’ll kill the process with dash nine signal, forcibly killing it. And the process id ***, goodbye, buddy, it’s gone

Now even better than kill is pkill, because you don’t need to know the process id, type in kill, use the f switch and specify the name, you kind of get it is, and it did

unsolved:
(ps -aux | grep file_name)
(pkill -f file_name)
在这里插入图片描述在这里插入图片描述

  • Samples on kill command
terminal one: 

[root@iZ2vc5lqzt23aweti4j777Z ~]# ping www.baidu.com

terminal two: 
[root@iZ2vc5lqzt23aweti4j777Z ~]# ping www.tencent.com
terminal thee: 

[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -ef | grep ping
root        4245    4055  0 14:07 pts/0    00:00:00 ping www.baidu.com
root        4395    4368  0 14:08 pts/2    00:00:00 grep --color=auto ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -ef | grep ping
root        4245    4055  0 14:07 pts/0    00:00:00 ping www.baidu.com
root        4536    4509  0 14:09 pts/3    00:00:00 ping www.tencent.com
root        4595    4368  0 14:09 pts/2    00:00:00 grep --color=auto ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# kill -9 4245
[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -ef | grep ping
root        4536    4509  0 14:09 pts/3    00:00:00 ping www.tencent.com
root        4715    4368  0 14:11 pts/2    00:00:00 grep --color=auto ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -ef | grep ping
root        4536    4509  0 14:09 pts/3    00:00:00 ping www.tencent.com
root        4717    4055  0 14:14 pts/0    00:00:00 ping www.baidu.com
root        4779    4368  0 14:14 pts/2    00:00:00 grep --color=auto ping

[root@iZ2vc5lqzt23aweti4j777Z ~]# killall ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -aux | grep ping
root        4964  0.0  0.1 227616  2268 pts/0    S+   14:21   0:00 ping www.baidu.com
root        5025  0.0  0.0 221528   868 pts/2    S+   14:21   0:00 grep --color=auto ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# pkill -f ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# ps -aux | grep ping
root        5152  0.0  0.0 221528   868 pts/2    S+   14:33   0:00 grep --color=auto ping
[root@iZ2vc5lqzt23aweti4j777Z ~]# 

PS: global regular expression print
Grep, short for “global regular expression print”

2.61) systemctl start apache, or system status apache | not work,but httpd working

To stop, start and restart the services or Damon and Linux, you can use the systemctl command, at your systems using system D, if not, it will be using service, so to stop a service system ctl, we do apache two, replace with start, we’ll restart the service, type in status to see what’s going on, or do a restart,

Example for systemctl command:
systemctl start httpd
systemctl start httpd
systemctl enable httpd

[root@iZ2vc5lqzt23aweti4j777Z ~]# systemctl stop httpd
Warning: Stopping httpd.service, but it can still be activated by:
  httpd.socket
[root@iZ2vc5lqzt23aweti4j777Z ~]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/httpd.service.d
           └─php-fpm.conf
   Active: inactive (dead) since Wed 2024-01-31 09:25:02 CST; 32s ago

在这里插入图片描述

2.62) history : check which commands we’ve ready typed in

Now we’ve gone through a lot of commands. If want a history of what we did, type in history, and that’s a lot of stuff

[root@iZ2vc5lqzt23aweti4j777Z ~]# history
    7  ls -al
    8  ls
    9  ll
   10  cd Folder_Dec19th2023/
   11  ll

6.63) sudo reboot, sudo shutdown or sudo shutdown -h now : not root user, but those other users

And finally, if you wanna reboot, sudo reboot. If you wanna shudown, sudo shutdown, this will shutdown machine in about one minutes. If yu wanna do it now, do a dash h now, which I’ll do

  • root shutdown
[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo reboot


[root@iZ2vc5lqzt23aweti4j777Z ~]# sudo shutdown -h
Shutdown scheduled for Wed 2024-01-31 10:13:43 CST, use 'shutdown -c' to cancel.
  • switch user shutdown
[root@iZ2vc5lqzt23aweti4j777Z home]# su Dave
[Dave@iZ2vc5lqzt23aweti4j777Z home]$ sudo reboot

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for Dave: 
Dave is not in the sudoers file.  This incident will be reported. (TDL: figure out in future if possible, commands as systemctl, sudo shutdown (needs sudo fils), htop, kill, pkill, system status apache,etc )

在这里插入图片描述
That’s the end of the video, talks to you guys later


  1. click the heels: This is a reference to the movie Wizard of Oz.
    At the end of the film, Glinda reveals one of the slippers’ abilities: Dorothy can return home to Kansas by simply clicking her heels three times and repeating, “There’s no place like home.”
    http://en.wikipedia.org/wiki/Ruby_slippers
    I think this means “No problem!” but I’m not certain. It could be ironic meaning “It’s not that easy.”
    Let’s see what others say.
    Note “click your heels” is different from “kick your heels”. ↩︎

  2. to correct/reclafication: in China here, 1) vim fileName.txt --> 2) only type/hit key i (not bothered esc + i, different Linux OS probably) -->3) esc+shift+colon + wq! or q! ↩︎

  3. linux shred文件后如何恢复
    在Linux中使用shred命令来覆写或删除文件内容。由于shred会将数据完全清空并重新编程为随机字节,因此无法直接从已经被shred的文件中进行恢复。然而,可以通过其他工具来尝试恢复部分被shred的文件。下面列举了两种常用的方法: ↩︎

  4. 在linux中,执行文件是指的是该文件可以被运行,文件有“x”权限;执行文件可以是一个代码文件(脚本文件),也可以是一个二进制文件。一个文件运行有两种方式:1、用解释器直接去运行文件;2、利用“./”运行文件,语法“./ 文件名”。 ↩︎

  5. 在linux中,x是指“执行”权限。x权限对文件和目录的作用不一样:1、对于文件来说,表示该文件可运行,特指shell脚本文件,对于普通文件没有影响;2、对于目录来说,代表用户可以进入指定目录,赋予x权限的用户可以使用cd命令来切换目录。 ↩︎

  6. The CTL (Common Type Library) namespace is a collection of interfaces, data types, and constants that are used by various Microsoft technologies, including Windows, Internet Explorer, and Office. The CTL namespace is defined in the ctluuid.h header file. ↩︎

  7. binary calculate ↩︎

;