For details on 28 Enterprise O & M posts

Source: Internet
Author: User
Tags ftp protocol

For details on 28 Enterprise O & M posts

1. in Linux, how does one Mount shared directories in windows?

For linux server, you need to manually create a user and pass following the password of the windows host. Note the space and comma.

2. How do I view the number of concurrent http requests and their TCP connection status?

Netstat-n | awk '/^ tcp/{+ B [$ NF]}' END {for (a in B) print, B [a]} 'and ulimit-n check the maximum file descriptor opened in linux. The default value is 1024. It is useless to modify the web server. If you want to use this method, modify one of the following methods: Modify/etc/security/limits. conf * soft nofile 10240 * hard nofile 10240 to take effect after restart.

3. How can I use tcpdump to sniff port 80 for the highest access?

tcpdump -i eth0 -tnn dst port 80 -c 1000 | awk -F”.” ‘{print $1″.”$2″.”$3″.”$4″.”}’ | sort |uniq -c | sort -nr | head-5

4. How do I view the number of files in the/var/log directory?

ls /var/log/ -1R | grep “-” | wc -l

5. How do I view the number of connections of each ip address in Linux?

netstat -n | awk ‘/^tcp/ {print $5}’ | awk -F: ‘{print $1}’ | sort | uniq -c | sort -rn

6. Generate a 32-bit random password in shell

cat /dev/urandom | head -1 | md5sum | head -c 32 >> /pass

7. Calculate the five most visited ip addresses in apache access. log.

cat access.log | awk ‘{print $1}’ | sort | uniq -c | sort -n -r | head -5

8. How to view the binary file content?

We generally use the hexdump command to view the binary file content. Hexdump-c xxx (file name) -C is the parameter. Different parameters have different meanings.-C is the standard hexadecimal and ASCII code.-c is the single-byte character.-B is the single-byte octal character.-o is double Byte octal display-d is double byte decimal display-x is double byte hexadecimal display

9. What does VSZ in ps aux mean? What does RSS mean?

VSZ: Virtual Memory set, virtual memory space occupied by processes RSS: physical memory set, actual physical memory space used for process warfare

10. How to detect and fix/dev/hda5?

Fsck is used to check and maintain inconsistent file systems. If the system power is down or the disk is faulty, use the fsck command to check the file system.

11. Introduce the boot sequence of the Linux system.

Load BIOS-> Read MBR-> Boot Loader-> load kernel-> User-layer init-An inittab file to set the system running level (generally 3 or 5 or 3 is a multi-user command line, 5 is the interface)-> init process executes rc. syninit-> Start the kernel module-> execute script programs running at different levels-> execute/etc/rc. d/rc. local (local Running Service)-> execute/bin/login to log on.

12. Differences between symbolic links and hard links

We can use Symbolic Links, that is, soft connections, as shortcuts in windows. The hard link is like copying another copy. For example, ln 3.txt 4.txt is a hard link, which is equivalent to copying and cannot be used across partitions. However, modification to 3 or 4 will change accordingly, delete 3, 4 without any impact. Ln-s 3.txt 4.txt is a soft connection, which is equivalent to a shortcut. Modifications 4 and 3 will also change. If you delete 3 and 4, it will break down. It cannot be used.

13. Save the Partition Table of the current disk partition

The dd command is a powerful command to convert dd if =/dev/sda of =./mbr.txt bs = 1 count = 512 while copying

14. How can I copy, paste, delete, delete all rows, search by row, and search by letter in text?

The following operations are performed in the command line status. Do not edit the status. Move the row to be copied in the text and press yy to copy it to the row, then press P to paste the Delete row and move it to the modified row. Then press dd to delete all dG. Note that G must be searched in uppercase and by row: in this case, you can find 90th rows and search by letter/path. In this case, you can find the location of the word path. There may be multiple entries in the text and multiple searches will be displayed in different locations.

15. Manually install grub

grub-install /dev/sda

16. Modify Kernel Parameters

Vi/etc/sysctl. conf modify the sysctl-p Parameter here and use it after refreshing.

17. Obtain a random number from 1 to 39

Expr $ [RANDOM % 39] + 1RANDOM RANDOM Number % 39 get remainder range 0-38

18. The number of new connections per second in apache is limited to 1 and the peak value is 3.

The number of new connections per second is generally implemented 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-a input-d 172.16.100.1-p tcp-dport 80-m limit-limit 1/second-j ACCEPT

19. Active and passive FTP Modes

The FTP protocol can work in two ways: PORT and PASV. The Chinese meaning is active and passive. The active connection process is: the client sends a connection request to the ftp port of the server (21 by default). The server accepts the connection and establishes a command link. When data needs to be transmitted, the client uses the PORT command on the command link to tell the server: "I opened PORT XX and you came to connect to me ". The server sends a connection request from Port 20 to port XX of the client and establishes a data link to transmit data. The PASV (passive) connection process is: the client sends a connection request to the FTP port of the server (21 by default). 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 opened port XX and you came to connect to me ". Therefore, the client sends a connection request to port XX of the server and establishes a data link to transmit data. From the above, we can see that the command link connection methods of the two methods are the same, and the data link creation methods are completely different.

20. The/etc/inittab starts with "#", followed by one or more white spaces, and followed by any non-white lines.

grep “^#\{1,\}[^]” /etc/inittab

21. The/etc/inittab contains the rows of a number (that is, a number between two colons ).

grep “\:[0-9]\{1\}:” /etc/inittab

22. How can I add a script to the system service and call it using the service?

Add #! To the script #! /Bin/bash # chkconfig: 345 85 15 # description: httpd and save chkconfig httpd-add to create a system service. Now you can use the service to start or restart the system service.

23. Write a script to add 20 users in batches. the user name is user01-20 and the password is followed by 5 random characters.

    #!/bin/bash    #description: useradd    for i in `seq -f”%02g” 1 20`;do    useradd user$i    echo “user$i-`echo $RANDOM|md5sum|cut -c 1-5`”|passwd –stdinuser$i >/dev/null 2>&1    done

24. Write a script to determine which IP addresses are online in the 192.168.1.0/24 network.

    #!/bin/bash    for 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    }&    done    wait

25. Write a script to check whether a specified script is a syntax error. If any, the user is reminded to press Q or q to ignore the error and exit any other key. You can use vim to open the specified script.

    [root@localhost tmp]# cat checksh.sh    #!/bin/bash    read -p “please input check script-> ” file    if [ -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    fi    else    echo “$file not exist”    exit 1    fi

26. How to write a script:

Create a function and accept two parameters:
1) The first parameter is the URL to download the file, and the second parameter is the directory, that is, the location saved after the download;
2) If the directory provided by the user does not exist, the system prompts whether to create the directory. If the directory is created, the system continues to execute. Otherwise, the function returns an error value of 51 to the calling script;
3) if a directory exists, download the file. After the download command is executed, test whether the file is successfully downloaded. If yes, return 0 to the script. Otherwise, return 52 to the call script;

  [root@localhost tmp]# cat downfile.sh    #!/bin/bash    url=$1    dir=$2    download()    {    cd $dir >> /dev/null 2>&1    if [ $? -ne 0 ];then    read -p “$dir No such file or directory,create?(y/n)” 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 $dir    echo $?

27. Write a script. The detailed requirements are as follows:

1. Create a function that can take the path of a disk device (such as/dev/sdb) as the parameter. Remind the user of the danger before the subsequent steps, and ask the user to choose whether to continue; then, clear all the partitions on the disk device. (The command dd if =/dev/zero of =/dev/sdb bs = 512 count = 1 is displayed, note that the device path should not be wrong;
If this step fails, 67 is returned to the main program;
Create two primary partitions on the disk device. One is 100 mb and the other is 1 GB. If this step fails, 68 is returned to the main program;
Format the two partitions. The file system type is ext3. If this step fails, 69 is returned to the main program;
If the above process is normal, return 0 to the main program;

2. Call this function. Receive the return value of the function execution to determine the execution status and display the information;

Local Darray = ('ls/dev/sd [a-z] ') for I in $ {Darray }; do [["$ I" = "$1"] & Sd = $ I & break done else return66 fi # When the match is successful, go to the selection page and tell the user, whether to continue or not. If an error is entered, an infinite loop is entered. When the user selects Y, the target partition is cleared and the while LOOP while:; do read-p "Warning !!! This operation will clean $ Sd data. next = y, Quit = n [y | n]: "Choice case $ Choice in y) dd if =/dev/zero of = $ Sd bs = 512 count = 1 &>/dev/null & break | return 67; n) exit 88 ;;*) echo "Invalid choice, please choice again. "; esac done # use echo to pass to fdisk for partitioning. If this command fails, it will jump out. The error value is 68. Note that sometimes this return value is very strange, the previous success or failure of the author is the return of 1. After the restart, it will be fine. If you are careful, you can judge the created partition, but you need to use other tools to intercept related fields, echo-e "n \ np \ n1 \ n + 100M \ nn \ np \ n2 \ N \ n + 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 use partprobe, for example, the author's environment is rhel5.8, and after rhel6.0, this command is very dangerous, using partx-a/dev/sdb is better... This item should be careful. If the formatting fails, it indicates that the failed partition is defined as a variable and the function exists, 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 69 done return 0} # the following code calls a function and receives the return value of the function, determine the Error Based on the returned value. Disk_Mod $1 Res = $? [$ Res-eq 0] & exit 0 [$ Res-eq 66] & echo "Error! Invalid input. "[$ Res-eq 67] & echo" Error! Command-> dd fdisk mke2fs

28. How can I display the specific time of the history command?

HISTTIMEFORMAT = "% Y-% m-% d % H: % M: % S" export HISTTIMEFORMAT will be restored after it is restarted. You can write/etc/profile

29. How much can a M Disk Partition be written into 1 K files and 1 m Files respectively? (*)

* Note: The inode size must be taken into account. * answer: To solve this problem, you only need to describe the inode and block technical knowledge: inode stores file attributes (the default size in c6.4 is 256 bytes). the actual size of the block is 1 k (boot) or 4 k (non-system partition) A file must occupy at least one inode and one block * when: "No space left on device" is caused by full inode and block. * When the block is 1 K or 4 K, no matter if the data is written to 1 K or 1 m, the block is full, while inode is sufficient.

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.