Linux Common Command Collection

Source: Internet
Author: User
Tags phpmyadmin virtualenv

This is the usual command to summarize here:

first, the Python class
1. PIP (installed)
pip is used to install all the Python dependencies from PyPI (https://www.python.org/) and can optionally install any previous versions of the dependencies that have been uploaded on PyPI. Personally considered Python-related packages and third-party packages as well as various versions
2. Setuptools (installed)
Easy_install

Top: How to install PIP:
Install Pip and virtualenv for Ubuntu 10.10 Maverick and newer

$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install--upgrade pip
$ sudo pip install--upgrade virtualenv
For older versions of Ubuntu

Install Easy Install
$ sudo apt-get install python-setuptools python-dev build-essential
Install Pip
$ sudo easy_install pip
Install virtualenv
$ sudo pip install--upgrade virtualenv


Second, SSH
1. No Password:
SSH-KEYGEN-T RSA
CD ~/.ssh
CP Id_rsa.pub Authorized_keys
Cd
SSH A (establish its own link)
Set B
Copy a. ssh file on a local overlay

Sometimes need ssh [email protected] First link (change/etc/hosts ip1 host name a ip2 hostname 2 ssh hostname a)
2.scp
Third, MySQL
Find/|grep MY.CNF
Find/-name my.conf
Whereis
which
Configuration file
1. Terminal start Mysql:/etc/init.d/mysql start; (Stop, restart. )
2. Login to Mysql:mysql-u root-p (login with root account), then enter the password, mysql-h 192.168.119.213-u root-p login to other machines

3. View all database names: show databases;
4. Select a database operation: use database_name;
5. View all the table names under the current database: show tables;
6. Creation of a database: Create databases database_name;
7. Delete a database: Drop DB database_name;
8. Create a table: The CREATE TABLE mytest (UID bigint () NOT NULL, uname varchar (a) not null);
9. Delete a table: Drop table mytest;
10.SQL INSERT statement: INSERT INTO table_name (COL1,COL2) values (value1,value2);
11.SQL updated Statement: UPDATE table_name set col1= ' value1 ', col2= ' value2 ' where where_definition;
12.SQL Query statement: SELECT * FROM table_name where .... (the most complex statement)
13.SQL DELETE statement: DELETE from table_name where ...
14. Add a table structure field: Alert table table_name Add column field1 date, add column Field2 time ...
15. Delete the table structure field: Alert table table_name drop field1;
16. View the structure of the table: Show columns from table_name;
17.limit Use: SELECT * FROM table_name limit 3;//only 3 rows per page
SELECT * FROM table_name limit 3,4//from the third start of the query results, four results are displayed.
This is a good place to use for paging.
18. Sort the results of the query: SELECT * FROM table_name ORDER by Field1,orderby Field2; multiple sorting
19. Exit Mysql:exit;
20 Import and Export mysqldump


Remote link for a given IP address
MySQL > GRANT all privileges on * * to ' root ' @ ' 192.168.130.124 ' identified by ' sudst2011 ' with GRANT OPTION;
MySQL > Flush privileges;

Four Apache

Configuration file/etc/apache2
Log file/var/log/apache2
Start/etc/init.d/apache2 Restart

Wu, phpMyAdmin

local phpMyAdmin Remote connection server-side MySQL first make sure that your MySQL remote connection is turned on, if it is not turned on follow these two methods:
method One: Change the table Method
because in the Linux environment, the default is to turn off the 3306 port remote connection, need to turn on, if you install the MySQL database when you open 3306 OK.
The default MySQL account does not allow remote login and only localhost access is allowed. After logging in to MySQL, change the "host" entry in the "User" (Remote database name) table in the "MySQL" Database and rename "localhost" to "%". This will allow your MySQL to operate remotely.
Update user Set host = '% ' where user = ' root ';
Note: This method only changes the native localhost access to the "%" all address IP can access the MySQL server, which is not secure. The default localhost access has all the operation permissions. So it's not safe! A second method is recommended.
method Two: Authorization method (recommended use)
(1) SQL statement:
Grant Select,insert,update,delete on * * to [e-mail protected] "%" identified by "password";
allow the address IP root user, password dboomysql to connect all MySQL database, only pay Select,insert,update,delete permissions. This is more secure. If only the root user on IP (192.168.1.1) is allowed
access more secure, action (2)
(2) sq statement:
Grant Select,insert,update,delete on * * to [e-mail protected] "192.168.1.1" identified by "password";
only allow root user access on address IP (192.168.1.1) is more secure.
(3)
Grant All on * * to [e-mail protected] "192.168.1.1" identified by "password"
allow the address 192.168.1.1 with root user, password password to connect all MySQL database, pay all permissions. Not very safe.
now restart the MySQL service, if you have a firewall installed on the server, see 3306 port Open No, if you do not need to open 3306 port to use, under Linux to open the firewall opened 3306 port, edit this file vi/etc/sysconfig/ Iptables
input
-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 3306-j ACCEPT
after saving the console input/etc/init.d/iptables Restart Restart the firewall, remember to restart the firewall.

Configure the local PHP environment and download phpMyAdmin.
method One:
(a), download phpMyAdmin
http://www.phpmyadmin.net/home_page/index.php
(b), modify the config.default.php file under the Libraries folder or the config.inc.php file of the phpMyAdmin root directory.
1. Find $cfg[' Pmaabsoluteuri '] and set its value to your local phpMyAdmin path
2. Find $cfg[' Servers ' [$i] [' Host '] and set its value to your MySQL database address, e.g. 127.0.0.1
3. Find $cfg[' Servers ' [$i] [' User '] and set its value to your MySQL database user name, e.g. admin
4, find $cfg[' Servers ' [$i] [' Password '], set its value to your MySQL database password, such as admin
(iii), local access to the PhpMyAdmin can view the remote MySQL database, phpMyAdmin 3.3.1 You only need to modify the value of the $cfg [' Servers '] [$i] [' host '], which is entered when the user name password is accessed phpMyAdmin.
Method Two:
1, enter in the browser: http://localhost/phpmyadmin/setup/
2. Click "New Server" to fill out the form:
Server Name: Host name
Server Host name: Host IP
authentication method: Config
user name of config authentication mode: User name
Config authentication method password: User password
3, after saving back to the Setup interface, click Download, download the file for config.inc.php
4. Copy the downloaded file config.inc.php to the/usr/share/phpmyadmin/directory

5, edit/usr/share/phpmyadmin/config.inc.php
Add the following code
/ * Server:localhost [1] * /
$i + +;
$cfg [' Servers '] [$i] [' verbose '] = ' host name ';
$cfg [' Servers '] [$i] [' host '] = ' hosts IP ';
$cfg [' Servers '] [$i] [' port '] = ';
$cfg [' Servers '] [$i] [' socket '] = ';
$cfg [' Servers '] [$i] [' connect_type '] = ' TCP ';
$cfg [' Servers '] [$i] [' extension '] = ' mysqli ';
$cfg [' Servers '] [$i] [' auth_type '] = ' config ';
$cfg [' Servers '] [$i] [' user '] = ' username ';
$cfg [' Servers '] [$i] [' password '] = ' password ';


Liu, Iptables

IPTABLES-L-N Check Port condition
In order to be able to use remote SSH login, we have to turn on port 22. The default rule for the input chain is drop. So we're going to write a chain that needs accetp.
Iptables-a input-p TCP--dport 22-j ACCEPT
Iptables-a output-p TCP--sport 22-j ACCEPT

Iptables-i input-p TCP--dport 3306-j ACCEPT open Port 3306

Iptables-i input-p TCP--dport 3306-j drop off

Seven VNC
1. Each time the server shuts down, re-kill and reapply for the VNC port number. Otherwise, "Authentication failure" appears.

#vncpassword Change Password
#vncserver-geometry 1280x1024 (cannot be *, use lowercase x (Letters)) to set the VNC server resolution
#vncserver-alwaysshared the same display window that sets up VNC can connect multiple clients, usually by default, the client that connects to the last send connection request
VNCSERVER-KILL:15 violence Stop VNC Server (be sure to remember to add a space before the colon, or kill fails.) Open multiple ports without, waste of resources, usually one)

Eight, server cache processing
1.
See how many files and folders are in the directory to be entered in the terminal
ls | wc-w
See how many files are in the directory to be entered in the terminal
ls | wc-c
See how many files are in the folder, how many subdirectories you need to enter in the terminal
ls-l |wc-l
If you only want to know the number of files, you need to enter
/bin/ls-l |grep ^-|wc-l
2.
du-h--max-depth=1 View folder capacity
df-h viewing file system capacity
3.
Uname-a View the number of system bits i686 32 or 64-bit
4. Find-mtime +1-type f-name ' cache* ' | xargs rm-rf
Search for the first 24 hours of files into the pipeline and delete


Ix. using shell to analyze Apache's Access.log

#查看80端口的tcp连接

#netstat-tan | grep "established" | grep ": 80" | Wc-l

1

#当前WEB服务器中联接次数最多的ip地址:

#netstat-ntu |awk ' {print $} ' |sort | uniq-c| Sort-n-R

#查看日志中访问次数最多的前10个IP

#cat access.log |cut-d "-F 1 |sort |uniq-c | Sort-nr | awk ' {print $} ' | Head-n |less

#查看日志中出现100次以上的IP

#cat access.log |cut-d "-F 1 |sort |uniq-c | awk ' {if (>) print $ |sort-nr} ' |less

#查看最近访问量最高的文件

#cat access.log |tail-10000|awk ' {print $7} ' |sort|uniq-c|sort-nr|less

#从日志里查看该ip在干嘛:

#cat Access.log | grep 218.66.36.119| awk ' {print $ '/t ' $7} ' | Sort | uniq-c | Sort-nr | Less

#列出传输时间超过 30-second file

#cat Access.log|awk ' ($NF >) {print $7} ' |sort-n|uniq-c|sort-nr|head-20

#列出最最耗时的页面 (more than 60 seconds) and the number of corresponding page occurrences

#cat access.log |awk ' ($NF > && $7~//.php/) {print $7} ' |sort-n|uniq-c|sort-nr|head-100

IX, VI
Find/keyword n continue find n Find online
X. Other

1, (garbled) configured and disabled 8 fonts
Zip decompression: Prevent garbled unzip-o CP936 file name. zip GBK GB18030 ********
Ubuntu is not supported by default GBK so the GBK code to write something will garbled let Ubuntu support GBK, the method is as follows:
Modify the/var/lib/locales/supported.d/local file to add ZH_CN to the file. GBK GBK ZH_CN. GB2312 GB2312 sudo dpkg-reconfigure--force locales then appears zh_cn in the output results. GB2312 done ZH_CN. GBK done so, Ubuntu supports GBK encoding this is just the system supported by some programs or not support need you to configure it yourself

2, CP without parameters, can only copy a file, can not copy the directory with the file, to the designated place.

CP-RF with parameters, you can copy any data to the specified place.

For example: CP test.txt/home/mir1566-pc/document Copy the test text file to the specified directory.

For example: CP-RF test/home/mir1566-pc/document Copy the test directory to the specified directory.

3, [* * * * * @localhost ~]$ Su-username
Password: #输入用户username的密码

4, you can use the command "getconf long_bit" view,
If the returned result is 32, the description is 32 bits, and the result returned is 64, the description is 64 bits.

You can also use the command "uname-a" to view
The result of the output, if there is a x86_64 is 64 bits, not 32 bits.

Subsequent backlog

Linux Common Command Collection

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.