Linux daily operation and maintenance summary

Source: Internet
Author: User
Tags rsync

1. How do I see the current Linux system with several physical CPUs and the number of cores per CPU?

Number of physical CPUs: Cat/proc/cpuinfo |grep-c ' physical ID '
How many cores does the CPU have: Grep-c processor/proc/cpuinfo
Divide the total number of cores of the CPU by the number of physical CPUs to get the number of cores per CPU.

2. Check the system load there are two common commands, which are the two? What do these three numbers mean?
Two commands are W and uptime, respectively.
These three system load values represent the average number of tasks active in 1, 5, and 15 minutes, respectively.

3. Vmstat R, B, Si, so, bi, bo What do these columns mean?
R indicates the number of processes running and waiting for CPU time slices
b indicates the number of processes waiting for the resource, such as waiting for I/O, memory, etc.
Si indicates the amount of memory entered by the swap area
So the number of memory into the swap area
The amount of data that bi reads from a block device (read disk)
The amount of data that Bo writes from a block device (write disk)

4. Linux system, do you know how to differentiate between buffer and cache? The
simply says that the data in buffer is going to be written to the disk, and the data in the cache is read from the disk. The
cache caches data that is read from disk to facilitate the next access of the data, improve the efficiency of data access, and avoid frequent disk operations. Linux automatically uses all the free memory as a buffer, and when the program needs more memory, it also automatically reduces the size of the buffer. The
buffer is used to buffer the disk write operations of the data by centralizing the scattered writes, reducing disk fragmentation and repeated pathfinding of the hard disk, thereby improving system performance. Linux has a daemon that periodically empties the buffered content (that is, writes the disk) or manually empties the buffer via the Sync command.

5. When using top to view system resource usage, which column represents memory consumption?
Res This column represents the amount of physical memory consumed

6. How to check the network card traffic in real time? How do I view historical network card traffic?
Sar-n DEV 1 100
Sar-n DEV can view the day's historical network card traffic
Sar-n dev-f/var/log/sa/saxx where xx is the date

7. How do I see which processes are currently in the system?
PS aux

8. PS when viewing the system process, there is a column stat, if the current process of the stat for SS what meaning? What do you mean by Z?
The SS indicates that the current process is the main process and is dormant; Z Indicates a zombie process

9. How do I see which ports are open on my system?
Netstat-lnp

10. How do I check the status of My network connection?
Netstat-an

11. Want to modify IP, which configuration file to edit, after modifying the configuration file, how to restart the network card, so that the configuration takes effect?
Vim/etc/sysconfig/network-scripts/ifcft-eth0 If it is eth1 the file name is Ifcft-eth1
After you modify the NIC, you can use the command: Ifdown eth0; ifup Eth0 Restart the network card, you can also restart Networking services: Service Network restart

12. Can I configure multiple IPs for a network card? If so, how to configure?
You can configure multiple IPs for a network card, with the following configuration steps:
1) CD/ETC/SYSCONFIG/NETWORK-SCRIPTS/CP Ifcfg-eth0 ifcfg-eth0\:1
2) values of vim ifcfg-eth0\:1 #修改DEVICE和IPADDR, netmask, and gateway (if necessary)
3) Restart Network Service

13. How do I see if a network adapter is connected to the switch?
Mii-tool eth0 or Mii-tool eth1

14. How to view the host name of the current host, and how to modify the hostname? What configuration file do I need to modify to continue to take effect after reboot?
Enter the command hostname can view the current hostname, modify the host name can be through the command: hostname newhostname
The configuration file needs to be modified/etc/sysconfig/network if the reboot is still in effect

15. Which configuration file do I need to modify to set DNS?
Need to modify/etc/resolv.conf,
If you modify the file and then restart the network services DNS related settings are lost, you need to add dns1=xxxxx such settings in/etc/sysconfig/network-scripts/ifcfg-eth0

16. Write a rule using iptables: direct rejection of packets with source IP for 192.168.1.101 access to native 80 ports
Iptables-i input-s 192.168.1.101-p tcp–dport 80-j REJECT

17. How do you want to save the Iptable rules to a file? How to recover?
Save: Iptables-save > 1.ipt
Recovery: Iptables-restore < 1.ipt

18. How do I back up a user's task schedule?
Copy the user's cron file directly cp/var/spool/cron/username/bak/

19. What does the preceding 5-digit table mean in the task plan format?
Time-sharing Week

20. How can I turn off the unused services in the system?
NTSYSV Tools
Or use chkconfig servicename off

21. How to make a service (if the service name is Nginx) open only in 3, 52 runlevel, other levels off?
Chkconfig Nginx off
Chkconfig–level/Nginx on

What is the difference between the following two methods in the rsync Sync command?
(1) rsync-av/dira/ip:/dirb/is synchronized via SSH
(2) RSYNC-AV/DIRA/IP::d IRB is synchronized via the Rsync service

When Rsync is synchronized, how can I synchronize the destination file or directory of a soft connection if there is a soft connection in the source to be synchronized?
If there is a soft connection in the source, you need to add an-l option

24. When an account logs on to Linux, what log files will the system record related information?
There are two log files: 1)/var/log/secure This record verifies the user information of the process 2)/var/log/wtmp This log records the user information successfully logged in

25. When there is a problem with the NIC or hard drive, which command can we use to view the information?
Dmesg

26. Use Xargs and exec respectively to implement the requirement to modify the permissions of all files with the suffix. txt in the current directory to 777.
Xargs:find./-type F-name "*.txt" |xargs chmod 777
Exec:find./-type F-name "*.txt"-exec chmod 777 {} \;

27. There is a script that can run for more than 2 days, how do you make it run uninterrupted, and you can watch the output information of the script at any time?
Using the Screen tool

28. Under the Linux system, how to capture the package according to the following requirements: only to filter out the HTTP service, the target IP is 192.168.0.111, catch 1000 packets altogether, and save to 1.cap file?
TCPDUMP-NN-S0 host 192.168.0.111 and Port 80-c 1000-w 1.cap

When rsync synchronizes data, how do I filter out all. txt files that are out of sync?
–exclude= "*.txt"

When rsync synchronizes data, if the target file is newer than the source file, how do I ignore the file?
Plus-u option

31. Want to visit a website under the Linux command line, and the site domain name has not been resolved, how to do?
Modify/etc/hosts to add parsing records, or use Curl-x

32. Which file can we edit when we customize the domain name resolution? Can one IP correspond to multiple domain names? Does a domain name correspond to multiple IPs?
Edit/etc/hosts, can be an IP corresponding to multiple domain names, not a domain name on multiple IP

33. Which command can we use to view the historical load of the system (e.g. two days ago)?
Sar-q-f/var/log/sa/saxx where xx is two days before the date

34. How do I specify a DNS server under Linux to resolve a domain name?
Dig @DNSip domain.com

35. When using rsync to synchronize data, if we are using SSH, and the target machine sshd port is not the default 22 port, then how do we do?
Rsync "–rsh=ssh-p Port"

When Rsync synchronizes, how to delete the data of the target data, that is, the source does not exist, but the target exists files or directories?
–delete

37. When using free to view memory usage, which value represents the amount of memory actually available?
The second line-/+ Buffers/cache corresponding to the number of free

38. One day you suddenly find that the company's website access speed is slow and slow, what should you do? (Server can log in, prompt: You can start from the system load and network card traffic)
First login to the server, first look at the load situation, using command W, if the first value is large, then use Vmstat 1 to see what is the lack of resources caused by the high load, can be r,b,si,so The number of columns is calculated because of the lack of resources. For example, the R column value is large, you need to use the top command to see which process consumes more CPU, if the number of Si,so two column changes frequently, it means that there is not enough memory, you can also use the top command to see which processes occupy more memory.
If the system load is not high, you need to check the network card traffic is normal: Sar-n DEV 1 10 compared to the usual network traffic to see if normal.

When Rsync uses the service mode, if we specify a password file, how much permission should the password file be set to?
600 or 400 in short, the group and other users can not read and cannot write or execute


This article is from the "Old seven Linux Operations Management" blog, please be sure to keep this source http://asd9577.blog.51cto.com/4291946/1934210

Linux daily operation and maintenance summary

Related Article

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.