Linux interview questions required for O & M
1. What is GPL, GNU, and free software?
GPL: (General Public License): An authorization. Anyone has the right to obtain, modify, and re-release free software.
GNU: (Plan): it aims to create a completely free and open operating system.
Free Software: software that can be freely used, copied, researched, modified, and distributed without restriction. There are two main licenses: GPL and BSD.
2. How to select the Linux operating system version?
Generally, Ubuntu is preferred for desktop users, RHEL or CentOS is preferred for servers, and CentOS is preferred for both desktop users.
According to specific requirements:
① If security requirements are high, Debian or FreeBSD is selected.
② Users who need to use advanced database services and email network applications can select SUSE.
③ If you want new technologies and features, you can choose Feddora. Feddora is a beta and pre-release version of RHEL and CentOS.
④ According to the current situation, most Internet companies choose CentOS. Currently, 6 series are commonly used, and about half of the market is now available. The other reason is that CentOS focuses more on the server field and has no copyright restrictions.
3. How do I select the startup items for beginners in Linux?
We recommend that you select five boot items:
①. Crond: this service is used to periodically execute scheduled tasks configured by the system and users. You need to enable the task plan for periodic execution. This service is a required software for production scenarios.
②. Iptables: the iptables packet filtering firewall is enabled when an Internet IP address is available.
③. Network: when starting the system, if you want to activate/disable each network interface at startup, You Should (must) Consider enabling it.
④. Sshd: this service program is required for remote connection to the Linux server. Therefore, it must be enabled. Otherwise, remote connection to the Linux server will fail.
⑤. Rsyslog: a mechanism provided by the operating system. The system daemon usually uses rsyslog to collect and write various information to the System Log File. CentOS6 was previously named syslog.
6. sysstat: a software package that includes a set of tools to monitor system performance and efficiency. These tools are very helpful for Linux system performance data, such as CPU usage, hard disk and network throughput data, the analysis of these data is helpful for determining whether the system is running normally. Therefore, it is an assistant for improving the system running efficiency and running services safely.
4. Describe the 12 steps for Linux system optimization.
(1) logon to the system: Do not use root logon. Use sudo authorization management to log on to the system as a common user.
(2) disable SSH remote: Change the default remote connection to the SSH service and disable root remote connection.
(3) Time Synchronization: automatically updates the server time at regular intervals.
(4) configure the yum update source and download and install the rpm package from domestic updates.
Disable selinux and iptables (enable iptables if there is a wan ip in the iptables work scenario, except for high concurrency)
Worker adjusts the number of file descriptors, and the process and file opening consume file descriptors.
⑺ Automatically clears/var/spool/clientmquene/directory junk files at regular intervals to prevent nodes from occupying the full size (c6.4 does not have sendmail by default, so it is not suitable .)
⑻ Brief startup Service (crond, sshd, network, rsyslog)
Optimize Linux Kernel Parameters in/etc/sysctl. conf and run sysct-p.
You can change the character set to Chinese. However, we recommend that you use English to prevent garbled characters.
When the hacker locks key system files (chattr + I/etc/passwd/etc/shadow/etc/group/etc/gshadow/etc/inittab to process the preceding content, the chatter is renamed, .)
Reset clears/etc/issue to remove the screen display before logging on to the system and kernel version.
5. Describe the meaning of Linux running level 0-6
0: shutdown mode
1: single-user mode <= cracking the root password
2: multi-user mode without network support
3: Multi-User Mode Supported by the Network (text mode, the most common mode in Work)
4: reserved, not used
5: X-windows with network support supports multi-user mode (desktop)
6. reboot the system.
6. Describe the startup process from Linux system boot to login interface
(1) boot BIOS self-check, attach the hard disk.
(2) read MBR and MBR boot.
(3) grub boot menu (BootLoader ).
(4) load the kernel.
Worker starts the init process and sets the running level based on the inittab file.
Initiate the init process and execute the rc. sysinit file.
Worker starts the kernel module and executes script programs of different levels.
⑻ Execute/etc/rc. d/rc. local
⑼ Start mingetty to enter the system login interface.
7. Differences between soft links and hard links in Linux
In Linux, there are two types of links: one is Hardlink and the other is SymbolicLink ).
① By default, ln creates hard links without parameters, and ln commands with-s parameters create soft links.
② The inode node number of the hard link file is the same as that of the source file, while the inode node number of the soft link file is different from that of the source file,
③ The ln command cannot create hard links to directories, but can create soft links. Soft links to directories are frequently used.
④ Deleting a soft link file does not affect the source file or hard link file.
⑤ Deleting a hard-link file does not affect the source file or soft-link file.
6. Deleting the source file of the linked file will not affect the hard-linked file, and the soft link will become invalid (red and white flashing ).
7. Deleting the source file and its hard-link file at the same time will actually Delete the entire file.
Snapshot functions of many hardware devices are similar to hard links.
The soft links can be cross-file systems, and hard links cannot be cross-file systems.
8. How can I reasonably plan partitions for linux systems in production scenarios?
The basic principle of partitioning is simple, easy to use, and convenient for Batch Management. Suggestions for locating server roles are as follows:
① Single-host server: such as 8 GB memory and GB hard disk
Partition:/boot100-200M, swap16G, memory size 8G * 2,/80G,/var20G (can also be divided),/data180G (store web and db data)
Advantage: data disks and system disks are separated to facilitate maintenance in case of problems.
RAID solution: Generally, RAID 5 is a compromise based on data and performance requirements.
② Server Load balancer (such as LVS)
Partition:/boot100-200M, 1-2 times of swap memory ,/,
Advantage: it is simple and convenient. Only a small amount of data is forwarded.
RAID solution: large data volume and high importance. RAID 1 can be used.
③ RSserver under Server Load balancer
Partition:/boot100-200M, 1-2 times of swap memory ,/
Advantage: it is simple and convenient, because there are multiple machines and there are low data requirements.
RAID solution: large data volume, low importance, performance requirements, low data requirements, RAID0 can be used
④ Database Server mysql and oracle such as 16/32 GB memory
Partition:/boot100-200M, swap16G, memory 1 times,/100G,/data remaining (store db data)
Advantages: data disks and system disks are separated, which facilitates maintenance and data integrity when a problem occurs.
RAID solution: Based on data and performance requirements, the master database can adopt RAID 10/RAID 5, and the slave database can use RAID 0 to Improve the Performance (in the case of read/write splitting .)
⑤ Storage Server
Partition:/boot100-200M, 1-2 times of swap memory,/100 GB,/data (data storage)
Advantage: This server should not be partitioned too much. Backup only, with low performance requirements. Large capacity.
RAID solution: sata disks and RAID 5
⑥ Shared storage server (such as NFS)
Partition:/boot100-200M, 1-2 times of swap memory,/100 GB,/data (data storage)
Advantage: This server should not be partitioned too much. NFS sharing requires more performance than storage.
RAID solution: raid5, raid10, or even raid0 (high-availability or dual-write solutions are required) based on performance and access requirements)
7. Monitoring Server cacti and nagios
Partition:/boot100-200M, 1-2 times of swap memory ,/
Advantage: moderate importance and general data requirements.
RAID solution: single disk or dual disk RAID 1. Three disks are RAID 5. You only need to add disks to check the capacity.
9. describes how files are deleted in Linux.
In Linux, the number of links is used to control file deletion. Only when a file does not have any links will the file be deleted. Generally, each file has two link counters to control I _count and I _nlink. When a file is occupied by a program, I _count is added with 1. When there is one more hard link to the file, I _nlink also adds 1. To delete a file, the file is deleted without process occupation, and the number of I _link files is 0.
10. Briefly describe the use of the VI Editor
① The vi editor is the most basic and commonly used standard text editor in linux.
② The vi editor has three working modes: Normal Mode, edit mode, and command mode.
③ In normal mode, any character input on the keyboard is executed as a command. You can also enter a command to move the cursor, copy, paste, or delete characters, words, and rows.
④ The editing mode is mainly used for text input. In this mode, any character entered by the user is saved as the file content.
⑤ In command mode, you can perform operations on the file, such as string SEARCH, replacement, and line number display. You must enter command mode.
⑥ Enter the colon in normal mode to enter the command mode. At this time, the status of the vi window will display a colon, waiting for the user to enter the command. "I" insert mode, which can be edited. After the user input is complete, press [Esc] And then the editor returns to normal mode. In command mode, save and exit. The available commands are wq and x. Add above! Indicates force exit, force save, and so on.
11. Please briefly describe the commands and usage of user management
# Group management commands
Groupadd # Add a group
Groupdel # delete a user group
Groupmod # modify a user group
Groups # display the user group to which the current user belongs
Grpck # Check the integrity of the user group and password files (etc/group and/etc/gshadow files)
>;
Grpunconv # synchronize or create/etc/group through the/etc/group and/etc/gshadow file content, and then delete the gshadow file.
# User management commands
Useradd # Add a user
Adduser # Add a user
Passwd # set a password for the user
Usermod # modify user commands. You can use usermod to modify the login name, user's home directory, and so on.
Pwcov # synchronize users from/etc/passwd to/etc/shadow
Pwck # pwck verifies whether the content of the user configuration file/etc/passwd and/etc/shadow is legal or complete
Pwunconv # Run the pwunconv command to disable the user's projection password. It will save the password from the shadow file and return it to the passwd file.
Finger # tools for viewing user information (Dangerous commands, not commonly used)
Id # view the UID, GID, and user group of the user
Chfn # Change User information tool
Su # User Switching Tool
12. Briefly describe the use of grep advanced parameters in the basic Regular Expression
Common parameters:
-V: exclude Matching content,
-E supports extended regular expressions,
-I ignore case sensitivity,
-O outputs matched content (only one piece, not a row ),
-- Color = auto match content display color,
-N: displays the row number at the beginning of the row.
Special Character considerations:
^ (Angle brackets) word: searches for content starting with word.
Word $ indicates searching for content ending with word.
^ $ Indicates empty rows, not spaces.
. Represents and can only represent any one character. Other functions of non-regular expressions (current directory, file loading)
\ Escape characters to remove characters with special identities, remove the vest, and restore the prototype. For example, \. indicates only the original decimal point.
* Indicates that zero or more first characters are repeated. Not all.
. * Indicates that all characters are matched. ^. * Indicates to start with any character.
[Any character, such as abc], matches any character in the character set [a-z].
[^ Abc] ^ it indicates no meaning in brackets and does not contain meaning. The row that does not contain a, B, or c.
{N, m} indicates to repeat the previous CHARACTER n to m times. {N} must be at least n times. {N} N times, {, m} Up to m times, not limited.
Note: Use grep or sed to escape. That is, \ {\}. egrep does not need to be escaped.
13. Briefly describe the use of advanced parameters of the basic regular expression sed (timing 4 minutes)
Answer:
-N cancel default output
-P print
-D Delete
-E: Allow multiple edits
When using sed to retrieve rows, pay special attention to the use of sed-n's ### G' filename. The sed \ (\) function can remember part of the regular expression, \ 1 is the first remembered mode, that is, the matching content in the first parentheses, \ 2 the second remembered mode, that is, the matching content in the second parentheses, sed can remember up to 9.
The selection of actual characters is best to be unique. Regular Expressions are greedy and always try to match further Matching content. In addition, pay attention to spaces in strings.
14. Check which users are running Linux commands online.
W # display currently logged-on users
Who # display information of logged-on users
Last # list current user information related to past login Systems
Lastlog # Check the last logon time of a specific user
Whoami # print the username associated with the currently active user ID
Finger # User Information Lookup Program
Id # display the user and group information of the specified user or current user
15. Describe the role and syntax of crontab and the points of attention for writing scheduled tasks.
After setting crontab, we can enable Linux to execute the specified system command or shellscript script at a fixed interval. The production environment can be used for log analysis or production backup.
Syntax format:
Crontab [-uuser] file ==="-u means to specify the user
Crontab [-uuser] {-l show file content |-r Delete All crontab files |-e edit crontab files |-I confirm the prompt before deleting the crontab file}
Example:
*/510,12*3-8 **/usr/sbin/ntpdate10.0.0.155>/dev/null2> & 1
The first five paragraphs are the time interval settings, in the unit of minutes, hours, days, months, and weeks (avoid the use of day and week at the same time to avoid system misjudgment ).
The minute range in the first time period is 0-59.
The hour range in the second time period is 0-23.
The Third World segment ranges from 1 to 31
Month range: 1-12
The week range of the fifth time period is 0-7.
* Asterisks indicate that commands are accepted at any time.
, Comma. This command is applicable to the time of separation.
-Minus sign, between two time periods, indicates that the scheduled task is executed during this time period.
/N diagonal lines and n (numbers) indicate execution once every n segments.
Points of attention include: basic essentials of writing and precautions for writing
Seven essentials:
1. Add necessary comments to the scheduled task rules
Second, it is best to write the scheduled Task Command or program to the script for execution.
Third, the script for scheduled task execution must be in a standard path, such as/server/scripts.
4. Add/bin/sh before executing shell script tasks
When executing a scheduled task, if the script is executed, put/bin/sh in front of the script as much as possible.
Fifth, add>/dev/null2> & 1 at the end of the scheduled task
Sixth,/dev/null is a special character device file, indicating a black hole device or an empty device.
VII. Instructions on redirection
> Or 1> output redirection: If you input the previous output to the following file, the original content of the file will be deleted.
>>> Or 1> append redirection: append the previous output to the following file without deleting the original content of the file.
<Or <0-input redirection: Enter redirection is used to change the input of the command, specify the input content, followed by the file name.
<Or <0 input redirection: Followed by a string, used to indicate "input end". You can also use ctrl + d to end the input.
2> error redirection: Enter the error information in the file behind the file to delete the original content of the file.
2> error append redirection: append the error information to the following file, without deleting the original content of the file.
Standard input (stdin): the code is 0, use <or <.
Standard output (stdout): the code is 1, use> or>. Normal output.
Standard Error output (sederr): Code 2, Use 2> or 2>.
Special:
2> & 1 is to redirect the standard error to the standard output (> &).
>/Dev/null2> & 1 is equivalent to 1>/dev/null2>/dev/null
16. List the folders and contents that you consider important in Linux.
①/The folders in the directory contain the following:
/Usr contains all commands and libraries, documents and other files and main applications of the current linux release
/Var contains the files being operated, record files, encrypted files, temporary files, etc.
/Home except for the configuration files, personalized files, and home directories of all users outside the root user, that is, the home Directory
/Proc virtual directory, which actually points to memory instead of Hard Disk
/Bin system execution files (binary files) can be used by common users
/Sbin system execution files (binary files) cannot be used by common users.
/Etc Operating System Configuration File
/Home directory of the rootroot user
/Dev system device files. All linux devices are processed as files. This directory does not contain drivers.
/Lib program and core module shared library (only programs under)
/Boot system boot, boot file, usually grub here
/Opt optional application directory
/Tmp temporary file, the system will automatically clean up
/Lost + found restore file (similar to recycle bin)
/All media disks (sometimes with CDs) will be mounted as folders, And the disc images can also be mounted.
/Where the cd-rom is attached to the cd
② Files under the/usr directory are important. The functions are listed in the following categories:
/Usr/X11X-windows desktop environment
/Usr/doclinux documents
/Usr/share is independent of the data structure of the current computer, such as words in the dictionary
/Usr/bin is similar to/bin but not involved in startup. Most commands are here
/Usr/local applications installed by the local administrator
Applications installed by/usr/local/bin users (Part)
③/Proc directory content
/Proc/cpuinfo processor Information
/Proc/devices list of all devices currently running the kernel
/Proc/dma the DMA channel in use currently
/Proc/filesystem the file system configured for the current running kernel
/Proc/interrupts: current and previous interruptions
/Proc/ioports is using the I/O port
17. Provide the correct command to shut down and restart the server.
(1) shutdown
[-T] specifies how long the system will be shut down
[-R] restart the system
[-K] does not actually shut down, but sends a warning signal to every logged-on user.
[-H] Shut down the system (halt)
(2) halt
Halt is the simplest shutdown command. It actually calls the shutdown-h command. When halt is executed, the application process is killed. After the file system writes, the kernel is stopped.
Some parameters of the halt command are as follows:
[-F] Force shutdown or restart without calling shutdown
[-I] disable all network interfaces before shutting down or restarting
[-P] poweroff is called upon shutdown. This option is the default option.
(3) reboot
The reboot process is similar to that of halt, which is used to restart and halt is used to shut down. Its parameters are similar to those of halt.
(4) init
Init is the ancestor of all processes, and its Process number is always 1. Init is used to switch the running level of the system. The switchover is completed immediately. The init0 command is used to immediately switch the system running level to 0, that is, shutdown. The init6 command is used to switch the system running level to 6, that is, restart.
18. Brief notes for modifying the/etc/sudoers configuration file
① The alias name can contain uppercase letters. Numbers and underscores. If it is a letter, it must be in upper case (the alias is a set with the same attributes ).
② An alias can contain multiple members separated by commas. The member must actually exist.
Alias members are restricted by the alias types Host_Alias, User_Alias, Runas_Alias, and Cmnd_Alias. To define aliases of different types, they must be matched.
③ The user group must be preceded by "%. The member in the Command alias must be the absolute path of the file or directory.
④ Specify that the switching user should be enclosed in brackets (). If omitted, the root user is used by default. If ALL is used in brackets, the user can be switched to ALL users.
⑤ Use the full path for the command path.
6. Each line of the alias rule is regarded as a rule. When a row cannot accommodate any capacity, use \ to continue the row. If more than one line is exceeded, use a backslash to wrap the line.
7. Generally, we do not recommend giving all permissions first. Permissions are granted to users. (Pay attention to permissions and syntax ).
If you do not need a password to directly run the command, add the NOPASSWD parameter.
Deny prohibits the execution of certain programs or commands. You must add "!" before the command action. And placed after the command can be executed.
19. Please describe how to implement fine-grained permission management for centralized management in linux?
① To collect and develop matching information between users and permissions, the principle is to grant minimum permissions, but to complete the responsibilities undertaken.
② Set the corresponding permissions for each user group, and specify the permissions for each command based on the group conditions.
③ Create a user for the planning permission group. Add relevant user groups. And modify the etc/sudoers configuration file.
④ Add the sudo permission opening, confirm that the relevant users are added to the soduers permission list, set the open permission content in detail, and select whether the password-related execution permission is required. (Pay attention to ALL permissions and password modification permission settings ).
⑤ We do not recommend that you grant all permissions first. We recommend that you use a whitelist.
6. Check whether the related permissions are correctly configured during actual debugging and testing.
7. write operation instructions and related precautions.
After the token has been debugged, the system permission settings of all relevant personnel in the email token take effect, along with the operation instructions and related precautions.
20. How can I write the following LinuxSecureCRT command line shortcut key command?
Ctrl + a cursor to the beginning
Ctrl + c interrupt the current program
Ctrl + d Exit the current window or the current user
Ctrl + epointer to end
Ctrl + l clear screen is equivalent to clear
Ctrl + u cut and delete (content before the cursor)
Ctrl + k cut and delete (content after the cursor)
Ctrl + r search (recently used commands)
All tabs and completion commands
Ctrl + shift + c command line copy content
Ctrl + shift + v command line paste content
Ctrl + q cancel screen lock
Ctrl + s execute screen lock
21. Describe the five solutions for server account log auditing.
(1) audit all logs by using the environment variable syslog (too much information, not recommended)
(2) Use sudo with the syslog service to audit sudo operation logs (with less information and good results)
(3) embed a monitor in the bash interpreter so that all users can use the modified bash program as the interpreter.
(4) Qi Zhi's bastion host (commercial products ).
22. If an office host cannot access the Internet (the website cannot be opened), please provide troubleshooting steps?
① First, determine whether the physical link is connected normally.
② Check whether the local IP address, route, and DNS settings are up to standard.
③ Telnet to check whether the WEB of the server is enabled and whether the firewall is blocked.
④ Ping the gateway and perform the basic check. If yes, it indicates that the server can be reached.
⑤ Test the gateway or router first, and then test the router Level 1 test.
6. Test the general situation of ping a public ip address (remember several external IP addresses ),
7. Test DNS smoothness. Ping the corresponding IP address.
After the supervisor passes the preceding check, the supervisor performs the check on the network management router.
23. Simple differences between single quotation marks, double quotation marks, and no quotation marks in Linuxshell
Single quotation marks: What you see is what you get. The content in single quotation marks is output as is, or the content is described as what you see in single quotation marks.
Double quotation marks: output the content in double quotation marks. If the content contains commands, variables, etc., the content will be changed to that, the command will parse the result, and then the final content will be output.
Use 'COMMAND or variable' or $ (command or variable) in double quotation marks)
No quotation marks: output the content. strings containing spaces may not be considered as a whole output. If the content contains commands and variables, the variables and commands will be parsed first, then output the final content. If the string contains special characters such as spaces, it cannot be completely output. You need to add double quotation marks. Generally, consecutive strings, numbers, paths, and so on can be used. However, it is best to use double quotation marks instead.
24. Briefly describe the execution process of several important configuration files during Linux Startup.
After logging on to Linux, the configuration execution sequence is (DebianSerialsCapable ):
/Etc/environment->/etc/profile-> (~ /. Bash_profile | ~ /. Bash_login | ~ /. Profile)-> ~ /. Bashrc->/etc/bashrc-> ~ /. Bash_logout
Description of the functions of each file:
(1)/etc/environment: This configuration file sets the basic PATH variable and the current language variable of the system. Although it is short, it plays an important role in system startup, for example, the content in my system is as follows:
(2)/etc/profile: This file sets the environment information for each user in the system. When the user logs on for the first time, this file is executed. and from/etc/profile. d directory configuration file to collect shell settings.
(3)/etc/bash. bashrc: execute this file for every user running bashshell. When bashshell is opened, the file is read.
(4 )~ /. Bash_profile: each user can use this file to input the shell information dedicated to their own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file.
(5 )~ /. Bashrc: This file contains bash information dedicated to your bashshell. This file is read when you log on and every time you open a new shell.
(6 )~ /. Bash_logout: execute this file every time you exit the system (exit bashshell). In addition, the variables set in/etc/profile (global) can act on any user, while ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
(7 )~ /. Bash_profile is interactive and login to run bash ~ /. Bashrc is the interactive non-login mode that enters bash. Generally, the two settings are roughly the same, so the former usually calls the latter.
25. What is the content of the following path?
/Var/log/messages System log File
/Var/log/secure system security file (file showing Logon Information)
/Var/spool/clientmqueue routine task receipt email storage file
/Proc/interrupts current system interrupt report file
/Etc/fstab configuration file for automatic disk mounting upon startup
Files stored in/etc/profile Environment Variables
26. Please give instructions on eth0 IP addresses and broadcast addresses in Linux. You must use cut, awk, grep, and sed commands.
Method 1: Use grep and cut
Method 2: Use grep and awk (the default Delimiter is space)
Method 3: Use grep and awk (Multi-separator)
Method 4: Use sed and awk
Method 5: Use grep and awk (Multi-separator and plus sign +)
Method 6: awk (separator and row fetch)
Method 7: grep Nic File
Method 8: head is split by awk
27. output the 20 LINUX commands you know and their functions
Cp copy-a (drp),-r copy directory-p keep attribute
Mv mobile files or directories
Mkdir create directory-p recursively create directory mkdir/a/B/c
Touch creates a file,
Cd switch directory (~ Current user's home directory,-last directory)
Cat View File Content-n display row number
Ls to view files under the directory, In the long format of-l,-d to view the directory **********
Rm delete file or directory-r directory-f force Delete (use with caution, mv, find)
Find file or directory-type (f, d, l, c, B),-name-exec execute action *****
Alias viewing and setting aliases
Unalias cancel alias
Seq print sequence-s specifies the separator-w number plus 0 completion digits
The first N rows of the file are viewed in the head. The default value is 10, and the value is-n.
The last N lines of the file are viewed by tail. The default value is 10.-n specifies the number of lines.-f tracks the changes at the end of the file in real time.
Sed linux sanjianke's second child, adding, deleting, modifying, and querying files ,*****
Pwd prints the current working directory
Rmdir Delete empty directory
Echo display output
Xargs (combined with find, ls) and other searched content processing,-n grouping
Tree-L layers-d directory
Rpm-q query-a all
Uname-r kernel-m32-bit or 64-bit-a all information,-n Host Name (hostname)
Hostname Host Name
Whoami view current user
Useradd Add User
Passwd password, -- stdin non-interactive password setting
Su switches user roles.-switches environment variables.