Summary and sharing of 23 common linux interview questions, and 23 in linux

Source: Internet
Author: User

Summary and sharing of 23 common linux interview questions, and 23 in linux

1. ps usage ps-ef the content of each column is as follows (8 columns) UID // user ID, but the output is the user name PID // idppid of the process // The percentage of CPU occupied by the parent process IDC // STIME // The process startup time TTY // this process runs on that terminal, if it is not related to the terminal, if it is pts/0, it indicates that the network is connected to the host process. CMD // command name and Parameters

Ps-aux has columns (11 columns) different from ps-ef) % CPU // percentage of CPU occupied by the process % MEM // percentage of memory occupied VSZ // virtual memory used by the process (KB) RSS // fixed content occupied by the process (KB) (number of resident pages) STAT // Process status START // start time when the process is triggered // The actual CPU running TIME of the process

2. The killkill command is used to abort a process. The safest way to kill a process: kill pid force stop: kill-9 pid and slow restart process: kill-hup pid stop by process name: killall httpd killing it and its sub-process: kill-TERM PPID

3. crontab configuration, how to implement the first column minute per second: 1--59 second column hour: 1--23 (0 indicates midnight) Third column day: 1--31 fourth column month: 1--12 Fifth Column week: week 0--6 (0 represents Sunday, 1 represents Monday, and so on) Column 6 command http://blog.csdn.net/fdipzone/article/details/22701113 to run

4. difference between a process and a thread a process is a "program in execution". It is a dynamic concept and can apply for and own system resources. A process, as the basic unit of resource allocation, is a part of a process. A process can contain several threads that can use the resources of the process. A thread is the basic unit for independent running and independent scheduling. Because a thread is smaller than a process and basically does not have system resources, the overhead for scheduling is much smaller, it can improve the degree of concurrent execution among multiple programs in the system more efficiently.

5. Three-state model of a process (1) running: when a process runs on a processor, it is called running. (2) Ready: when a process obtains all the resources other than the processor and can run as soon as the processor is obtained, the process is in ready state. (3) Blocking: it is also called a waiting or sleep state. A process temporarily stops running while waiting for an event (for example, requesting I/O and waiting for I/O to complete, at this time, even if the processor is assigned to a process, it cannot be run. Therefore, the process is blocked. Five-state model: For an actual system, the process state and its transformation are more complex. The introduction of the new and terminated States forms the five-state model of the process.

6. chmod chown chgrp (1) chmod variable file attributes r = 4, w = 2, x = 1 format: chmod 777 file three numbers represent the permissions of the User, Group, and Other (2) chown transformation of the file owner-R option means that all files in all subdirectories are in the same operation format: chown User name: User Group: File/directory example: chown-R root: root/home (3) the user group-R option of the chgrp conversion file means that all files in all subdirectories are also operated in the same format: chgrp user group file name example: chgrp-R user smb. conf

7. vim (1) Replace: Use the: s command to replace the string: s/vivian/sky/Replace the first vivian in the current line with sky: s/vivian/sky/g replace all vivian in the current row with sky: n, $ s/vivian/sky/g replace all vivian from row n to row n as sky (2) Search: Use/word next N previous n (3) cut a row: dd (4) copy a row: yy (5) paste: p (6) locate: gg locate the first line, G locate the last line (7) delete all rows: 1, $ d (8) undo: u (9) undo: ctrl + r

8. when rm is used to delete files or directories in a Linux system, you must use the command-f like rm-rf * to force the deletion of files that do not exist. The system never prompts-I interactive mode to delete files, prompt-r recursively deletes files in directories and subdirectories before deleting files

9. sortsort compares each row of the file as a unit. The comparison principle is to compare the lines from the first character to the back, compare them by ASCII code value, and finally output them in ascending order. -R is sorted in reverse order. -F indicates that uppercase and lowercase letters are ignored during sorting. -B ignores the leading space characters in each line.

10. The uniquniq command deletes duplicate lines in the file. Note: uniq only removes adjacent duplicate rows. You can use the sort command to make all duplicate rows adjacent, then we can remove all repeated rows-c and add the number of times each row appears in the input file before the output row. -D: only duplicate rows are displayed. -U only displays non-duplicate rows.

11. query logs of a certain period of time ($1> = "2017-03-1::50:11" & $1 <= "2017-03-1::50:13 ") {print $1 }'

12. stack and stack differences 1. Stack space allocation differences 1. Stack (operating system): automatically assigned and released by the operating system, stored function parameter values, and local variable values. The operation method is similar to the stack in the data structure. 2. The stack (operating system) is usually assigned and released by the programmer. If the programmer does not release the stack, it may be recycled by the OS at the end of the program, the allocation method is similar to the linked list. Ii. Stack cache methods: 1. the stack uses a level-1 cache, which is usually in a bucket when called and is released immediately after the call is completed; 2. The heap is stored in the second-level cache. The life cycle is determined by the garbage collection algorithm of the Virtual Machine (not to be recycled once an orphan object ). Therefore, the call speed of these objects is relatively low. 3. Stack data structure difference: Stack (Data Structure): A stack can be considered as a tree, for example, stack sorting; stack (Data Structure): an advanced and later data structure.

13. The Linux Process structure consists of three parts: code segment, data segment, and stack segment. That is, the Process Control Block (PCB) consists of the program, data, and Process Control Block. A process control block is the unique identifier of a process. The system perceives the existence of a process through the presence of a PCB. The code segment stores executable code of the program. The data segment stores global variables, constants, and static variables of the program. The heap in the stack segment is used to store dynamically allocated memory variables, and the stack in the stack segment is used for function calls. It stores function parameters and local variables defined in the function.

14. IO models there are four common IO models: (1) Synchronous blocking IO (BlockingIO): the traditional IO model. (2) Non-blocking IO (Non-blockingIO): by default, the created socket is blocked. Non-blocking IO requires the socket to be set to NONBLOCK. Note that NIO is not a Java NIO (NewIO) Library. (3) IOMultiplexing: the classic Reactor design mode, also known as Asynchronous blocking IO. This model applies to Selector in Java and epoll in Linux. (4) AsynchronousIO: the classic Proactor design mode, also known as Asynchronous non-blocking IO. The concept of synchronization and Asynchronization describes the interaction between the user thread and the kernel: synchronization means that the user thread can continue to execute after initiating an IO request or polling the kernel IO operation; asynchronous means that the user thread continues to execute after initiating an IO request. After the kernel IO operation is completed, the user thread is notified or the callback function registered by the user thread is called. The concept of blocking and non-blocking describes how the user thread calls the kernel I/O operation: Blocking means that IO operations need to be completely completed before they are returned to the user space; non-blocking means that an I/O operation is returned to the user immediately after it is called. You do not need to wait until the I/O operation is complete.

15. find searches for files in the directory structure and performs the specified operation. Find pathname-options [-exec]-name searches for files by file name. -Mtime-n + n: searches for files based on the file change time.-n indicates that the file change time is less than n days away, + n indicates that the file change time is n days ago.-exec: find command executes the shell command given by this parameter on the matching file. The corresponding command is in the form of 'command' {}\;. Note the space between {} And. Example: php {}\;

16. File Attribute l is link d is directory c is character device file B is block device-is File

17. Two programs on the socket network exchange data through a two-way communication connection. one end of the connection is called a socket. It is also called "socket". It is used to describe the IP address and port. It is a communication chain handle and can be used to implement communication between different virtual machines or different computers.

18.tar compression operation: # tar-cvf/usr/local/auto_bak/test.tar/usr/local/test package only, do not compress # tar-zcvf/usr/local/auto_bak/test.tar.gz/usr/local/test package and decompress it with gzip: # tar-zxvf/usr/local/test.tar.gz

19. soft connection: ln-s source file target file 20. shell operation cursor ctrl + a move cursor to the beginning of the line crtl + e move cursor to the end of the line ctrl + u Delete content on the left of the cursor

20. Global Search for whether all files in a directory contain a certain string: (1) enter the directory to be queried (2) grep-rn "hello world "*

21. Shortcut Key copy: ctrl + insert paste: shift + insert

22. dstat displays the CPU status: CPU usage of all system resources in real time. The more interesting part of this report is that it displays statistics of users, systems, and idle disks: disk read/write operations, this column displays the total number of reads and writes to the disk. Network statistics: the data sent and received by network devices. The total number of network receiving and sending data is displayed in this column. Paging statistics: System paging activity system statistics: This item displays the interrupt (int) and context switching (csw)

23. history command history record command ctrl + r reverse query history command

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.