Linux Interview topics

Question one:

What absolute path is represented by a symbol? The current directory, parent directory is represented by what? Home directory is represented by what? Change directory what order?
Answer:
Absolute path: /etc/init.d as
the current directory and the parent directory: ./ ... /
home directory: ~ /
Change directory: cd

Question two:

How to view the current process? How an exit? How to view the current path?
Answer:
Check the current process: ps
an exit: exit
view the current path: pwd

Question three:

How clear the screen? How to exit the current command? How to perform sleep? How to view the current user id? View help specify what order?
The answer:
clear the screen: clear
exit the current command : ctrl + c completely out of the
execution of sleep : ctrl + z suspends the current process to restore the background fg
view the current user the above mentioned id : "the above mentioned id": View shows the current login account uid and gid and Group-owned and username
View help specify : If this man adduser very wide and there are examples; adduser --help this tell you some common parameters; info adduesr;

Question 4:

Ls command performs what function? Which parameter can take, what's the difference?
Answer:
the function performed ls: list directories in the specified directory, and the files
which parameters and differences:
Detail a L all documents, including the size of the number of bytes, read-write and the like executable permissions

Question 5:

The soft links (shortcuts), and hard links command.
The answer:
a soft link : ln -s slink source
hard link : ln link source

Question six:

Create a directory what order? Create a file what order? Copy the file what order?
Answer:
Create a directory: mkdir
to create the file : typical, such as touch, vi files can also be created, in fact, as long as the output to a file that does not exist, create a file will
copy the file : cp 7. file permissions to modify what order? Format is kind of how?
File permissions to modify : chmod
format is as follows:
$ chmod U + the X-file to the owner of the file increases execute permissions
$ chmod 751 file to the owner of the distribution file read, write, execute permissions (7), and where the group is assigned to read to file a , execute permissions (5), the permission to perform (1) assigned to another user
$ chmod u = rwx, g = rx, o = x file on another form of embodiment of
$ chmod = r file read permissions assigned to all users
$ chmod 444 file supra embodiments
$ chmod a-wx, a + r file supra embodiments
$ chmod -R u + R & lt directory permissions recursively assigned to the owner of all files and subdirectories under the directory read directory

Question eight:

View the contents of the file have what command?
The answer:
vi filename # editing view, you can modify the
cat filename # All contents of the file
more filename # page display file contents
less filename # and more similar, better can forward flip
tail filename only # Check the tail, you can also specify the number of rows
head filename head # view only, you can also specify the number of rows

Nine on:

Free to write file commands? How to screen output string with spaces, such as "hello world"?
Answer:
Write File command: vi
to the screen output string with spaces: echo hello world

Question 10:

Terminal which is which file folder? Black hole which command file which folder?
Answer:
Terminal / dev / tty
black hole file / dev / null

Question 11:

Move files which command? Which changed its name to command?
The answer:
mv mv

Problem 12:

[root@localhost ~]# whatis zcat
zcat [gzip] (1) – compress or expand files

Problems thirteen:

Which one command to view their own file system, disk quota it?
Answer:
Use the command repquota able to show quota information for a file system

1) Linux, which has several major kernel lock?

Linux synchronization mechanism from 2.0 to 2.6 since the continuous development and improvement. From the initial atomic operations, the semaphore later, from the big kernel lock into today's spin locks. The development of these synchronization mechanisms associated with the transition to Linux from a single-processor symmetric multi-processors;
accompanied the transition from non-preemptive kernel to kernel preemption. Linux lock mechanism more effective, but also more complex.
Linux kernel lock mainly spin locks and semaphores.
Spin lock can only be held by a thread of execution, if one thread of execution has been trying to request a contention (already held) spin lock, then the thread will always be busy loop - rotation - waiting for the lock to become available. If the lock is not contention, requesting its execution thread can get it immediately and proceed. Spin locks can prevent more than one thread of execution while entering the critical section at any time.
Semaphore in Linux is a sleep lock. If there is a task trying to get a semaphore has been held, the semaphore will push it into the waiting queue, and then allowed to sleep. In this case the processor to execute other code freedom. When the process holds the semaphore of the semaphore is released, a task in the queue waiting to be awakened, so that they can obtain the semaphore.
Semaphore's sleep, which makes the signal amount applicable to the case of the lock will be held for a long time; only in process context, because the context is not scheduled interruption; In addition, when the code signal holdings, not and then holding a spin lock.
Linux kernel synchronization mechanisms: atomic operations, the semaphore, the semaphore and the reading and writing of the API spin locks, some other synchronization mechanisms, including large kernel lock, read-write locks, the lock of Reader, RCU (Read-Copy Update, as the name implies is read - modified copy), and the order of the lock.

2) Linux user mode and kernel mode is what meaning?

MS-DOS and other operating systems running in single CPU mode, but some Unix-like operating systems use a dual-mode, time-sharing can be effectively achieved. On Linux machines, CPU either in kernel mode trusted, either in a restricted user mode. In addition to the kernel itself in kernel mode, all user processes run in user mode.
Kernel mode code can have unlimited access to all processor instruction set and all memory and I / O space. If the user-mode process to enjoy this privilege, it must call makes a request to a device driver or other kernel-mode code that through the system. Further, the user mode code allows page fault occurs, the kernel-mode code is allowed.
2.4 and earlier kernels, only user-mode process can be a context switch out, preemption by other processes. Unless two things happens, otherwise the kernel mode code may have been exclusively the CPU:
(1) it voluntarily give up the CPU;
(2) the occurrence of an interrupt or exception.
2.6 kernel introduced kernel preemption, most kernel-mode code may be preempted.

3) How to apply chunks of kernel memory?

In the Linux kernel environment, large memory application success rate with increasing system uptime and reduce, although you can apply by calling vmalloc Series physically discrete but contiguous virtual address memory, but that its efficiency is not high and in 32 vmalloc bit limited on the system memory address space. Therefore, the general recommendation is to apply for large chunks of memory in the system start-up phase, but the probability of success is only relatively high only, instead of 100%. If the program really care about the success of this application, only back with the "start memory" (Boot Memory). Here is some sample code and export application startup memory:

void* x_bootmem = NULL;
 EXPORT_SYMBOL(x_bootmem); 
 unsigned long x_bootmem_size = 0; 
 EXPORT_SYMBOL(x_bootmem_size); 
 static int __init x_bootmem_setup(char *str) 
{ 
x_bootmem_size = memparse(str, &str); 
x_bootmem = alloc_bootmem(x_bootmem_size); 
printk(“Reserved %lu bytes from %p for x\n”, x_bootmem_size, x_bootmem); 
return 1;
 }
  __setup(“x-bootmem=”, x_bootmem_setup); 

Visible its application is relatively simple, but always pros and cons of symbiosis, it inevitably has its own limitations: memory allocation code can only be connected into the kernel, can not be used in the module.
Application memory is not being used and statistics page allocator and slab allocator, which means that it is outside the visible memory system, even if at some future where you release it.
General users will only apply for a chunk of memory, if you need to implement complex memory management on which you need to implement.
In the case of failure of memory allocation is not allowed, by starting memory reserved memory space will be our only choice.

4) inter-process communication major user what kinds of ways?

(1) pipe (Pipe): having a communication conduit may be used for genetic relationship between the process, a process and allows it to communicate with other processes between the common ancestor.
(2) the named pipe (named pipe): Named Pipes overcomes the limitations of the pipeline without a name, therefore, in addition to a pipe with the functions, it also allows communication between unrelated processes. Named pipes have corresponding file name in the file system. Named Pipes mkfifo command or system call mkfifo to create.
(3) signal (Signal): the signal is more complex communication mode for receiving the notification process has some event occurs, except for inter-process communication, the process can also send a signal to the process itself; Unix early signal in addition to supporting Linux outside the semantic function sigal, also supports the function of the signal sigaction semantic Posix.1 in line with the standard (in fact, the function is based on the BSD, BSD order to achieve reliable signal mechanism, but also to unify external interface, use sigaction function to re-implement the signal function) .
(4) message (Message) queues: a message queue is a linked list of messages, including a message queue Posix system V message queue. Has sufficient rights process can add a message to the queue, was given permission to read a process you can go read messages in the queue. Signal bearing the message queue overcome small amount of information, only the carrier pipe and the plain byte stream buffer size is limited by the lack of other
(5) of shared memory: such that multiple processes can access the same memory space available is the fastest IPC form. For other communication mechanism is not efficient design. Often, such as semaphores in conjunction with other communication mechanism, to achieve synchronization and mutual exclusion between processes.
(6) semaphore (semaphore): mainly as a means of inter-process synchronization as well as between the different threads in the same process. (7) the socket (Socket): more general inter-process communication mechanism can be used for inter-process communication between the different machines. It was originally developed by BSD Unix systems branch out, but they are generally portable to other Unix-like systems: Linux and System V variants support sockets.

5) function through the buddy system application kernel memory of what?

On the physical page management implementation based on the area of ​​the buddy system (zone based buddy system). Memory for different areas using a separate system partner (buddy system) management, and independent monitors free pages. Corresponding interface alloc_pages (gfp_mask, order), _ _get_free_pages (gfp_mask, order) and the like.

6) critical data structure of Linux virtual file system What? (Write at least four)

struct super_block,struct inode,struct file,struct dentry;

7) of the file or device manipulation functions stored in the data structure?

struct file_operations

8) Linux files, including what?

Execute files, regular files, directories, files, links, files and device files and pipes file.

9) the process of creating a system call those?

clone (), fork (), vfork (); system call service routine: sys_clone, sys_fork, sys_vfork;
10) calling schedule () carried out the process of switching in several ways?
1. The system calls do_fork ();
2. Timing interrupt do_timer ();
3. wake process wake_up_process
4. changing the process scheduling policy setscheduler ();
5. system call comity sys_sched_yield ();

11) Linux scheduler is based on the dynamic priority scheduling priority of a process or static process?

Liunx Scheduler are two values associated with the static priority based algorithm calculated, according to both the scheduling process according to the dynamic priority of a process, but a dynamic priority and yes. Because of the high-priority process is always better than low-priority processes are scheduled first, CPU resources to prevent multiple high-priority process, resulting in other processes can not occupy CPU, so the reference to the concept of dynamic priority
core 12) process scheduling which data structure?
struct runqueue
13) how to load, unload a module?
insmod loads, rmmod unloading
14) modules and applications are run in what space?
module runs in kernel space, the application is running in user space

15) Linux in floating-point operations achieved by the application or kernel implementation?

Application implementation, Linux is the use of floating point math library functions to achieve, library functions can be called after linking an application, call the kernel can not be linked. These operations are running in the application, and then sends the results back to the system. If the Linux kernel must be floating-point operations, require elected in the establishment of core math-emu, using simulation software floating-point operations, is said to cost of doing so is twofold: users need to rebuild the kernel when installing the driver might affect to other applications, so that these applications also use math-emu doing floating-point operations when the greatly reduced efficiency.
16) Can I use the program module library functions can be linked?
Module runs in kernel space, you can not link library functions.
17) TLB cache is what?
TLB, the page table cache, when the linear address is first converted into physical addresses, and corresponding linear address into a physical address of the TLB for the next visit to this linear an address, speed up the conversion.
18) Linux, which has several facilities in the?
Character and block devices. NIC is the exception, he does not correspond directly with the device file, mknod system call is used to create the device files.
19) The key data structure of a character device driver which?
Character device descriptor struct cdev, cdev_alloc () for dynamic allocation descriptor cdev, cdev_add () to register a cdev descriptor, cdev type comprising a struct kobject it is a core data structure of a data structure
which features function 20) device drivers include?
Open (), the Read (), the Write (), llseek (), iTS DISPOSAL, UNLESS ();
21) how to uniquely identify a device?
Linux uses a device number for uniquely identifies a device, the device ID is divided into: the major and minor numbers, drivers generally designated major number corresponds to the device, the corresponding device file minor number pointing device, used in the kernel dev_t device number is represented, which is typically 32 bits long, 12 for indicating the major number 20 is used to indicate the minor number, using mKDEV (int major, int minor) ; dev_t for generating a type of the object .
22) Linux system call by what means?
By software interrupt realize, first of all, the user program calls to set parameters for the system, in which a numbering system call number, the parameters are set, the program executes a system call instruction, soft on the x86 interrupt int is generated, this directive will result in an exception, generates an event, the event will result in kernel mode and processor jumps to jump to a new address. And starts processing where the exception handler, this time exception handling system is the caller.

What 23) Linux and soft interrupt work queue is the role?

Linux in the work queue is soft interrupt and interrupt handling.
1. soft interrupt is generally "function can be delayed," the general term, it can not sleep, can not block, it is in interrupt context, can not be switched into the city, the soft interrupt can not be interrupted himself, only to be interrupted by a hardware interrupt (upper half ), you can run concurrently on a plurality of CPU. It must be designed as a function of soft interrupt reentrant, spin lock is also required to protect their data structures.
2. The work queue function in process context, it can sleep, can also be blocked, can switch between different processes. Completed different jobs. Functions can be delayed work queue and can not access the user's process space, the function can not be delayed in performing any running process, the kernel function work queue process execution, he can not access user address space.

Published 74 original articles · won praise 233 · views 20000 +

Guess you like

Origin blog.csdn.net/qq_43107323/article/details/104840963