This paper is participating in the30 years of Linux”Topic essay activity

Hi, I'm a sleeping cat, and today I'm going to share with you the Linux questions I've met with over 90 companies.Copy the code

Linux is one of the skills that will make you stand out from the crowd.

In the IT industry, there is an unwritten rule called interview build rocket, job turn screw. Like it first, watch it later.

In that just unemployed one summer, summer scorching, come to the big factory that everybody thinks —- some degree. My interview is a big brother, smiling said: classmate, let’s walk and chat.

The following is the formal Topic of Linux, we can be certified to learn.

A: I see from your resume that you are familiar with Linux. What commands do you use in your work? At least five, but the more the better.

Well, handsome interviewer, generally we use the command: ll, ls, ps, top, grep, tail, cat, CD, PWD, rm, chmod, mkdir, cp, mv, cat, find, tar. (these commands we all have to understand, know, understand, do not usually back the command has not used the command to say, to their own pit, that is really over the calf)

Well, see you know a lot, you just explain you just said those commands in the context of use, as carefully as possible ha.

Well..

First, the CD command is used to switch directories. For example, if we were on a Linux server to view the log, but switched to the log directory altogether, we could use the CD command. Such as CD/opt/log. If we forget the name of the file in the log folder, we can press TAB twice in a row, and the file in the log folder will appear. (See the picture below for those who don’t understand)

There are many system logs, usually in the form of date folders. When we cut to the log folder, use ll or ls. (Next, ll and ls commands)

Cut to the corresponding date directory, we can use LL to view the file properties, dates, permissions. Ll can be used with arguments such as -a to view hidden files. -h Displays the file size. (See the picture below for those who don’t understand)

At this point, find the corresponding file and you can monitor the log in real time. The tail -f. Log file is used for monitoring logs.

Well, of course, if you want to know something about the error log before, we can use cat file. The log | grep “keywords”. I found it more intuitive to add –color when I used the cat command to look at keywords.

At this point, the interviewer may interrupt you. Why? To be honest, I don’t know. Maybe I don’t like what I said. At this point, he will ask you about the scenarios he uses in his work.

Do you use Linux commands to delete files at work? How did you delete it?

** Keep in mind that the rm command is not allowed to be used on Linux servers, or you do not even have permission to use it. ** We generally do not use rm -rf to delete files. Deleting files is quite risky. We generally move unused files MV to a unified directory, and Linux server uses scheduled tasks to delete files.

The server suddenly reported that the CPU was high, how did you use the command to check? How do I check the CPU usage of a process?

We have also encountered in our work, for example, a service that has a sudden high CPU usage, we will use the top command to check. The top command dynamically displays the running status of all processes in Linux. Parameters in the top command:

D Specifies the interval between screen information refreshes. Of course, the user can use the S interactive command to change this.

P Monitors only the status of a process by specifying the process ID.

Q This option will refresh top without any delay. If the caller has superuser privileges, top will run with the highest priority possible.

S Specifies the accumulative mode

S Enables the top command to run in safe mode. This removes the potential dangers of interactive commands.

I makes top not show any idle or dead processes.

C displays the entire command line instead of just the command name

Find the process that consumes a lot of CPU and kill it. The PId can be seen from the top command. Kill -9 PId can be seen from the top command.

Of course, we also can find the corresponding pid use ps aux | grep pid can be careful have a look at his below the corresponding problems.

Ok, ask you another command, we want to change a file permissions, use chmod, this command you explain why.

The chmod command controls user permissions on files. File invocation permissions are divided into three levels: Owner, Group, and Other Users.

It’s 0,1,2,3,4,5,6,7. Let me explain. (I don’t talk nonsense, we look at the table below)

# permissions rwx binary
7 Read + write + execute rwx 111
6 Read + write rw- 110
5 Read + execution r-x 101
4 read-only r– 100
3 Write + execution -wx 011
2 Just write -w- 010
1 Only perform –x 001
0 There is no 000

In a real job interview, you’ll usually have a shell in addition to Linux. In fact, shell is not as difficult as imagined, it is the execution of Linux commands, but it is also a language.

Linux is a kernel, and a shell is something that wraps around the kernel and allows users to use Linux through a shell.