The 20 most commonly used and basic commands in Linux

Table of contents

Commands used dozens of times a day

Commands used about ten times a day

Other commonly used commands

I was interviewing recently. The plan was to interview several junior operation and maintenance engineers. I interviewed many of them, but I haven’t met a suitable one yet. Maybe it’s because I didn’t have the experience of interviewing others before, so I didn’t master the standard of asking.

Seeing that the resumes are very tall, it is difficult to ask. I saw k8 and containers, but when I asked, either I did it myself, or I didn’t answer clearly. .

As a result, I finally asked, what command should I use to view the last 10 lines of the log, but I hesitated for a long time, only to find that the clown is myself. What I want to say here is that although many of them are cloud resources now, many times Some basic content has been completed for me, but some of the most basic things still need to be clear.

The words in this article are based entirely on my own experience and conclusions. They may be used less now, but in the past, they were basically used every day.

Commands used dozens of times a day

1.cd

Dozens of times a day is actually a small number, especially for companies whose daily operations and maintenance are not so automated.

The function is to switch directories

cd .. switch to the previous directory

cd ~ switch to the root directory

cd - Switch to the directory you were in last time. This command can sometimes be helpful.

2.cp

Copy, -r, -a. These two attributes are used more often.

-r is recursive copy, which can be used to copy directories

If -a is used, the corresponding attributes will be copied, such as some executable files.

3.ls

View the files in the corresponding directory

The most commonly used options are -l and -a

-l can display some creation time, file size, etc. of specific files

-a can display hidden files, such as .ssh, etc.

4.rm

Many developers will joke with us, what about rm -rf

But for operation and maintenance, this command is really used many times a day, and it has not been deleted by mistake in so many years.

Of course, newcomers should be more cautious when using it, and use -f sparingly.

If -r is used, it will be deleted recursively.

5.mv

You can change the location of the file or change the file name.

6.cat

View file contents

Use caution when reading large log files

Commands used about ten times a day

7.ps

View progress

The most commonly used one is -ef

Or -aux

8.top

To put it simply, check the load

You can see the overall load of the server and the load of a single process.

Press a to see the load of all cpu cores

Press m to view the processes taking up the most memory.

9.free

View memory

Can -h, -m

10.tail

The last 10 lines of the file

-n can specify the number of lines

-f can refresh in real time

11.head

View the first 10 lines of the file

You can add -n to view the fixed number of lines

12.ip ad

In fact, the complete version is ip add show

IP ad can be displayed directly

The most used one is to check IP

You can also use ipconfig under Linux

You can use ifconfig under cmd

13. netstat

There is also a similar command nc. Sometimes you can also use lsof.

Used to view ports

netstat -an |grep port

You can view the port based on the process number

netstat -antlp|grep pid

Other commonly used commands

14.touch

Create a file

15.history

View command history

In fact, in operation and maintenance work, it is very useful to view historical commands.

Especially some historical systems that have not been touched for a long time.

You have to look at the history commands to find some records.

16.find

This command is actually very powerful

The most commonly used one is to find files

You can search by name, you can search by time, you can also search by file type.

find / -name test*

find / -mtime 10

find / -type f

17.awk

Commonly used is -F

Split based on specified fields

For example: echo "1-2-3"|awk -F'-''{print $2}'

18.sed

The most commonly used one is the replacement field.

sed -i can directly take effect on the file. Without -i, you can output and view the replacement effect.

sed -i 's/original field/replacement field/g' file name

19.telnet

Detect whether the peer port is open

Can determine whether the peer service is normal

Of course, there might be a wall

20.pwd

Current location path

For example, copying files, etc., sometimes used

Guess you like

Origin blog.csdn.net/smallbird108/article/details/125493584