Linux operation and maintenance plane question

Source: Internet
Author: User


Summarize the interview questions encountered: If there are errors, please point out, thank you!


1, using iptbales How to forward the local 80 port request to 8080 port, the current host IP is 192.168.2.1 1), Dnat implementation: IPTABLES-T nat-a prerouting-d 192.168.2.1-p TCP- M TCP--dport 80-j DNAT--to-destination 192.168.2.1:8080 2), Snat implementation: Iptables-t nat-a postrouting-d 192.16 8.2.1-p tcp-m TCP--dport 8080-j SNAT--to-source 192.168.2.1:80


2, use iptables only open port to 192.168.200.1

Iptables-i input-s 192.168.200.1/24-p TCP--dport 22-j ACCEPT

3 . How to solve the Mysql forgotten password?

1, install the mysql5.5.38 version in centos6.5 , forget how to solve the password?

(1), first close the MYSQLD service

Service Mysqld Stop

(2), using Mysqld_safe Safe mode to start MySQL, using two parameters:

--skip-grant-tables: Skip Authorization Form

--skip-networking: Skip the network, prevent other users to read and write to the database, after the password recovery can open normally

Execute command:

Mysqld_safe--skip-grant-tables--skip-networking &

(3), no password login:

Mysql-u Root

(4), change the password:

mysql> use MySQL; # # #使用 mysql database

mysql> Update user Set Password=password (' New password ') where user= ' root '

mysql> flush Privileges;

Mysql> quit//Exit database

(5), restart the MySQL service

Service mysqld Restart

(6). Log in to MySQL with a new password

Mysql-uroot-p New Password

2, installed in the Centos7 mysql5.7.13 version of Forget Root password, how to solve?

(1), modify the main configuration file my.cnf

Vim/etc/my.cnf

# # #在 [Mysqld] added in

Skip-grant-tables

Save, exit

(2), restart MySQL service

Systemctl MySQL Restart

(3), use the root user login (password is empty, direct enter enter)

Mysql-u root-p

(4), execute the command in MySQL:

mysql> use MySQL;

mysql> Update user Set Authentication_string=password (' New password ') where user= ' root ';

Note: In the mysql5.7 version, the password field does not exist , using the authentication_string field

mysql> flush Privileges;

Mysql> quit//Exit database

(5), add the original my.cnf configuration file Skip-grant-tables parameters, delete, restart service

Sed-i ' s/skip-grant-tables//g/etc/my.cnf '

Systemctl Restart Mysqld

(6), log in to the database test with the new password:

Mysql-u root-p New Password

4, execute ifconfig command only show IP address

os:centos6.5

ifconfig eth0 | grep " inet Addr " | awk ' {print $} ' | awk-f: ' {print $} '


650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/97/25/wKiom1kpXIrj1URjAARy0bPR7Wk280.png "style=" float : none; "title=" 0_ vocational scene question 1689.png "alt=" Wkiom1kpxirj1urjaary0bpr7wk280.png "/>


5. Brief description of python Ganso, dictionary, list of differences?

List:

Use [] defined, ordered object collection type, the elements in the list are mutable

Ganso

Use () definition, also an ordered combination, the elements of Yongzu are immutable

Dictionary:

Use {} definition, where the element is stored using key value, the key must be a unique value.

6. Use Python to write a 99 multiplication table?

For I in Range (1,10):

For j in Range (1,i+1):

Print ' %d*%d=%d ' % (j,i,i*j),

Print ' \ n '

The results are as follows:

650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M01/97/25/wKiom1kpXI-iP4ZJAArdheekQSA920.png "style=" float : none; "title=" 0_ vocational scene question 1943.png "alt=" Wkiom1kpxi-ip4zjaardheekqsa920.png "/>

7, Statistics of the apache access.log in the most visited 5 IP?

Cat Access.log | awk ' {print $} ' | sort | uniq-c | sort-r | head-5


This article is from the "Keep Keep your" blog, be sure to keep this source http://keep88.blog.51cto.com/11829099/1930361

Linux operation and maintenance plane question

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.