Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the interview questions for Linux operation and maintenance staff?

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article introduces the relevant knowledge of "what are the interview questions of Linux operation and maintenance". In the course of the operation of actual cases, 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!

1. What is operation and maintenance? What is the game operation and maintenance?

1) Operation and maintenance refers to the maintenance of network software and hardware already established by large organizations, which is to ensure the normal operation and operation of the business.

In the course of his operation, he maintains him, and he integrates network, system, database, development, security and monitoring technology.

There are many kinds of operation and maintenance, including DBA operation and maintenance, website operation and maintenance, virtual operation and maintenance, monitoring operation and maintenance, game operation and maintenance, and so on.

2) Game operation and maintenance has a division of labor, which is divided into development operation and maintenance, application operation and maintenance (business operation and maintenance) and system operation and maintenance.

Development, operation and maintenance: it is for the application operation and maintenance development tools and operation and maintenance platform.

Application operation and maintenance: it is to launch, maintain and troubleshoot the business, and use the tools developed by the development and operation and maintenance to launch, maintain and troubleshoot the business.

System operation and maintenance: to provide business infrastructure for application operation and maintenance, such as system, network, monitoring, hardware, etc.

Summary: the development of operation and maintenance system provides "tools" and "infrastructure" support for application operation and maintenance.

The development of operation and maintenance, the application of operation and maintenance system, their work is interlinked.

2. In the work, the operation and maintenance personnel often need to deal with the operators. What do the operators do?

One of the things that game operators need to do is to coordinate their work.

We also need to communicate with various platforms and make plans for service launch time, number of services, user guidance, activities, etc.

3. Now I give you 300 servers, how do you manage them?

How to manage 300 servers:

1) set up the jumping machine and log in with a unified account to facilitate security and login considerations.

2) use salt, ansiable and puppet to manage the unified scheduling and configuration of the system.

3) establish simple cmdb information management of server system, configuration and application. It is easy to consult all kinds of information records on each server.

4. Briefly describe the working principle and characteristics of the three working modes of raid0 raid1 raid5.

RAID, you can integrate the hard disk into one large disk, and you can also partition and store data on the large disk.

There is also a big function, multiple disks can be put together to have redundancy (backup)

There are many ways of RAID integration, commonly used: 0 1 5 10

RAID 0, which can be a combination of one disk and N disks

It has the advantages of fast reading and writing, and is the best in RAID.

Disadvantages: without redundancy, if a piece of data is broken, it will be gone.

RAID 1, only 2 disks. The size of the disk can be different, whichever is smaller.

The 10G+10G has only 10G, and the other one is backed up. It has 100% redundancy and disadvantages: waste of resources and high cost.

RAID 5, 3 disks, capacity calculation 10 * (nMel 1), loss of one disk

Features, average reading and writing performance, better reading, poor writing

Redundancy from good to bad: RAID1 RAID10 RAID 5 RAID0

Performance from good to bad: RAID0 RAID10 RAID5 RAID1

Cost from low to high: RAID0 RAID5 RAID1 RAID10

Single server: very important not many disks, system disks, RAID1

Database server: master library: RAID10 slave library RAID5\ RAID0 (RAID10 for maintenance costs)

WEB server, if not too much data, RAID5,RAID0 (single disk)

There are multiple, monitoring, application servers, RAID0 RAID5

We will match the corresponding RAID level according to the requirements of data storage and access.

5. What's the difference between LVS, Nginx and HAproxy? How do you choose at work?

LVS: is based on layer 4 forwarding

HAproxy: based on layer 4 and layer 7 forwarding, it is a professional proxy server

Nginx: WEB server, cache server, and reverse proxy server, which can be forwarded at seven layers.

Difference: LVS can only do port forwarding because it is based on layer 4 forwarding.

However, this kind of forwarding LVS based on URL and directory cannot be done.

Job selection:

Since HAproxy and Nginx can do layer 7 forwarding, both URL and directory forwarding can be done.

When there is a large amount of concurrency, we have to choose LVS. For small and medium-sized companies, the amount of concurrency is not so large.

Choose HAproxy or Nginx, because HAproxy is a professional proxy server

HAproxy is recommended for small and medium-sized enterprises because of its simple configuration.

6. What's the difference between Squid, Varinsh and Nginx? how do you choose at work?

Squid, Varinsh, and Nginx are all proxy servers

What is a proxy server:

It can be used to access the public network for the user, and the accessed data can be cached locally on the server until the user accesses the same information next time.

When the source is used, the proxy server responds directly to the user locally. When it is not available locally, I will access the public network instead of you, and I will answer it.

To receive your request, I will first look for it in my own local cache. If I have a local cache, I will reply to you directly from my local cache.

If I don't find the cached data you want to access locally, then the proxy server will access the public network instead of you.

Difference:

1) Nginx is originally a reverse proxy / web server. You can do this sideline with plug-ins.

But it does not support many features, so it can only cache static files.

2) from these functions. Varnish and squid are professional cache services, while nginx these are done by third-party modules

3) the technical advantage of varnish itself is higher than that of squid, which adopts visual page caching technology.

In the use of memory, Varnish has an advantage over Squid, and its performance is higher than Squid.

There is also a powerful management port through Varnish, which can use regular expressions to quickly and bulk clear part of the cache.

It is an in-memory cache with first-class speed, but the in-memory cache also limits its capacity. Caching pages and pictures is generally good.

4) the advantage of squid lies in the complete and huge technical data of cache and many application production environments.

Choose at work:

If we want to do cache services, we must choose professional cache services and give priority to squid or varnish.

7. What's the difference between Tomcat and Resin? how do you choose at work?

Difference: more Tomcat users, more reference documents, less Resin users, fewer documents to consider

The main difference is that Tomcat is a standard java container, but its performance is worse than that of resin.

But the stability and compatibility of java programs should be better than those of resin.

Choice in work: now large companies use resin to pursue performance, while small and medium-sized companies use Tomcat to pursue stability and program compatibility

8. What is middleware? What is jdk?

Introduction to middleware:

Middleware is an independent system software or service program, which is used by distributed application software to share resources among different technologies.

Middleware is located on top of the client / server operating system to manage computer resources and network communications.

Is software that connects two independent applications or independent systems. Connected systems, even if they have different interfaces

However, information can still be exchanged with each other through middleware. One of the key ways to implement middleware is information transmission.

Through middleware, applications can work in multi-platform or OS environments.

Jdk:jdk is the development kit for Java

It is a development environment for building applications, applet, and components released on the Java platform

9. Describe the meaning of the three ports Tomcat8005, 8009 and 8080?

8005 hours = "use when closed

8009 ports = "AJP port, that is, used by containers. For example, Apache can access port 8009 of Tomcat through AJP protocol.

8080 percent = "used by general applications

10. What is CDN?

-content distribution network

-the aim is to publish the content of the site to the existing Internet by adding a new network architecture to the

Closest to the edge of the user's network, so that users can get the content they need nearby, and improve the speed of users' access to the site.

11. What is the grayscale release of the website?

Grayscale publishing is a way of publishing that can make a smooth transition between black and white.

AB test is a grayscale publishing method that allows one user to continue to use An and some users to start using B.

If users have no objection to B, then gradually expand the scope and migrate all users to B

The grayscale release can ensure the stability of the whole system, and the problem can be found and adjusted at the initial gray level to ensure its influence.

12. Briefly describe the process of domain name resolution by DNS?

If users want to access www.baidu.com, they will first find the local host file, and then find the local DNS server. If they do not have it, they will go to the root server in the network. The root server will feedback the result, saying that they can only provide first-level domain name server.cn, then go to the first-level domain name server.com.cn, and go to the second-level domain name server. The second-level domain server can only provide the third-level domain name server .baidu.com.cn, so go to the third-level domain name server, which happens to have this website www.baidu.com, and then send it to the requesting server, save a copy, and then send it to the client.

13. What is RabbitMQ?

RabbitMQ is also known as message queuing middleware, which is a container that stores messages during message transmission.

Message middleware acts as a middleman when it takes messages from its source to its target when it wins the bid.

The main purpose of queues is to provide routing and ensure the delivery of messages; if the recipient is not available when sending messages

Message queuing does not retain messages until it can be successfully delivered, and of course, message queuing saves messages for a limited period of time.

14. How does Keepalived work?

In a virtual router, only the VRRP router as MASTER will always send VRRP advertisement messages

BACKUP does not preempt MASTER unless it has a higher priority. When MASTER is not available (BACKUP does not receive notification information)

The one with the highest priority of multiple BACKUP will be preempted as MASTER. This preemption is very fast (in the environment, use the update command to directly update the data of the user table of the mysql library:

Update mysql.user set passwordpassword=password ('new password') where user='root'; flush privileges

Note: the mysql statement ends with a semicolon ";"

3. In the mysql > environment, use the grant command to modify the authorization permissions of the root user.

Grant all on *. * to root@'localhost' identified by 'new password'

Second, what should I do if I forget the password of the ROOT user in the mysql database? The methods are as follows:

1. Close the currently running mysqld service program: service mysqld stop (to add mysqld as a system service first)

two。 Use the mysqld_safe script to start the mysqld service in safe mode (without loading the authorization table)

/ usr/local/mysql/bin/mysqld_safe-skip-grant-table &

3. Log in to the database with a root user with an empty password and reset the password for the ROOT user

# mysql-u root Mysql > Update mysql.user set passwordpassword=password ('new password') where user='root'; Mysql > flush privileges

18. Advantages and disadvantages of lvs/nginx/haproxy

The advantages of Nginx are:

1. Working above the 7 layers of the network, you can make some diversion strategies for http applications, such as domain name and directory structure.

Its regular rules are more powerful and flexible than HAProxy, which is one of the main reasons why it is so popular at present.

With this alone, there are far more occasions available for Nginx than LVS.

2.Nginx has very little dependence on network stability. Theoretically, it can carry out load function as soon as it can ping, which is also one of its advantages.

On the contrary, LVS depends heavily on network stability, which I know very well.

3.Nginx is easy to install and configure, and easy to test. It can basically print errors in a log.

The configuration and testing of LVS will take a long time, and LVS is highly dependent on the network.

4. Can bear high load pressure and stable, in the case of the same hardware can generally support tens of thousands of concurrency, the load is relatively smaller than the LVS.

5.Nginx can detect internal faults in the server through the port, such as the status code returned by the server processing web pages, timeout, and so on, and will resubmit the request that returns an error to another node, but the disadvantage is that it does not support url detection. For example, if a user is uploading a file, and the node handling the upload just fails during the upload process, Nginx will cut the upload to another server for re-processing, and the LVS will be cut off directly.

If you are uploading a large file or a very important file, users may be dissatisfied with it.

6.Nginx is not only an excellent load balancer / reverse proxy software, but also a powerful Web application server.

LNMP is also a very popular web architecture in recent years, and it is stable in a high-traffic environment.

7.Nginx is becoming more and more mature as a Web reverse acceleration cache, which is faster than traditional Squid servers, so we can consider using it as a reverse proxy accelerator.

8.Nginx can be used as a middle-level reverse proxy. At this level, Nginx is basically unmatched, and the only thing that can compare Nginx is lighttpd.

However, at present, lighttpd does not achieve the full function of Nginx, the configuration is not so clear and easy to read, and community materials are far less active than Nginx.

9.Nginx can also be used as a static web page and image server, and there is no match for this performance. And the Nginx community is very active, and there are many third-party modules.

The disadvantages of Nginx are:

1.Nginx only supports http, https and Email protocols, so it is less applicable, which is its disadvantage.

two。 Health check for backend servers only supports port detection, but not url detection.

Direct retention of Session is not supported, but it can be solved through ip_hash

LVS: using Linux kernel cluster to implement a high-performance, high-availability load balancing server

It has good scalability (Scalability), reliability (Reliability) and manageability (Manageability)

The advantages of LVS are:

1. Strong anti-load ability, working above layer 4 of the network for distribution only, no traffic generation

This feature also determines that it has the strongest performance in load balancing software and consumes relatively low memory and cpu resources.

two。 The configuration is relatively low, which is both a disadvantage and an advantage, because there is nothing to configure too much.

So it doesn't need too much contact, which greatly reduces the probability of human error.

3. The work is stable, because it has strong anti-load ability, and it has a complete dual-computer hot backup scheme.

Such as LVS+Keepalived, but what we use most in project implementation is LVS/DR+Keepalived.

4. There is no traffic, LVS only distributes requests, and traffic does not go out from itself, which ensures that the performance of equalizer IO will not be affected by large traffic.

5. LVS has a wide range of applications, because it works on layer 4, so it can load balance almost all applications, including http, database, online chat rooms, etc.

The disadvantages of LVS are:

1. The software itself does not support regular expression processing and cannot do dynamic and static separation.

Now many websites have a strong demand in this respect, which is the advantage of Nginx/HAProxy+Keepalived.

two。 If the website application is relatively large, the implementation of LVS/DR+Keepalived is more complicated.

In particular, if there is a Windows Server machine behind it, the implementation, configuration and maintenance process will be more complicated.

Relatively speaking, Nginx/HAProxy+Keepalived is much simpler.

The characteristics of HAProxy are:

1.HAProxy also supports virtual hosting.

The advantages of 2.HAProxy can supplement some disadvantages of Nginx, such as supporting the maintenance of Session and booting of Cookie.

At the same time, you can detect the status of the backend server by getting the specified url

3.HAProxy, like LVS, is just a load balancing software.

In terms of efficiency, HAProxy has a better load balancing speed than Nginx, and it is also better than Nginx in concurrent processing.

4.HAProxy supports load balancing forwarding of TCP protocol, and can load balance MySQL reads.

Check and load balance the backend MySQL nodes. You can use LVS+Keepalived to load balance the MySQL master and slave.

There are many load balancing strategies for 5.HAProxy. There are 8 load balancing algorithms for HAProxy:

① roundrobin, which means simple polling. Not to mention this, this is basically what load balancers have.

② static-rr, indicating that according to the weight, it is recommended to pay attention to

③ leastconn, which means that those with least connections should be dealt with first. It is recommended to pay attention to

④ source, which indicates that according to the request source IP, this is similar to Nginx's IP_hash mechanism

We use it as a way to solve the session problem and suggest that we pay attention to it.

⑤ ri, which represents the URI based on the request

⑥ rl_param, which indicates that according to the requested URl parameter 'balance url_param' requires an URL parameter name

⑦ hdr (name), which means that each HTTP request is locked according to the HTTP request header

⑧ rdp-cookie (name), which means that each TCP request is locked and hashed according to cookie (name).

19. Mysql data backup tool

Mysqldump tool

Mysqldump is a backup tool that comes with mysql. The directory is under the bin directory: / usr/local/mysql/bin/mysqldump

Hot backup based on innodb is supported, but because it is a logical backup, the speed is not very fast, so it is suitable for scenarios where backup data is relatively small.

Mysqldump full backup + binary log enables point-in-time recovery.

Backup based on LVM snapshot

In a physical backup, there is a physical backup based on the file system (a snapshot of LVM), or you can directly use commands such as tar to the entire database directory

Package backup, but these can only be backed up by cold backup. Different storage engines back up different backups. Myisam automatically backs up to the table level.

On the other hand, if innodb does not open independent tablespaces, it can only back up the entire database.

Tar package backup

Xtrabackup tools provided by percona

Support innodb physical hot backup, support full backup, incremental backup, and very fast, support data caused by innodb storage in different

Migration between databases, supporting slave backup recovery in replication mode, in order to enable xtrabackup to support more functional extensions

Independent tablespaces can be set up and innodb_file_per_table function can be turned on. When enabled, individual table backups can be supported.

20. The working principle of keepalive and how to do health examination

Keepalived is based on VRRP protocol, and VRRP is called Virtual Router Redundancy Protocol, that is, virtual routing redundancy protocol.

Virtual routing redundancy protocol can be considered as a protocol to achieve high availability of routers, that is, N routers that provide the same function form a router group.

In this group, there is a master and multiple backup,master with a vip that provides services (the router is located in the local area network).

The default route for other machines is this vip), and master will send multicast. When backup fails to receive vrrp packets, it is considered that master is down.

At this point, you need to choose a backup as master according to the priority of VRRP. This ensures the high availability of the router.

Keepalived has three main modules, namely, core, check and vrrp. Core module is the core of keepalived, which is responsible for the startup and maintenance of the main process.

And the loading and parsing of global configuration files. Check is responsible for health check, including various common check methods. The vrrp module is used to implement the VRRP protocol.

Keepalived Health check configuration HTTP_GET | SSL_GET HTTP_GET | SSL_GET {url {the url checked by path / # HTTP/SSL can be the summary information after multiple digest # HTTP/SSL checks. Use the tool genhash to generate the status code returned by status_code 20 check HTTP/SSL check} connect_port 80 # connection port bindto connect_timeout 3 # connection timeout nb_get_retry 3 # repeat Count delay_before_retry 2 # connection interval}

21. Statistics of ip access. It is required to analyze the nginx access log and find out the ip with the top ten visited pages

Cat access.log | awk'{print $1}'| uniq-c | sort-rn | head-10

22. Use tcpdump to listen on the data whose port is 192.168.1.1, and save the output to tcpdump.log.

Tcpdump 'host 192.168.1.1 and port 80' > tcpdump.log

23. How to forward the request from local port 80 to port 8080. The current host IP is 192.168.2.1

Iptables-A PREROUTING-d 192.168.2.1-p tcp-m tcp-dport 80-j DNAT-to-destination 192.168.2.1 tcp 8080

24. Briefly describe the working principle and characteristics of the three working modes of raid0 raid1 raid5.

RAID 0: striped volume that continuously splits data in bits or bytes and reads / writes in parallel on multiple disks, so it has a high data transfer rate.

But it has no data redundancy. RAID 0 only improves the performance and does not guarantee the reliability of the data.

And the failure of one of the disks will affect all data. Therefore, RAID 0 cannot be used in situations with high data security requirements.

RAID 1: mirrored volumes, which achieve data redundancy through disk data mirroring, producing data backed up by each other on pairs of independent disks

Can not improve the efficiency of writing data. When the original data is busy, the data can be read directly from the mirror copy, so RAID1 can improve read performance.

RAID 1 has the highest unit cost in the disk array. The available capacity of the mirrored volume is 1x2 of the total capacity, but provides high data security and availability.

When a disk fails, the system can automatically switch to the mirrored disk to read and write without the need to reorganize the failed data.

RAID5: a separate disk structure consisting of at least three hard disks with distributed parity, whose parity codes exist on all disks.

If any hard disk is damaged, the damaged data can be reconstructed according to the check bits on other hard drives (a maximum of 1 hard disk damage is allowed).

Therefore, raid5 can achieve data redundancy and ensure the security of data, while raid5 can also improve the read and write performance of data.

25. Your understanding of the current operation and maintenance engineers and their work

Operation and maintenance engineers have a great responsibility in the company, and they need to ensure that they provide the highest, fastest, most stable and safest service for the company and its customers at all times.

A small mistake made by the operation and maintenance engineer is likely to cause heavy losses to the company and customers.

Therefore, the work of operation and maintenance engineers needs to be rigorous and innovative.

26. Capture and display the network data information of tcp port 80 in the current system in real time. Please write out the complete operation command.

Tcpdump-nn tcp port 80

27. How to solve the problem of troubleshooting step by step if the server cannot be turned on?

A. the reasons for server failure may be as follows:

B. the steps for troubleshooting the server are as follows:

28. How to solve the virus in Linux system

1) the simplest and most effective way is to reinstall the system

2) if you want to check, find the virus file and delete it.

After poisoning, the general machine cpu, memory utilization rate will be relatively high.

For abnormal situations such as sending packets out of the machine, the troubleshooting method is briefly introduced.

The top command finds the process with the highest cpu utilization

Generally, the names of virus files are messy. You can use ps aux to find the location of virus files.

Rm-f command to delete virus file

Check the scheduled tasks, boot items and virus file directory for other available files, etc.

3) since even deleting virus files does not rule out latent viruses, it is best to reinstall the machine after backing up the data.

29. How to solve the problem if you delete a virus file and create it automatically

There is an inexplicable surge in the traffic of a linux server in the company's internal network. Use iftop to check if there is a connection to the external network.

In view of this situation, we generally focus on the public network ip and port of the netstat connection.

With lsof-p pid, you can see which processes and which files

After investigation, it is found that there are two suspicious files related to the configuration conf.n hhe under / root, which are automatically generated less than a minute after rm-rf.

It is inferred that these files are generated by a parent process. So finding the mother process is to find the culprit.

It is best to cut off the access to the external network to check and kill the virus. Fortunately, it is the server of the internal network, which can be accessed through the internal network.

When the intranet is cut off, the virus loses its ability to reach out, and it is much easier to kill it.

How to find it? after looking for it for a long time, I didn't see any clues. There was no way but ps axu to investigate one by one.

The method is to check the users who can and the counterfeiters who are similar to the system but not impostors. Sure enough, we see the following suspicious process.

If you can't see the picture, it's / usr/bin/.sshd.

So I killed all the processes related to .sshd and deleted the executable .sshd directly.

Then the automatic resurrection files mentioned at the beginning of the article were deleted.

To sum up, if this kind of problem is not too serious, try not to reinstall the system.

Generally speaking, it is to cut off the external network first, and then use these tools such as iftop,ps,netstat,chattr,lsof,pstree to find out the melons.

You can usually find the culprit. But if you encounter problems like this,

/ boot/efi/EFI/redhat/grub.efi: Heuristics.Broken.Executable FOUND, I think it's time to reinstall the system.

30. Talk about the seven-tier model of TCP/IP

Application layer (Application):

An interface between a network service and an end user.

The protocols are: HTTP FTP TFTP SMTP SNMP DNS TELNET HTTPS POP3 DHCP

Presentation layer (Presentation Layer):

Data representation, security, compression. (it has been merged into the application layer in the five-tier model)

Formats include JPEG, ASCll, DECOIC, encryption format, etc.

Session layer (Session Layer):

Establish, manage, and terminate sessions. (it has been merged into the application layer in the five-tier model)

The corresponding host process, which refers to the ongoing session between the local host and the remote host

Transport layer (Transport):

Define the protocol port number over which data is transmitted, as well as flow control and error checking.

The protocols are: TCP UDP, once the packet leaves the network card, it enters the network transport layer.

Network layer (Network):

Logical address addressing is carried out to realize the path selection between different networks.

The protocols are: ICMP IGMP IP (IPV4 IPV6) ARP RARP

Data Link layer (Link):

Establish logical connection, hardware address addressing, error checking and other functions. (protocol defined by the underlying network)

Combining bits into bytes and then into frames, accessing the media with MAC addresses, errors are found but cannot be corrected

Physical layer (Physical Layer):

It is the lowest layer in the computer network OSI model.

The physical layer stipulates that the physical links needed to transmit data are created, maintained, and dismantled.

It provides mechanical, electronic, functional and normative properties.

Simply put, the physical layer ensures that the original data can be transmitted over a variety of physical media. Both local area network and wide area network belong to layers 1 and 2.

The physical layer is the first layer of OSI. Although it is at the bottom, it is the foundation of the whole open system.

The physical layer provides transmission media and interconnection devices for data communication between devices, and provides a reliable environment for data transmission.

If you want to remember this first layer with as few words as possible, it is "signals and media".

31. What is your commonly used Nginx module for?

Rewrite module to implement the rewrite function

Access module: source control

Ssl module: secure encryption

Ngx_http_gzip_module: network transmission compression module

Ngx_http_proxy_module module implements proxy

Ngx_http_upstream_module module implementation defines the list of backend servers

Ngx_cache_purge implements cache clearing function

32. Please list the web server load architecture you know

Nginx Haproxy Keepalived LVS

33. Check the number of concurrent requests of http and its TCP connection status

Netstat-n | awk'/ ^ tcp/ {+ + S [$NF]} END {for (an in S) print a, S [a]}'

There is also ulimit-n to view the largest file descriptor opened by the linux system, which defaults to 1024.

It is useless not to modify the web server here. If you want to use it, there are several ways to modify it. Here is one of them:

Modify / etc/security/limits.conf * soft nofile 10240 * hard nofile 10240

Take effect after restart

34. Use tcpdump to sniff the access to port 80 to see who is the highest.

Tcpdump-I eth0-tnn dst port 80-c 1000 | awk-F "."'{print $1 "." $2 "." $3 "." $4}'| sort | uniq-c | sort-nr | head-20

35. Write a script to judge which IP is currently online in the 192.168.1.0 Universe 24 network, which can be considered as online by the general rule of ping

#! / 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

36. It is known that the access log of the apache service is recorded daily in the server's local directory / app/logs. Due to the shortage of disk space, it is required that you can only keep the access log for the last 7 days! May I ask how to solve it? Please give a solution or configuration or processing command

Create a file script:

#! / bin/bash for n in `date 14` do date-s "11 log done 0$ n touch access_www_ 14" touch access_www_ `(date +% F)`.

Solution:

# pwd/application/logs # ll-rw-r--r--. 1 root root 0 Jan 1 00:00 access_www_2015-01-01.log-rw-r--r--. 1 root root 0 Jan 2 00:00 access_www_2015-01-02.log-rw-r--r--. 1 root root 0 Jan 3 00:00 access_www_2015-01-03.log-rw-r--r--. 1 root root 0 Jan 4 00:00 access_www_2015-01-04.log-rw-r--r--. 1 root root 0 Jan 5 00:00 access_www_2015-01-05.log-rw-r--r--. 1 root root 0 Jan 6 00:00 access_www_2015-01-06.log-rw-r--r--. 1 root root 0 Jan 7 00:00 access_www_2015-01-07.log-rw-r--r--. 1 root root 0 Jan 8 00:00 access_www_2015-01-08.log-rw-r--r--. 1 root root 0 Jan 9 00:00 access_www_2015-01-09.log-rw-r--r--. 1 root root 0 Jan 10 00:00 access_www_2015-01-10.log-rw-r--r--. 1 root root 0 Jan 11 00:00 access_www_2015-01-11.log-rw-r--r--. 1 root root 0 Jan 12 00:00 access_www_2015-01-12.log-rw-r--r--. 1 root root 0 Jan 13 00:00 access_www_2015-01-13.log-rw-r--r--. 1 root root 0 Jan 14 00:00 access_www_2015-01-14.log # find / application/logs/-type f-mtime + 7-name "* .log" | xargs rm-f # # can also use-exec rm-f {}\; delete # ll-rw-r--r--. 1 root root 0 Jan 7 00:00 access_www_2015-01-07.log-rw-r--r--. 1 root root 0 Jan 8 00:00 access_www_2015-01-08.log-rw-r--r--. 1 root root 0 Jan 9 00:00 access_www_2015-01-09.log-rw-r--r--. 1 root root 0 Jan 10 00:00 access_www_2015-01-10.log-rw-r--r--. 1 root root 0 Jan 11 00:00 access_www_2015-01-11.log-rw-r--r--. 1 root root 0 Jan 12 00:00 access_www_2015-01-12.log-rw-r--r--. 1 root root 0 Jan 13 00:00 access_www_2015-01-13.log-rw-r--r--. 1 root root 0 Jan 14 00:00 access_www_2015-01-14.log

37. How to optimize the Linux system (not too specific)?

Hongmeng official Strategic Cooperation to build HarmonyOS Technology Community

Do not use root, add ordinary users, and manage through sudo authorization

Change the default remote connection SSH service port and prohibit root users from connecting remotely

Update server time automatically on a regular basis

Configure domestic yum feeds

Close selinux and iptables (if there is a public network IP in iptables work scene, be sure to open it, except for high concurrency)

Adjust the number of file descriptors

Simplified Boot Boot Service (crond rsyslog network sshd)

Kernel parameter optimization (/ etc/sysctl.conf)

Change the character set to support Chinese, but it is recommended to use the English character set to prevent garbled code.

Lock critical system files

Clear / etc/issue and remove the screen display before login of the system and kernel version

38. Please execute the command to get the IP address of the eth0 in the linux (please use cut, and those who have the ability can also use the awk,sed command to answer)

Cut method 1: # ifconfig eth0 | sed-n '2p' | cut-d ":"-f2 | cut-d ""-F1 192.168.20.130 awk method 2: # ifconfig eth0 | awk' NR==2' | awk-F ":"'{print $2}'| awk'{print $1} '192.168.20.130 awk multiple separator method 3: # ifconfig eth0 | awk' NR==2' | awk-F "[:] +" {print $4} '192.168.20.130 sed Method 4: # ifconfig eth0 | sed-n'/ inet addr/p' | sed-r's # ^. * ddr: (. *) Bc.*$#\ 1Secretg' 192.168.20.130

39. Please write down the function of the following linux SecureCRT command line shortcut key command?

Ctrl+ a Ctrl+ c Ctrl+ d Ctrl+ e Ctrl+ l Ctrl+ u Ctrl+ k tab Ctrl+shift+c Ctrl+shift+v

Answer:

Ctrl + a-- > cursor moves to the beginning of the line

Ctrl + e-- > cursor moves to the end of the line

Ctrl + c-- > terminate the current program

Ctrl + d-- > if there is a character before the cursor, delete it. If not, exit the current interrupt.

Ctrl + l-- > clear the screen

Ctrl + u-- > cut the characters before the cursor

Ctrl + k-> cut the characters after the cursor

Ctrl + y-- > copy the contents of ubank k

Ctrl + r-- > find recently used commands

Tab-- > command or path completion

Ctrl+shift+c-- > copy

Ctrl+shift+v-- > paste

40. At 12:00 every evening, pack the site directory / var/www/html and backup it to the / data directory (it is best to generate different backup packages for each backup)

# cat a.sh # / bin/bash cd / var/www/ & & / bin/tar zcf / data/html- `date +% mmurd% d% H`.tar.gz html/ # crontab-e 00 * / bin/sh / root/a.sh what are the interview questions for Linux operation and maintenance? thank you for 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report