Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to teach yourself the Linux command

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to learn Linux commands by yourself. the editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Daily hint

One gradual way to learn the Linux command is to have it display a "daily prompt" each time you open the terminal. This will introduce you to some useful commands and their advanced techniques. Add the following line to .bashrc (/ home/.bashrc):

Echo "Did you know that:"; whatis $(ls / bin | shuf-n 1)

All you have to do is add this line! If you want to make it more entertaining, you can install cowsay. Install cowsay under Ubuntu/Debian:

Sudo apt-get install cowsay

Install cowsay under Fedora:

Yum install cowsay

In addition to installing cowsay, you need to add to .bashrc:

Cowsay-f $(ls / usr/share/cowsay/cows | shuf-n 1 | cut-d. -F1) $(whatis $(ls / bin) 2 > / dev/null | shuf-n 1)

However, the above method of using cowsay does not work successfully under all Linux distributions.

Use "whatis"

If you don't like learning random commands, maybe you like to learn its usage when using a certain command. At this point, you just need to add whatis in front of it. Whatis will explain the commands you enter one by one.

The whatis sudo yum install cheese example in the figure above clearly tells you: 1) sudo is to give you administrator privileges; 2) yun is the package manager; 3) install is to let YUM install the package; 4) cheese is the software you intend to install. This method does not work well in front of complex or unusual commands. But if you want to know the general purpose of a command, it's worth a try.

Browse all available options for the command

If you are using a new command, there are two ways to see its detailed usage. One way is "man", where is the name of the program you want to run. For example, "man cp" will tell you the detailed usage of cp in the man file browser.

Another way to quickly look at the main usage of a command-"- help". For example, "cp-help" prints out a large number of uses of the cp command directly in the terminal. In other words, the-help option has the same meaning in all Linux commands.

Crash course-yes, now!

*, you can learn the syntax of the Linux command here! Understanding the basic syntax of Linux commands is good for understanding commands and is worth learning.

All Linux commands have the same structure: [sudo] program [parameter] [parameter]... [parameter] [- flag] [parameter] [- flag] [parameter]... [flag] [parameter]

Let me analyze the above structure in sections:

If a command requires administrator privileges (root access) to run, you must precede it with "sudo". This allows the administrator's password to be entered at the point where the command is run.

"program" is the name of the application. It includes yum, apt-get, cheese, tar, cp, mv, firefox and so on. Without additional configuration, all commands that can be accessed through this method are placed in the / usr/bin directory. For many programs, you only need to enter their name in the terminal. For example, type "firefox" in the terminal, then press enter, and Firefox will run.

After the name of the program, you can use different parameters and flags. Different programs vary greatly in this respect. For example, the command "cp file1 file2" makes a copy of file1 in the directory where it is located and saves it as file2. Here "file1" and "file2" are two arguments to the command "cp". Some commands also change their behavior by using different flags. For example, "install" in the command "sudo yum install cheese-y" is the parameter of yum, "cheese" is the parameter of install, and "- y" is the flag of yum-when yum asks you if you want to continue, it always answers "yes" by default. It is important to note that some flags have their own parameters, while others do not. No specific examples will be given here. Each Linux name has its own set of logo settings, which take a long time to master.

This is the end of this article on "how to self-study Linux commands". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report