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

What is the use of the Linux command tool

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces you what is the use of Linux command tool, the content is very detailed, interested friends can refer to, hope to be helpful to you.

There are too many commands on Linux, if you memorize them, you don't know when to memorize them, but Linux has the history of Bash commands and tools like apropos and fish, so you don't have to spend too much memory recalling commands that help you complete your tasks. Let's share with you how to use the Linux command tool.

Bash Command History

Whether you know it or not, Bash (the most popular Linux shell) keeps a history of the commands you have executed. Want to take a look at it in practice? There are two ways. Open the terminal window and press the up arrow. You should be able to see orders appear, one by one. Once you have found the command you want to use, you can press Enter directly if you don't need to modify it, or press Enter after modification.

This is a good way to re-execute (or modify and re-execute) previously run commands. I often use this function. It not only frees me from having to remember all the details of a command, but also allows me to type the same command over and over again.

Speaking of the command history of Bash, if you execute the command history, you can make a list of commands you have executed in the past (figure 1).

Figure 1: can you find the mistake in the command I typed?

The number of historical commands saved by your Bash command history can be set in the ~ / .bashrc file. You can find the following two lines in this file:

HISTSIZE=1000HISTFILESIZE=2000

HISTSIZE is the maximum number of commands recorded in the command history list, while HISTFILESIZE is the maximum number of lines in the command history file.

Obviously, by default, Bash records your 1000 historical commands. That's a lot. Sometimes, this is considered to be a security breach. If you care, you can reduce this value as much as you like to strike a balance between safety and practicality. If you don't want Bash to record your command history, you can set HISTSIZE to 0.

If you modify the ~ / .bashrc file, remember to log out and log back in (otherwise the changes will not take effect).

Apropos

This is the first tool I want to introduce to help you remember Linux commands. Apropos ("about") can search the Linux help documentation to help you find the commands you want. For example, you don't remember what firewall tools you used in your distribution. You can type apropos "firewall" and the tool will return the relevant commands (figure 2).

Figure 2: what firewall do you use?

And what if you need a command to manipulate the directory, but you have no idea which one to use? Type apropos "directory" to list all commands that contain the character "directory" in the help document (figure 3).

Linux three command tools! Linux three command tools!

Figure 3: what are the tools that can manipulate directories?

The apropos tool is installed by default in almost all Linux distributions.

Fish

There is another good tool that can help you remember commands. Fish is a command line shell of Linux/Unix/Mac OS with some useful features.

Automatically recommend VGA color-perfect scripts that support web-based configuration to help documents automatically complete syntax highlighting and more

Automatic recommendation makes fish very convenient (especially if you can't remember some commands).

You may think it's fine, but fish is not installed by default. For Ubuntu (and its derivative version), you can install it with the following command:

Sudo apt-add-repository ppa:fish-shell/release-2sudo apt updatesudo apt install fish

For CentOS-like systems, you can install fish like this. Add the warehouse with the following command:

Sudo-scd / etc/yum.repos.d/wget http://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo

Update the warehouse with the following command:

Yum repolistyum update

Then install fish with the following command:

Yum install fish

Fish may not be as intuitive to use as you might think. Remember, fish is a shell, so you have to log in before you can use the command. On your terminal, run the command fish and you will see that you have opened a new shell (figure 4).

Linux three command tools! Linux three command tools!

Figure 4: interactive shell for fish.

When you start entering a command, fish automatically completes the command. If the recommended command is not what you want, press the Tab key on the keyboard to browse for more options. If that's exactly what you want, press the right arrow on the keyboard to complete the command, and then press Enter to execute. After using fish, type exit to exit shell.

Fish can do a lot more, but here's just an introduction to help you remember commands, and automatic recommendation is enough.

What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.

On the use of the Linux command tool is shared here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can 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

Development

Wechat

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

12
Report