Python randomly generated a 6 bit verification code

source code:

# -*- coding: utf-8 -*-
import random
def generate_verification_code():
    ''' randomly generated a 6 bit verification code '''
    code_list = []
    for i in range(10): # 0-9 number
    for i in range(65, 91): # A-Z
    for i in range(97, 123): # a-z
    myslice = random.sample(code_list, 6)  
    verification_code ...

Continue reading

Linux systemctl is the replacement for service and chkconfig

1.Enable a service to start automatically

1) chkconfig --level 3 SERVICENAME on (old command)    
2) systemctl enable SERVICENAME.service (new command)

2.Disable a service to start automatically

1) chkconfig --level 3 SERVICENAME off (old command)    
2) systemctl disable SERVICENAME.service (new command)

3.View service status(old command and old command)

1) service ...

Continue reading

Linux configure Mysql to allow remote access

The operation is very simple, on the 5 step, as follows:

1.login mysql :

>mysql -uroot -p;

2.Using mysql database:

>use mysql;

3.View user table :

>SELECT Host,User FROM user;
| host         | user | password                                  |
| localhost    | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |
|  | root | *A731AEBFB621E354CD41BAF207D884A609E81F5E |

4.Update user table :

>UPDATE user SET Host = '%' WHERE User = 'root ...

Continue reading

Linux rpm related commands

RPM(RedHat Package Manager)

Binary package (Binary) as well as the source code package (Source) two. The binary package can be installed directly on the computer, and the source code package will be compiled and installed automatically by the RPM. Source code packages often use src.rpm as a suffix.

1.Common command combination:

-ivh ...

Continue reading

Linux mysql service mysql start fail can't run mysql

View error log:

160104 22:02:31  InnoDB: Waiting for the background threads to start
160104 22:02:32 InnoDB: 5.5.42 started; log sequence number 1595675
160104 22:02:32 [Note] Server hostname (bind-address): ''; port: 3306
160104 22:02:32 [Note]   - '' resolves to '0.0 ...

Continue reading

Linux SSH login without password

client1: Linux Host
server1: Linux Host
client server Generate key(Public key and Private key), copy the Public key to server1

1.client1 Generate key

[root@client1 ~]# ssh-keygen -b 1024 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root ...

Continue reading

Linux Process management command

Process management command

init: Process number is 1

Classification of processes:
     the processes associated with the terminal
     Terminal independent process

1.process state:

     D: Non interrupted sleep
     R: Run or ready
     S: Interrupted sleep
     T: Stop it
     Z:  Zombie state

     <:  High priority process
     N: Low priority process
     +: Processes in the foreground process group
     l ...

Continue reading

Linux software is not installed in the default directory

The software is not installed in the default directory of the solution

1.Modify the PATH environment variable to be able to identify the binary file path for this program:

   modified /etc/profile
  In the /etc/profile.d/ directory, create a file with names ending in .sh suffix, which write the  "export PATH=$PATH:/path ...

Continue reading

Linux File compression and Archive command

File compression and Archive command summary

compressed format: gz, bz2, xz, Z, zip Compression algorithm: the algorithm is different, the compression ratio will be different;


gzip: .gz 
  gzip /PATH/TO/SOMEFILE: gzip will delete the original file after the completion of the compression
  gzip -d: decompression
       -#: 1-9, specify the compression ratio, the default ...

Continue reading

Linux File Find command

File Find command


Non-real-time, fuzzy matching, lookup is performed according to the system-wide file database;
# updatedb, Manually generated file database (fast)

2. find: Find PathFinder standard look to a future process of operation

Real-time, accurate, supports many search criteria, traversing all the files in the specified directory lookup completed, slow;

Search Path: The ...

Continue reading

Yearly archives