Home >System Tutorial >LINUX >Five Linux Terminal Command Tips for Newbies to Master

Five Linux Terminal Command Tips for Newbies to Master

王林
王林forward
2024-02-14 17:45:111346browse

I personally am a big fan of "Neon Genesis Evangelion", so here is a line: "People are afraid of the dark, so they try to depict the outline of flames in it." For many Linux newcomers, the gloomy screen of the terminal is also the same It's a kind of darkness - so people desperately use GUI to replace it.

Although graphical user interfaces do represent the friendly side of modern computing and are easier to use in most cases. However, sometimes the command line still has its unique advantages. As long as you have some basic knowledge, you can use the command line to easily solve the problem when the user interface fails to start or needs maintenance.

For beginners, as long as you master the following five commands, you can easily play Linux.

sudo

If commands are divided into classes, then sudo is undoubtedly the most worthy of respect. What Sudo does is very simple: it will run any command with superuser (or root) privileges. Whether you are updating the system or changing configuration files, running commands with sudo is essential. Five Linux Terminal Command Tips for Newbies to Master

Since /mnt belongs to root, you need to use sudo to create a directory in /mnt.

Sudo also allows users to damage the system or view the privacy of other users. Because of this, the system will give the following prompt when using sudo for the first time:

We believe you have received general guidance from your local system administrator. The specific content usually boils down to the following three points:

(1) Respect the privacy of others.

(2) Think twice before entering.

(3)The greater the ability, the greater the responsibility.

If you want to edit or modify any files outside your own user's home directory, you often need to use sudo. To use sudo, your user needs to be in the sudoers file or as a member of the superuser group (usually 'wheel' or 'sudo'). Five Linux Terminal Command Tips for Newbies to Master

The above picture shows the contents of a typical sudoers file, which specifies the groups that are allowed to perform root access. Please be careful not to assign sudo access to users or groups that do not require a password.

Due to the huge power of sudo, if you do not know the specific function of the command, do not add sudo at will. Many friends may have heard of the prank command sudorm–R /, which will recursively delete every file on the system without any additional prompts from the operating system. So as mentioned before, "think before you type."

Package Manager Tool

The number one reason to use sudo is to add or remove programs to the PC through the package manager. Although the three major package managers mentioned here each have different command parameters and syntax, they can all perform the same three basic functions: install packages, remove packages, and upgrade all packages on the system. (Note: Unless you are logged in as root, you will need to add sudo to run these commands.) Five Linux Terminal Command Tips for Newbies to Master

Use pacman to upgrade the system on Arch Linux. Please note that sudo is used before the pacman command.

yum (红帽/Fedora/CentOS)

Install software package:

yum install 

Remove package:

yum remove 

Upgrading the system:

yum update
apt (Debian/Ubuntu/Mint)

Install software package:

apt install 

Remove package:

apt remove 

Upgrading the system:

apt update
apt upgrade
pacman (Arch/Manjaro)

Install software package:

pacman -S 

Remove package:

pacman -R 

Upgrading the system:

pacman -Syu

The functions of each software package manager are of course more than this, but listed here are the three most commonly used functions. No matter which Linux distribution you choose, you should be comfortable using your package manager and know where to find documentation.

systemctl

For a long time, background programs in Linux - daemons - have used a series of scripts called initscripts. For newcomers, initscript is often difficult to read and interpret or modify. Recently, initscript has been replaced by a service management application called Systemd. If you are using a newer Linux distribution, it is appropriate to learn how to use Systemd to start the services you need. Five Linux Terminal Command Tips for Newbies to Master

Disable and re-enable the NetworkManager service at boot

There are various functions that can be achieved using Systemd (Unix programs usually only focus on one function and make it the best). However, you should still consider the following five keywords when using systemd.

When starting the service, use the start keyword:

systemctl start 

Similarly, if you need to restart a failed service or change its configuration, use restart:

systemctl restart 

To stop the service, use stop:

systemctl stop 

To enable each service at boot time, use enable:

systemctl enable 

Finally, use disable to disable the service from starting during boot:

systemctl disable 

ls

Although simple and intuitive, the role of ls is beyond everyone's idea. In terms of effectiveness, the ls command can list all files and folders under a specific path. By default, it lists the files and folders in the current working directory (usually the user's home directory). Of course, you can also use it to find content under a specific path. Five Linux Terminal Command Tips for Newbies to Master

You can add a variety of options to the ls command, the most commonly used of which is -l, which will display file permissions and ownership.

So, as the Linux version of dir, why does ls play such an important role? First of all, it can help you find subdirectories in configuration files. It can also view file names in a certain environment without the need for a GUI. Since Linux filenames and commands are case-sensitive, it can easily figure out the exact spelling. In short, you can use ls as your own reconnaissance aircraft to explore surrounding systems.

man

Sometimes, we may need help but don't have access to the Internet. In this dire situation, man can help everyone get out of trouble.

In fact, the man command is manual, which is the abbreviation of manual, and can display command documents in an "online" manner for information stored in the computer. If you need to know the function of chmod, you only need to enter man chmod in the terminal. In addition, you can use the up and down arrows or the PgUp and PgDn keys to turn pages in man. After reading, press Q to exit. Five Linux Terminal Command Tips for Newbies to Master

Man page for ls command

Although man can be of great help in the absence of the Internet, Google is still the most powerful resource acquisition tool. It should be pointed out that the first thing displayed in Google search results is actually the web version of the description like the man page.

Summarize

Of course, the five commands introduced today are just the beginning. You still need to learn more commands to better understand your Linux system. Although tasks can be completed in a variety of ways in the graphical interface, console commands are still the fastest way to update the system.

In addition, console commands also have unique advantages when displaying error messages. This means that when an update goes wrong, a package malfunctions, or you don't have access to the internet, the command line is often a better solution to your current dilemma.

In short, as long as you practice diligently, everyone can use terminal commands with confidence to solve various needs in work and life.

The above is the detailed content of Five Linux Terminal Command Tips for Newbies to Master. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:lxlinux.net. If there is any infringement, please contact admin@php.cn delete