Linux has been going through so many years, with so many commands and so many different parameters, that even the most experienced professionals, let alone beginners, don’t know how to use these commands perfectly.

Faced with these complex and difficult to remember commands, some online tools such as Keep, Bashpast CLI, Pet and so on can help us record these complex commands. But these are a little difficult to learn, and also need to download specific tools, more trouble.

Here are two tips that can easily label some complex commands. You can quickly find the corresponding commands according to the labels. Simple and efficient!

Flag Linux commands

We can label complex commands that remind you of the function of the relevant Linux commands. After the markup is applied to Linux commands, we can enter the markup character instead of long and complicated commands.

For example, find and list files larger than 10MB in the current directory and sort them by size:

$ find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z
Copy the code

I don’t know if you remember what this command is? If you don’t remember, break it down by yourself.

Because it’s too long to see at a glance, we can add a memorable tag at the end of it, preferably to reflect the effect of the command, such as ListFilesBiggerThanXSize here:

$ find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z #ListFilesBiggerThanXSize
Copy the code

Note: starts with # and leaves a space between the command and the label name.

To test the effect, enter the previous tag:

$ !? #ListFilesBiggerThanXSize
Copy the code

Here it is! And? The operator is used to get and run the commands we previously marked from the BASH history.

[alvin@VM_0_16_centos ~]$ find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z #ListFilesBiggerThanXSizeTotal 104K 16K httpd.c 16K Shakespeare 12K hello 4.0k dir2 [alvin@VM_0_16_centos ~]$! ?#ListFilesBiggerThanXSize
find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z #ListFilesBiggerThanXSizeTotal 104K 16K httpd.c 16K Shakespeare 12K Hello 4.0K dir2Copy the code

Another way to do it

Another way to remember names is to use the alias command, which you should be familiar with. The principle is similar to that of marking.

For example, give our command a nickname:

$ alias ListFilesBiggerThanXSize='find . -size +10M -type f -print0 | xargs -0 ls -Ssh | sort -z'
Copy the code

To use:

$ ListFilesBiggerThanXSize
Copy the code

It’s that simple!

—————–

Good xu, the world’s top 500 foreign companies Linux development engineer, Linux evangelist, welcome to pay attention to my public number “good Xu Linux”, full of dry goods!

→ “Technical dry goods push”

→ “Exclusive data Sharing”

→ “Community of masters like clouds”

If you are interested in my topics, you can also follow my blog: lxlinux.net