Basic introduction to linux series -- Chapter 4 common commands for remote management

Linux The column contains this content
5 articles 1 subscription

Common commands for remote management


  • Shutdown / restart
    • shutdown
  • View or configure network card information
    • ifconfig
    • ping
  • Remote login and copying files
    • ssh
    • scp

01. Shutdown / restart

Serial numbercommandCorresponding Englisheffect
01Shutdown option timeshutdownShutdown / restart

one point oneshutdown

  • shutdownCommand cansecurity closeOrreboot system again


  • Do not specify options and parameters, default1 minuteAfterTurn off the computer
  • When maintaining the server remotely, it is best not to shut down the system, but to restart the system
  • Examples of common commands
#Restart the operating system, where now means now
$ shutdown-r now

#Shut down immediately, where now means now
$ shutdownnow

#The system will shut down at 20:25 today
$ shutdown20:25

#The system will shut down automatically in ten minutes
$ shutdown+10

#Cancels the previously specified shutdown schedule
$ shutdown-c

02. View or configure network card information

Serial numbercommandCorresponding Englisheffect
01ifconfigconfigure a network interfaceView / configure the current network card configuration information of the computer
02Ping IP addresspingWhether the connection of the target IP address is normal is detected

2.1 network card and IP address

network card

  • Network card is a hardware device specially responsible for network communication
  • IP addressIs the address information set on the network card

We can putcomputerCompareTelephonenetwork cardamount toSIM cardIP addressamount toTelephone number

IP address

  • On every networked computerBothIP addressIt is an important setting to ensure normal communication between computers

Note: the IP address of each computer cannot be the same, otherwise there will be IP address conflict and there is no way to communicate normally

Tip: AboutIP addressThe details of the will be explained in detail at the employment class meeting!

two point twoifconfig

  • ifconfigYou can view / configure the current network card configuration information of the computer
#View network card configuration information
$ ifconfig

#View the IP address corresponding to the network card
$ ifconfig | grepinet

Tip: there may be one in a computerPhysical network cardAndMultiple virtual network cards, in Linux, the name of the physical network card is usuallyensXXexpress

  • by the name ofLocal loopback / loopback addressIt is generally used to test whether the local network card is normal

two point threeping

#Whether the target host is connected normally is detected
$ pingIP address

#Check that the local network card is working normally
$ ping127.0.0.1
  • pingIt is generally used to detect the network between the current computer and the target computerIs it unobstructedThe higher the value, the slower the speed
  • pingIts working principle is similar to that of submarine sonar,pingThis command is taken fromSonar sound
  • Network administrators oftenpingUsed as a verb——Ping the computer x to see if it is on

Principle: all machines on the network haveUnique IP address, we giveDestination IP addressWhen sending a packet, the other party will return a packet. According to the returned packet and time, we can determine the existence of the target host

Tip: in Linux, if you want to terminate the execution of a terminal program, most can use itCTRL + C

03. Remote login and copying files

Serial numbercommandCorresponding Englisheffect
01SSH username @ IPsecure shellShutdown / restart
02SCP user name @ IP: file name or path user name @ IP: file name or pathsecure copyRemote copy files

three point onesshFoundation (key)

In Linux, SSH isVery commonTools, throughSSH clientWe can connect to the runningSsh serverOn a remote machine

Insert picture description here

  • SSH clientIt is a kind of useSecure Shell(SSH)A software program that connects to a remote computer using a protocol
  • SSHIt is more reliable at present,Designed for remote login sessions and other network servicesProtocol providing security
    • UseSSH protocolCan be effectivePrevent information leakage during remote management
    • PassSSH protocolIt can encrypt all transmitted data and prevent DNS spoofing and IP spoofing
  • SSHAnother advantage of is that the transmitted data can be compressed, so it can speed up the transmission speed

1) Domain name and port number

domain name
  • By a stringSeparated by dotsName composition of, for
  • YesIP addressAlias, convenient for users to remember
Port number
  • IP address: passedIP addressFound on the networkcomputer

  • Port number: passedPort numberCan findApplications running on the computer

    • Ssh serverThe default port number istwenty-two, if it is the default port number, it can be omitted during connection
  • List of common service port numbers:

Serial numberservicePort number
01Ssh servertwenty-two
02Web servereighty
03HTTPSfour hundred and forty-three
04FTP servertwenty-one

2) Simple use of SSH client

ssh [-p port]user@remote
  • userIs the user name on the remote machine. If it is not specified, it defaults to the current user
  • remoteIs the address of the remote machine, which can beIPdomain name, orAliases mentioned later
  • portYesPort on which ssh server listens, if not specified, it is the default valuetwenty-two


  • useexitLog out of the current user

be careful:

  • sshThis terminal command can only be used inLinuxOrUNIXUse under system
  • If inWindowsIn the system, you can installPuTTYOrXShellJust the client software


  • At work, the port number of ssh server is likely to beNot 22, if this is the case, you need to use-pOption, specify the correct port number, otherwise you cannot connect to the server normally

3) Installation of SSH client under Windows

  • Putty ~sgtatham/putty/latest.html
  • XShell

It is recommended to download the official installation program from the official website

three point twoscp(Master)

  • SCP issecure copy, which is used under LinuxRemote copy fileCommand of
  • itsThe address format is basically the same as SSHIt should be noted that, the port is specified in uppercase-PNot lowercase

Insert picture description here

#Copy the file in the current local directory to desktop / in the remote home directory
#Note: `: ` if the following path is not an absolute path, the user's home directory will be used as the reference path
scp-P port  user@remote :Desktop/

#Copy the desktop / file in the remote home directory to in the local current directory
scp-P port  user@remote :Desktop/

#Add the - R option to transfer folders
#Copy the demo folder in the current directory to the desktop in the remote home directory
scp-r demo  user@remote :Desktop

#Copy the desktop under the remote home directory to the demo folder under the current directory
scp-r  user@remote :Desktop demo
-rIf the given source file is a directory file, SCP will recursively copy all subdirectories and files in the directory, and the target file must be a directory name
-PIf the port of the remote ssh server is not 22, you need to use the uppercase - P option to specify the port

be careful:

  • scpThis terminal command can only be used inLinuxOrUNIXUse under system
  • If inWindowsIn the system, you can installPuTTY, usepscpCommand line tools or installationFileZillauseFTPFile transfer


  • Official website:
  • FileZillaWhen transferring files, useFTP serviceinstead ofSSH serviceTherefore, the port number should be set totwenty-one

3.3 SSH advanced

  • Password free login
  • Configure alias

Tip: all SSH configuration information is saved in the user's home directory.sshDirectory

1) Password free login

  • Configure public key
    • Executessh-The SSH key can be generated and you can enter all the way
  • Upload public key to server
    • Executessh-copy-id -p port user@remote, we can let the remote server remember our public key
Sketch Map

Insert picture description here

Asymmetric encryption algorithm

  • usePublic keyEncrypted data, need to usePrivate keydecrypt
  • usePrivate keyEncrypted data, need to usePublic keydecrypt

2) Configure alias

Enter every timessh -p port user@remote, it will be very troublesome after a long time, especially whenuser, remoteAndportHave to input, and it's hard to remember

AndConfigure aliasIt can make us further lazy, for example:ssh macTo replace such a long string above, then~/.ssh/configThe following contents are added:

Host mac
Hostname IP address
User itheima
Port 22

Available after savingssh macRemote login has been realized,scpIt can also be used

Creation is not easy, white whoring is not good. Your support and recognition is the biggest driving force for my creation. See you in the next article!

Dragon youth

If there are any mistakes in this blog, please comment and advice. Thank you very much!
Insert picture description here

  • one
    give the thumbs-up
  • one
  • four
  • One key three links
    One key three links
  • Sweep and share posters

Insert expression
©️ 2020 CSDN Skin theme: swimming - white Designer: Bai Songlin Return to home page
Paid inelement
Payment with balance
Click retrieve
Code scanning payment
Wallet balance 0

Deduction Description:

1. The balance is the virtual currency of wallet recharge, and the payment amount is deducted according to the ratio of 1:1.
2. The balance cannot be purchased and downloaded directly. You can buy VIP, c-coin package, paid column and courses.

Balance recharge