Some basic knowledge of Linux entry


[switching mode between graphic mode and text mode]

The Linux default provides six command window terminals for us to log in. By default, we log in to the first window, that is, tty1. The six windows are tty1, tty2… Tty6. You can press Ctrl + Alt + F1 ~ F6 to switch them. If you have installed the graphical interface, you can enter the graphical interface by default. At this time, you can press Ctrl + Alt + F1 ~ F6 to enter one of the command window interfaces. When you enter the command window interface and then return to the graphical interface, just press Ctrl + Alt + F7 to return. If you use a VMware virtual machine, the shortcut keys for switching the command window are Alt + space + F1 ~ F6 If you are in the graphical interface, press Alt + Shift + Ctrl + F1 ~ F6 to switch to the command window.

[learn to use shortcut keys]

CTRL + C: This is the shortcut key used to terminate the current command. Of course, you can also enter a large string of characters. If you don’t want it to run directly Ctrl + C, the cursor will jump to the next line.

Tab: this key is the most useful key, and it is also the key with the highest probability of hitting by the author. Because when you type half of an order, it will help you complete it. It’s not just a command. When you type a directory, you can also complete it. If you don’t believe it, try it.


CTRL + D: to exit the current terminal, you can also enter exit.

CTRL + Z: pause the current process. For example, if you are running a command and suddenly feel a problem and want to pause, you can use this shortcut key. After the pause, you can use FG to resume it.
Enter man ls in the format of man + command

You will see the relevant help documents. From the introduction of the command to the introduction of the parameters and usage of the command are very detailed. Not bad.


[Linux system directory structure]

After logging into the system, enter LS / in the current command window, and you will see
2015623163215087.png (640×382)

CTRL + L: clear the screen and move the cursor to the first line.


[learn to query help documents – man]

This man is usually used to view the help document of a command. For example:
2015623163239180.png (507×52)

The following is an explanation of these directories:

/Bin Bin is the abbreviation of binary. This directory holds the most frequently used commands.

/Boot stores some core files used when starting Linux, including some connection files and image files.

/Dev dev is an abbreviation for device. The external devices of Linux are stored in this directory. The way to access devices and files in Linux is the same.

/The etc directory is used to store all configuration files and subdirectories required for system management.

/Home user’s home directory. In Linux, each user has its own directory. Generally, the directory name is named after the user’s account.

/Lib directory stores the most basic dynamic connection shared library of the system, which is similar to the DLL file in windows. Almost all applications need these shared libraries.

/The lost + found directory is generally empty. When the system shuts down illegally, some files are stored here.

/Media Linux system will automatically identify some devices, such as USB flash disk, optical drive, etc. after identification, Linux will mount the identified devices to this directory.

/The MNT system provides this directory to allow users to temporarily mount other file systems. We can mount the optical drive on / MNT /, and then enter this directory to view the contents of the optical drive.

/Opt this is the directory where additional software is installed for the host. For example, if you install an Oracle database, you can put it in this directory. The default is empty.

/The proc directory is a virtual directory, which is the mapping of system memory. We can access this directory directly to obtain system information. The contents of this directory are not on the hard disk but in the memory. We can also directly modify some files in it. For example, we can mask the ping command of the host through the following command to prevent others from Ping your machine:

echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all。

/Root this directory is the user home directory of the system administrator, also known as the super authority.

/SBIN s means super user. Here is the system management program used by the system administrator.

/SELinux is a unique directory of RedHat / CentOS. SELinux is a security mechanism similar to windows firewall, but this mechanism is complex. This directory is used to store SELinux related files.

/SRV this directory stores some data to be extracted after the service is started.

/Sys this is Linux 2 A big change in the 6 kernel. A new file system sysfs in the 2.6 kernel is installed in this directory. The sysfs file system integrates the information of the following three file systems: proc file system for process information, devfs file system for device and devpts file system for pseudo terminal. The file system is a visual reflection of the kernel device tree. When a kernel object is created, the corresponding files and directories are also created in the kernel object subsystem.

/TMP this directory is used to store some temporary files.

/Usr this is a very important directory. Many user applications and files are placed in this directory, similar to the program files directory under windows.

/Usr / bin: application used by system users.

/Usr / SBIN: a more advanced hypervisor and system daemon used by super users.

/Usr / SRC: the default placement directory for kernel source code.

/There are constantly expanding things stored in the VaR directory. We are used to putting those directories that are often modified under this directory. Including various log files.

In Linux system, there are several directories that are important. You should pay attention not to delete or change internal files at will/ Etc: as mentioned above, this is the configuration file in the system. If you change a file in this directory, the system may not start/ Bin, / SBIN, / usr / bin, / usr / SBIN: This is the default directory where the execution files are placed. For example, LS is in the / bin / LS directory. It is worth mentioning that / bin, / usr / bin are the instructions for system users (pass through users except root), while / SBIN, / usr / SBIN are the instructions for root/ Var: This is a very important directory. There are many programs running on the system, so each program will have a corresponding log, and these logs will be recorded in this directory, specifically in the / var / log directory. In addition, the default placement of mail is also here.


[how to shut down correctly]

In fact, in the field of Linux, it is mostly used on the server, and rarely encountered the operation of shutdown. After all, there is no end to running a service on the server. It will be shut down only under special circumstances.

Linux is different from windows. Under Linux, because each program (or service) is executed in the background, behind the screen you can’t see, there may be quite a few people working on your host at the same time, such as browsing web pages, transmitting letters, transmitting files through FTP, etc. if you directly press the power switch to shut down, Then other people’s data may be interrupted! That’s nerve racking! In addition, the biggest problem is that if it is not shut down normally, the file system may be damaged (because there is no time to write the data back to the file, there will be problems with the files of some services!).

If you want to shut down, you must ensure that no other users are online in the current system. You can issue the who command. If you want to see the online status of the network, you can issue the netstat – a command. If you want to see the background execution program, you can execute the PS – aux command. Using these instructions can give you a little understanding of the current use status of the host! (these commands will be mentioned in later chapters. Now just understand them!)

The correct shutdown process is: sysnc? shutdown ? reboot ? halt

Copy code

The code is as follows:


Synchronize data from memory to hard disk.

Copy code

The code is as follows:


Shutdown command, you can man shutdown to see the help document. For example, you can run the following command to shut down:

Copy code

The code is as follows:

shutdown –h 10

The command ‘this server will shut down after 10 minutes’ tells you that the computer will shut down in 10 minutes and will be displayed on the current screen of the logged in user.

Copy code

The code is as follows:

Shutdown –h now

Turn it off immediately

Copy code

The code is as follows:

Shutdown –h 20:25

The system will shut down at 20:25 today

Copy code

The code is as follows:

Shutdown –h +10

Shut down in ten minutes

Copy code

The code is as follows:

Shutdown –r now

The system restarts immediately

Copy code

The code is as follows:

Shutdown –r +10

The system will restart in ten minutes

Reboot means restart, which is equivalent to shutdown – r now

Halt shuts down the system, which is equivalent to shutdown – h now and poweroff


Finally, whether you restart or shut down the system, you must first run the sync command to write the data in memory to disk. The shutdown commands are shutdown – h now halt poweroff and init 0, and the system restart commands are shutdown – r now reboot init 6