In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the Linux operation and maintenance test questions". In the course of the operation of the actual case, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
How to hang 1.linux in the shared directory mount.cifs / / 192.168.1.3/server / mnt/server-o user=administrator,pass=123456 under windows
The server under linux needs to be created manually. The following user and pass are the accounts and passwords of the windows host. Pay attention to spaces and commas.
two。 Check the number of concurrent requests of http and its TCP connection status netstat-n | awk'/ ^ tcp/ {+ + b [$NF]} END {for (an in b) print a, b [a]}'
There is also ulimit-n to view the largest file descriptor opened by the linux system, which defaults to 1024 here. It is useless to modify the web server no matter how big it is. If you want to use it, you can modify several methods. Here is one of them:
Modify / etc/security/limits.conf
* soft nofile 10240 * hard nofile 10240
Take effect after restart
3. Use tcpdump to sniff the access to port 80 to see who has the highest tcpdump-I eth0-tnn dst port 80-c 1000 | awk-F "."'{print $1 "." $2 "." $3 "." $4}'| sort | uniq-c | sort-nr | head-54. View the number of files in the / var/log directory ls / var/log/-lR | grep "^ -" | wc-L5. Check the number of connections per IP of the current system netstat-n | awk'/ ^ tcp/ {print $5}'| awk-F:'{print $1}'| sort | uniq-c | cat / dev/urandom generated by 32-bit random passwords under sort-rn6.shell | head-1 | md5sum | head-c 32 > > / pass
Save the generated 32-bit random number to the / pass file
7. Count out the five most visited IPcat access_log in apache's access.log | awk'{print $1}'| sort | uniq-c | sort-n-r | head-58. How to view the contents of a binary file
We usually use the hexdump command to view the contents of the binary file.
Hexdump-C XXX (file name)-C is a parameter that has different meanings.
-C is a more standard hexadecimal and ASCII code display.
-c is a single-byte character display
-b single byte octal display
-o is a double-byte octal display
-d is a double-byte decimal display
-x is a double-byte hexadecimal display
What does VSZ stand for in 9.ps aux and what does RSS stand for
VSZ: virtual memory set, virtual memory space occupied by processes
RSS: physical memory set, actual physical memory space for process warfare
10. Detect and repair / dev/hda5
Fsck is used to check and maintain inconsistent file systems. If the system is powered off or there is a problem with the disk, you can use the fsck command to check the file system. Usage:
Boot sequence of umount / dev/hda5; e2fsck-p / dev/hda5;mount / dev/hda511.Linux system
Boot sequence:
1). Bios program reads the information on CMOS into memory, obtains the parameters of each hardware, detects and initializes the hardware (POST,Power-on self-test, power-on self-test), and determines the order of starting devices.
2). Bios reads the bootloader (boot loader) in MBR into memory.
3)。 The bootloader reads the kernel files into memory, and after the kernel is loaded, it redetects the hardware and loads the drivers of each hardware to make the hardware ready!
4)。 Run the first process, initrd, and start various services step by step.
5)。 In addition, if it is a multi-system host, it also includes the contents of the boot loader and grub. Each partition will also have a boot sector (boot sector) to perform the multi-boot function.
twelve。 The difference between symbolic links and hard links
1)。 Hard connection (actual connection): multiple file names correspond to an inode in the block of the directory, which can be understood as an alias of the file. There is no need to occupy additional inode and block, just add point data under the block of the directory. You can only use hard connections for files, not for directories. Using the command ln filename1 filename2, generate a hard connection (alias) filename2. File to filename1.
2)。 Symbolic link (shortcut): create a file (inode+block). Block records the inode of the directory to which the file needs to be connected and the file name of the file, which becomes a symbolic link and can be understood as a shortcut. Symbolic links can be directed to directories. Ln-s filename1 filename2
We can think of symbolic links, or soft links, as shortcuts in windows systems.
The hard link is like another copy.
Ln 3.txt 4.txt this is a hard link, equivalent to replication, can not be cross-partition, but the modification of 3Jing 4 will change, if deleted 3Jing 4 will not be affected in any way.
Ln-s 3.txt 4.txt this is a soft connection, equivalent to a shortcut. The modification of 4pr 3 will also change. If you delete 3pr 4, it will be broken. It can't be used.
13. Save the partition table of the current disk partition
The dd command is a powerful command that converts while copying.
Dd if=/dev/sda of=./mbr.txt bs=1 count=512
You can also go like this:
Sfdisk-d / dev/sdb > / etc/sdbpar.bak: save the partition table sfdisk-d / dev/sdb: view the partition table 14 of the whole hard disk sdb. I will do a simple one myself, how to copy, paste, delete lines, delete all, find by line and find by letter in the text.
The following actions are all operated in the command line state, not in the editing state.
Move to the line you want to copy in the text, press yy to copy it wherever you want, and then press P to paste it.
Delete line move to change line press dd
Delete all dG. Note that G must be capitalized here.
Find by line: 90 so you find line 90
Find / path by letter so that you can find the location of the word path. There may be more than one in the text, and multiple searches will be displayed in different locations.
15. Manually install grubgrub-install / dev/sda16. Modify kernel parameter vim / etc/sysctl.conf here modify parameter sysctl-p can be used after refresh. Take the random number expr $[$RANDOM%39] + 1RANDOM random number% 39 in the range of 1-39 and the remainder range from 0 to 3818. Limit the number of new connections per second for apache to 1, with a peak of 3
The number of new connections per second is generally done by the firewall. Apache itself does not seem to be able to set the number of new connections per second, but can only set the maximum connection:
Iptables-An INPUT-d 172.16.100.1-p tcp-- dport 80-m limit-- limit 1/second-j ACCEPT
The hardware firewall is easier to set up, has an interface, and can fill in the numbers directly.
The maximum connection apache itself can be set
MaxClients 3, the prerequisite for modifying apache maximum connections is to modify the default number of tcp connections on the system. I also said it in my blog, so I won't talk about it.
Active mode and passive mode of 19.FTP
FTP protocol has two working modes: PORT mode and PASV mode, which means active and passive in Chinese.
The PORT (active) connection process is that the client sends a connection to the server's FTP port (the default is 21). Please, the server accepts the connection and establishes a command link. When it is necessary to transmit data, the client uses the PORT command on the command link to tell the server, "I have opened the XX port, you come and connect me". So the server sends a connection request from port 20 to the client's XX port and establishes a data link to transmit data.
The PASV (passive) connection process is that the client sends a connection to the server's FTP port (the default is 21). Please, the server accepts the connection and establishes a command link. When data needs to be transmitted, the server uses the PASV command on the command link to tell the client, "I have opened the XX port, you come and connect to me." So the client sends a connection request to the server's XX port and establishes a data link to transmit data.
As can be seen from the above, the command link connection methods of the two modes are the same, while the data link establishment methods are completely different.
20. Display / etc/inittab begins with # followed by one or more white space characters, followed by any non-white space character line grep "^ #\ {1,\} [^]" / etc/inittab21. The display / etc/inittab contains a number: the line grep "\: [0-9]\ {1\}\:" / etc/inittab22. How to add the script to the system service, that is, to use service to call
Add to the script
#! / bin/bash# chkconfig: 345 85 15# description: httpd
And then save.
Chkconfig httpd-add create system service
You can use service to start or restart now
23. Write a script to add 20 users in batch, the user name is user01-20, and the password is user followed by five random characters #! / bin/bash#description: useraddfor i in `echo-f "g" 120`; douseradd user$iecho "user$i: `echo $RANDOM | md5sum | cut-c 1-5`" | passwd-stdinuser$i > / dev/null 2 > & 1done24. Write a script to determine which IP is currently online in the 192.168.1.0 IP 24 network, and can ping the general rule that online #! / bin/bashfor ip in `seq 1 255` do {ping-c 1 192.168.1.$ip > / dev/null 2 > & 1 if [$?-eq 0]; then echo 192.168.1.$ip UP else echo 192.168.1.$ip DOWN fi} & donewait25. Write a script to determine whether a specified script is a syntax error If there is an error, remind the user to type Q or Q to ignore the error and exit any other keys. You can open the specified script [root@localhost tmp] # cat checksh.shangqqqbinanda through vim. Bashread-p "please input check script- >" fileif [- f $file]; then sh-n $file > / dev/null 2 > & 1 if [$?-ne 0] Then read-p "You input $file syntax error, [Type q to exit or Type vim to edit]" answer case $answer in q | Q) exit 0;; vim) vim $file;; *) exit 0;; esac fielse echo "$file not exist" exit 1fi26, write a script
Create a function that accepts two parameters:
1)。 The first parameter is URL, which is the downloadable file, and the second parameter is the directory, which is the location saved after the download.
2)。 If the directory given by the user does not exist, prompt the user whether to create it; if so, continue to execute, otherwise, the function returns an error value of 51 to the calling script
3)。 If the given directory exists, download the file; test whether the file download is successful after the download command is executed; if successful, return 0 to the calling script; otherwise, return 52 to the calling script
[root@localhost tmp] # cat downfile.shimoo raceme [download () {cd $dir > > / dev/null 2 > & 1 if [$?-ne 0]; then read-p "$dir No such file or directory,create? (YGO)" answer if ["$answer" = "y"] Then mkdir-p $dir cd $dir wget $url 1 > / dev/null 2 > & 1 else return "51" fi fi if [$?-ne 0]; then return "52" fi} download $url $direcho $27, write a script
1. Create a function that accepts a disk device path (such as / dev/sdb) as an argument; remind the user of the danger before really starting the next steps, and let the user choose whether to continue or not; then clear all partitions on the disk device (prompt, use the command dd if=/dev/zero of=/dev/sdb bs=512 count=1 implementation, note that the device path is not written wrong
If this step fails, return 67 to the main program
Then create two primary partitions on this disk device, one with a size of 100m and one with a size of 1G; if this step fails, return 68 to the main program
Format the two partitions with the file system type ext3;. If this step fails, return 69 to the main program.
If all the above procedures are normal, return 0 to the main program
2. Call this function; and judge its execution by receiving the return value of the function execution, and display the information
Local Darray= (`ls / dev/sd [amurz] `) for i in ${Darray}; do [["$I" = "$1"]] & & Sd=$i & & breakdone else return66 fi# when the match is successful, enter the selection, tell the user whether to continue, and enter an infinite loop if the error is typed. When the user selects Y, the target partition is cleared and while jumps out of the while loop: Do read-p "warningbirds awarded this operation will clean $Sd data.Next=y,Quit=n [y | n]:" Choice case $Choice iny) dd if=/dev/zero of=$Sd bs=512 count=1 & > / dev/null & & break | | return 67;; n) exit 88;; *) echo "Invalid choice,please choice again."; esacdone
Use echo to pass to fdisk for partition, if this command fails, jump out, error value 68, it should be noted that sometimes this return value is very strange, the author before success or not is returned 1, and then restart, then, if careful, you can judge the created partition, but you need to use other tools to intercept the relevant fields, although a little trouble, but no big deal
Echo-e "n\ np\ N1\ n\ nThe 100m\ nn\ np\ N2\ n\ nThe 1024M\ nw\ n" | fdisk / dev/sdb& > / dev/null | | return 68
Before formatting, let the kernel re-read the disk partition table. It is worth noting that some system versions do not use partprobe. For example, the author's environment is rhel5.8, but after rhel6.0, this command is very dangerous, while using partx-a / dev/sdb is even better. If formatting fails, you will be told to define the failed partition as a variable, jump out of the function, and bring out the error value 69.
`partprobe`Part = `fdisk-l / dev/$Sd | tail-2 | cut-d ""-f1`for M in ${Part}; do mke2fs-j $M & > / dev/null & & ErrorPart=$M & & return 69done return 0}
The following code calls the function, receives the return value of the function, and determines where the error is based on the return value.
Disk_Mod $1Responsible? [$Res-eq 0] & & exit 0 [$Res-eq 66] & & echo "Error! Invalid input." [$Res-eq 67] & & echo "Error! Command-> dd [$Res-eq 68] & & echo" Error! Command-> fdisk [$Res-eq 69] & & echo "Error! Command-> mke2fs" what are the Linux operation and maintenance test questions? thank you for your reading. if you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.