Linux operation and maintenance basic problem (II.)

Source: Internet
Author: User

1. Linux Mount Winodws shared folder
# mount-t CIFS//1.1.1.254/ok/var/tmp/share/-o username=administrator,password=yourpass

2. View the number of concurrent requests for HTTP and their TCP connection status:
netstat-n | awk '/^tcp/{++s[$NF]} END {for (a in S) print A, S[a]} '

3. Sniff 80-port access with tcpdump to see who is the tallest
tcpdump-i ETH0-TNN DST Port 80-c | awk-f "." ' {print $ '. $ "." $ "." $4} ' | Sort | uniq-c | Sort-nr |head-20

4. Count the number of files in the specified directory
Find/-type f | wc-l

5. View the number of IP connections
netstat-n | awk '/^tcp/{print $} ' | awk-f: ' {print $} ' | sort | uniq-c | Sort-rn

6. "32-bit random password generation under shell"
tr-dc \~\ ' \[email protected]#\\$\\%\\^\\&\*\-\_\+\=\|\\\?\/\.\>\,\<a-za-z0-9_ </dev/urandom|head -C 32|xargs

7, statistics of Apache Access.log in the most visited 5 IP
cat Access.log |awk ' {print $} ' |uniq-c|sort-rn |head-n 5

8. How to view the contents of a binary file
echo/etc/passwd | 16 binary and ASCII code display for HEXDUMP-C <== specification (Canonical HEX+ASCII displays)

9. What does the vsz in PS aux mean? What does RSS represent?
aux
a displays all terminal-related processes, initiated by the terminal.
x shows all processes unrelated to the terminal.
u displays a user-directed list of users.
VSZ Virtual Memory set, process-occupied virtual memory space
RSS Physical Memory set, process warfare with actual physical memory space.

10, Detect and Repair/dev/hda5
e2fsck-p/dev/hda5//e2fsck for ext2 ext3 type file system

11. Linux Boot Sequence
Boot order:
POST (Power-on self-test)--Boot device sequence--&GT;MBR (bootloader)--unzip kernel, load kernel to memory and load init process (/etc/inittab)

12. The difference between symbolic links and hard links
Hard links: Files of different paths specify the same inode
Hard links cannot exist across partitions
Hard links cannot be linked to directories (to avoid circular references)
Deleting a hard link only reduces the number of times the file is hard-linked, and the source file does not move.
Soft Link: is a separate file that has its own independent inode
Refers to the path itself, not the inode
Delete soft links, not related to source files
A soft link does not store any data, just another path that stores access to the file.
Soft links can be created on a directory or across partitions
The source file is deleted and the soft connection will not be available.

13. Save the partition table of the current disk partition
# sfdisk-d/dev/sdb >/etc/sdbpar.bak//Save partition Table
# SFDISK/DEV/SDB


14, detect and automatically repair the file system
E2fsck-check a Linux ext2/ext3 file system
-B Specify block size
-F Force Detection.
-P Automatic Repair file system

15. Install Grub Manually
Install grub Manually
# grub-install--root-directory= (Specify boot directory) DEVICE
Or
Grub
Grub>root (hd0,0)
Grub>setup (hd0)

16, change the kernel parameters
# Sysctl
-P Do not restart the system, let the kernel reread/etc/sysctl.conf files
-a displays all kernel parameters and the values they are using.
-W Temporary set/etc/sysctl.conf parameter sysctl-w net.ipv4.ip_froward=0

17. Take random numbers within the specified range
echo $[$RANDOM%39] to the 39, the remainder must be 39 or less of the number.
No bounds echo $RANDOM

18. Limit the number of Apache connections per second to 1 and a peak of 3
Iptables-a input-d 172.16.100.1-p tcp--dport 80-m limit--limit 1/second--limit-burst 3-j ACCEPT

19. FTP Active and Passive mode
Active mode
1. Any port greater than 1024 to the 21 port of the FTP server. (client-initiated connection)
2. The FTP server is 21 ports to a port greater than 1024. (server responds to client's control port)
3. The FTP server is 20 ports to a port greater than 1024. (Server-side initialization data is connected to the client's data port)
4.20 ports greater than 1024 ports to the FTP server (the client sends an ACK response to the server's data port)
Passive mode
1. From any port greater than 1024 to server 21 port (client initiated connection)
2.21 Port of the server to any port greater than 1024 (the server responds to the connection to the client's control port)
3. From any port greater than 1024 to the server (client-initiated data connection to any ports specified by the server)
4. Server greater than 1024 port to remote port greater than 1024 (the server sends ACK response and data to the client's data port)

Client and the server to establish a connection, after the TCP three handshake, the connection is established, the client can be established through the connection channel to send commands to the servers, the server according to the client's command,

When sending data to the client, the server will then establish a TCP connection with the client for the purpose of transmitting the data, and the connection is the data connection.
Data connection has two modes of operation: Active mode and passive mode
Active mode means that the server is active
Passive mode means that the server is passive.
Active mode:
The server side automatically opens Port 20th, which is the data transfer port. Actively go to the port that connects the client's command port +1. The data connection is automatically disconnected when the transfer is complete.
Passive mode:
The server-side notifies the client of its open port, notifies the client to connect to its own data port, and the client uses the port of command port +1 to connect to the server-side data port.
In passive mode, the server's data connection port uses a random port. The active mode server is using port 20.



20, display/etc/inittab in the beginning of #, and followed by one or more white space characters, followed by any non-whitespace character line;
grep "^\#[[:space:]]\{1,\}.\{1,\}"/etc/inittab

21, display/etc/inittab contains: A number: (that is, two colons in the middle of a number) line;
grep "\:[0-9]\{1\}\:"/etc/inittab

22, how to add their own script to the service inside, that is, you can use the service command to invoke
#!/bin/bash
Chkconfig:-90 10
Description:just a test
echo "Hello,$1"

MV Test/etc/init.d/
chmod +x/etc/init.d/test
Chkconfig--add Test
Service test start//Can see Hello,start indicates success

23, write a script, realize the bulk add 20 users, the user name is user1-20, password is user followed by 5 random characters
#!/bin/bash
For i in {1..20}; Do
pass=$ (tr-dc \~\ ' \[email protected]#\\$\\%\\^\\&\*\-\_\+\=\|\\\?\/\.\>\,\<a-za-z0-9_ <= "" dev= "" Urandom|head= ""-c= "" 5)
Useradd User${i}
echo $pass | passwd User${i}--stdin
echo "User${i} <=============> $pass" >>./userlist.out
Done
Echo ' sucess,passwd is in Userlist.out '

24, write a script to achieve the Judgment 192.168.1.0/24 Network, the current online IP What, can ping general think online
#!/bin/bash
Ips= "192.168.1."
For i in {1..254}; Do
Ping-w 1-c 1 ${ips}${i} &>/dev/null && echo "${ips}${i} is up" | Tee-a Uplog | | echo "${ips}${i} is down"
Done
echo "Please read Uplog-know which host is online."

Linux operation and maintenance basic problem (II.)

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.