Interview Questions for Sohu Linux engineers

Source: Internet
Author: User

Interview Questions for Linux System Engineers:
1. view the maximum value of a single shared memory segment in Linux (command)
IPCS-m
IPCS-
2. What command is used to query the server port of the specified IP address?
The NMAP and nbtscan commands should be used to scan the question.
3. What commands are used in crontab to define the priority level for executing a program?
Nice/renice: Process Execution priority
Concept:
Process Priority: The system allocates CPU time based on different process priorities. High-priority processes get more CPU usage time to increase the speed and shorten the overall execution time.
Process Priority:-20 to 19
Highest level:-20
Minimum: 19
The system administrator has the right to set the process priority to-1 to-20, while normal users can only set 0 to 19.
The default running level of a process is 0.
The default level of a process executed by nice is 10 (that is, when nice <program name> is not specified ).
Format:
Nice <program name>
Nice-<Grade> <program name>
For example: (add after command & indicates that the server will run later)
VI & priority level 0, default level.
Nice VI & priority level 10, default level when nice is used for program execution.
Nice-50 VI & Priority Level 19,-number indicates the option, level 50 exceeds the minimum level 19, so the system executes at Level 19.
Nice-18 VI & priority 18.
Nice -- 50 VI & priority-20, option value:-50, exceeds the highest level-20, so the system runs at level-20.
Nice -- 18 VI & priority-18.
You can use PS-L to view the execution of the preceding commands (note that the Ni values of each VI process are different ).
Re-adjust the priority of the process being executed:
Adjust the level of the specified PID Process
Renice <Grade> <pid>
Note: <level> is a parameter, not an option, and there is no prefix-number.
Adjusts the levels of all processes of a specified user.
Renice <Grade> <username 1> <username 2>...
Adjusts the levels of all processes of all users in the specified group.
Renice <Grade>-G <group name 1>
4. How to make the history command display the specific time
Histtimeformat = "% Y-% m-% d % H: % m: % s"
Reset CT histtimeformat
It will be restored after reboot. You can write/etc/ProFile
5. view the mail queue of the specified user in Linux
Mailq command
Print two types of list:
The mailq command lists the following message queues:
Mail queue (1 request)
--- Qid ---- -- size -- ----- Q-time ----- ------ sender/recipient -----
Aa02508 3 Thu Dec 17 10:01 Root
(User unknown)
Bad_user
The mailq-V command lists the following message queues:
Mail queue (1 request)
--- Qid ---- -- size ---priority---- Q-time --- -- Sender/recipient --
Aa02508 3 1005 Dec 17 Root
(User unknown)
Bad_user
6. view the library files currently loaded in Linux.
Lsof
7. How does the ext3 File System Restore the RM command to delete files?
(1) A brief introduction to the ext3 File System Structure
In the ext3 File System Used in Linux, files are stored in blocks. By default, the size of each block is 1 K. Different blocks are distinguished by block numbers. Each file has a node that contains information such as the file owner, read/write permission, and file type. For a file smaller than 12 blocks, the block number of the file data block is directly stored in the node. If the file contains more than 12 blocks, the node stores the block number of an indirect block after the 12 blocks. In the block corresponding to this indirect block number, block number that stores 256 file data blocks (each block number in ext2fs occupies 4 bytes, so that the block number that can be stored in a block is 1024/4 = 256 ). If a larger file exists, the second-level indirect block and third-level indirect block appear in the node.
(2) restore the accidentally deleted file
Most Linux distributions provide a debugfs tool for editing ext3 file systems. However, there is still some work to do before using this tool.

First, Remount the partition where the accidentally deleted file is located in read-only mode. Run the following command: (assume that the file is in the/usr partition)
Mount-r-n-o remount/usr
-R indicates read-only mounting;-N indicates no write to/etc/mtab. this parameter is added if the file on/etc is restored. If the system says XXX partion busy, you can run the fuser command to check which processes use the files in this partition:
Fuser-v-M/usr
If there are no important processes, run the following command to stop them:
Fuser-K-v-M/usr
Then you can remount these file systems.
If all the files are installed in a large partition, you can use Linux single to enter the single-user mode at the boot prompt to minimize the chance of system processes writing data to the hard disk, or simply mount the hard disk on another machine. In addition, do not write the recovered data to/to avoid damaging the useful data. If the host has DoS/Windows, you can write it to these partitions:
Mount-r-N/dev/hda1/mnt/had
Then you can run debugfs: (Suppose Linux is in/dev/hda5)
# Debugfs/dev/hda5
The prompt debugfs appears:
The lsdel command can be used to list the information of many deleted files:
Debugfs: lsdel
Debugfs: 2692 deleted inodes found.
Inode owner mode size blocks time deleted
164821 0 100600 8192 1/1 sun May 13 19:22:46 2001
.............................................................................................
36137 0 100644 4 1/1 Tue Apr 24 10:11:15 2001
196829 0 100644 149500 38/38 mon May 27 13:52:04 2001
Debugfs:
There are many objects listed (2692 objects are found here). The first field is the file node number, the second field is the file owner, the third field is the read/write permission, and the next is the file size, which occupies the number of parts, deletion time. Then we can determine what we need based on the file size and deletion date. For example, we want to restore a file with a node of 196829:
You can first check the file data status:
Debugfs: stat
Inode: 196829 type: regular mode: 0644 flags: 0x0 version: 1
User: 0 group: 0 size: 149500
File ACL: 0 directory ACL: 0
Links: 0 blockcount: 38
Fragment: Address: 0 Number: 0 size: 0
Ctime: 0x31a9a574 -- mon May 27 13:52:04 2001
Atime: 0x31a21dd1 -- Tue May 21 20:47:29 2001
Mtime: 0x313bf4d7 -- Tue Mar 5 08:01:27 2001
Dtime: 0x31a9a574 -- mon May 27 13:52:04 2001
Blocks:
594810 594811 594814 594815 594816 ........................................
Total: 38
Then you can use the dump command to restore the file:
Debugfs: dump/mnt/hda/01.sav
In this way, the file is restored. Exit debugfs:
Debugfs: Quit
Another method is to manually edit inode:
Debugfs: Mi
Mode [0100644]
User ID [0]
Group ID [0]
Size [149500]
Creation Time [0x31a9a574]
Modification time [0x31a9a574]
Access time [0x31a21dd1]
Deletion time [0x31a9a574] 0
Link count [0] 1
Block count [38]
File flags [0x0]
Reserved1 [0]
File ACL [0]
Directory ACL [0]
Fragment Address [0]
Fragment number [0]
Fragment Size [0]
Direct block #0 [594810]
..................................
Triple indirect block [0]
After the MI command is used, a line of information is displayed each time for editing. For other lines, press enter to confirm. Change the deletion time to 0 (not deleted), and change link count to 1. After modification, exit debugfs:
Debugfs: Quit
Then use fsck to check/dev/hda5
Fsck/dev/hda5
The program will find the lost data block and put it in lost + found.
8. view the driver version of a hardware in the current system. For example, Nic
Dmidecode
9. What are the three types of DNS servers?
Master Slave Cache
10. Implementation steps for Apache directory access authentication (set with htpasswd)
Htpasswd-C/directory user
Alias/directory
11. Use tcpdump to listen to data with Host IP address 192.168.1.1 and TCP port 80, and write the corresponding command
Tcpdump TCP port 80 host 192.168.1.1
12. Briefly describe the functions and implementation principles of IDS
Intrusion Detection: the device is placed behind the first route entry in intelnet. Detects all packets entering the route. If any exception occurs, an alarm is triggered.
13.use sedto modify the 23 rows test of test.txt to tset;
Sed '23s/test/tset/G' test.txt

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.