Unlike Windows, which is easy to operate, Linux is more terminal. More than 70% of servers run Linux, so Linux is more for servers or developers, although Ubuntu’s desktop software is already doing well. So this article mainly introduces how to start operating Linux through the terminal.

Master key

First, the man command is a core command. With this command you can view the manual of any command. Man is short for manual. For example, you can view the method of using the ls command. When you have any doubts about a command, use this command to get help. You can even use man man to see how the man command works.

In addition to the man command, you can also use the command -h command to check the usage of a command. In this case, you can use the built-in parameter -h to check the usage of a command.

Sometimes we get stuck with lengthy documentation in both of these ways. You can use the TLDR command in a more concise way. TLDR means too long, don’t read. TLDR provides a brief command description and examples of common command usage. If you don’t need to see the details of the command, you only need to know the direct use of the command, use TLDR. Click to jump to GitHub.

The above three methods can help us to see how any command is used, which is a kind of master key.

User management

Unlike the Windows login interface, Linux starts up and waits for you as shown below, a text window that lets you enter your username and password. Anything you want to do can only be done from the command line.

Like the Administrator in Windows, Linux calls root to have the highest privileges on the system.

Once in the system, you can use the passwd command to change the password. You can create a new user with userAdd. Linux has the concept of users and user groups. If useradd does not specify a user group, the system will create a group for you with the same user name. You can also specify a user group by using the -g parameter.

Linux was designed to be all about files. After the preceding two commands are executed, the /etc/passwd and /etc/group files are modified. You can use the cat command to view the contents of both files.

File management

File systems have the concept of folders and files, and folders can contain subfolders and files. This creates a tree structure to manage hierarchical relationships between files.

We can change the current directory by using CD. CD can be followed by relative and absolute paths. The other CD.. You can return to the previous directory without entering redundant path information.

Ls Displays the directory structure under the current folder. The -l option displays the directory structure in a list and lists related file information. The -a option views all files, including hidden files starting with –.

In addition, you can use chown to change the owner of a file, that is, the user who can operate the file. CHGRP Changes the file group.

Mkdir creates a directory, rmdir deletes a directory. Rm can delete directories and files using the corresponding parameters.

Cp can copy a file, mv can move a file or change the file name.

Cat can view the contents of a file, but it prints out the entire contents of the file, and when the contents are too long, you can pipe in other commands to optimize. Head command, for example, the cat file | head – 5 representative to view the contents of the file, pass through a pipeline to head the order, then the head command will list the first five lines. Other auxiliary commands include tail, more, and less.

Vim is the Swiss Army knife of text editing under the text window. You can use it to write code like an IDE. You can first master several modes and simple file editing, save operations. Because of the steep learning curve, it takes time to master. After installing Vim, you can install a tutorial software called VimTutor. After learning the tutorial, you can form an overall understanding of Vim and master the basic operation.

Software installation

Download the installation package and install it

Ubuntu, for example, uses deb as the installation package. Related commands are as follows:

/ / install software DPKG -i JDK. Deb / / to look for in the installed software DPKG -l | grep JDK/DPKG/delete software - r JDKCopy the code

In the command to find software, pipes are also used, which means that all installed software information is passed to grep. Grep is a filtering and filtering command to find content with JDK characters.

CentOS also has these capabilities, but the command is changed to RPM, the details can be explored by yourself.

Software manager installs software

Just like the Tencent software manager on Windows integrated most software, available for download and installation. Linux also provides a corresponding command tool.

Using Ubuntu as an example, use the software manager tool to perform the following operations:

// Install the software apt-cache search JDK // delete the software apt-get purge JDKCopy the code

The software manager can download the software from the Internet only when the corresponding server provides the download service. You can check the source address of the software in /etc/apt/sources.list.

CentOS corresponds to the command tool yum.

Download the file to configure environment variables

When the shell executes a command, it looks for the command in the directory configured for the environment variable PATH and runs the program.

So installing software is actually a process of downloading software and unpacking it; Configure environment variables. In both cases, tools help us block this process.

We can do this manually.

Download the software package using wget or curl and decompress it using tar or unzip. After decompressing, run export PATH=/your/directory:$PATH to update the environment variables, and then run the newly installed command on the terminal.

To run the program

When we type a command, we are actually running a program. But sometimes we come across a program running for a long time, but we want to finish what to do? You can use Ctrl + C to end the execution of the program.

We can also run a program in the background by nohup Command &. Background running procedures we need to cooperate with the PS command to view, through the kill command to kill a program.

Shutdown and restart

Finally, use shutdown -h now to shutdown the machine immediately, although you can modify the parameters to shutdown the machine periodically. Run the reboot command to restart the system.

! Scan the code to follow the wechat official account