The most common Linux Shell commands

The most common Linux Shell commands

introduction

As the most attractive and indispensable component of the Unix operating system, Shell has not only not been eliminated after decades of baptism, but has become more mature and stable. The reason is probably because it is a very stable adhesive. A large number of powerful components can be arbitrarily matched, and the user’s task can always be completed very quickly.

Some of the commands in this article may seem to be “carved bugs”, we have to admire Shell Daniel, but I will dig a little to explain some details, and I hope to make you laugh when I encounter interesting places.

1. Run the last command with sudo

1 $ sudo !!

Everyone should know sudo, but don’t explain it. But what usually happens is that after typing the command, it reports an error and only finds that sudo has been forgotten. At this time, novice users will: press the up arrow, press the left arrow, stare at the cursor back to the beginning, type sudo, and press Enter; if the expert users are more determined, press Ctrl-p, press Ctrl-a, and type sudo , enter.

It is introduced here that this is the level of Feixian, yes, just sudo!!.

Of course, the effects of these solutions are exactly the same, but the models are different, um, no explanation.

The two exclamation marks are actually a feature of bash called event designators. !! is actually equivalent to !-1, referring to the previous command, of course !-2, !-50. By default, bash records the last 500 commands executed by the user in the ~/.bash_history file, and the history command can display these commands.

For more on the usage of event specifiers, read The Definitive Guide to Bash Command Line History in depth.

2. Share files in the current folder via HTTP

1 $ python -m SimpleHTTPServer 8080

This command starts Python’s SimpleHTTPServer module. Considering that Python is installed by default in most Linux distributions, this command is probably the easiest way to transfer files across platforms.

After the command is executed, the HTTP service will be opened on port 8000 of the local machine. Open ttp://ip:8000 in the browser of other machines that can access the local machine to open a directory list, click to download.

python3 words

1
python3 -m http.server

The post Most Popular Linux Shell Commands first appeared on Lenix Blog .

This article is reprinted from https://blog.p2hp.com/archives/9448
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment