升级Ubuntu的Linux Kernel

安装新内核

apt update
apt dist-upgrade
apt-cache search linux-image
apt-cache search linux-headers
apt install linux-image-4.15.0-15-generic linux-image-extra-4.15.0-15-generic linux-headers-4.15.0-15-generic
shutdown -r now

清理旧内核

dpkg --list|grep linux-image
dpkg --list|grep linux-headers
apt purge linux-image-4.14.13-041413-generic linux-headers-4.14.13-041413-generic

WordPress转换MySQL存储引擎InnoDB与MYISAM

ALTER TABLE wp_commentmeta ENGINE=INNODB;
ALTER TABLE wp_comments ENGINE=INNODB;
ALTER TABLE wp_links ENGINE=INNODB;
ALTER TABLE wp_options ENGINE=INNODB;
ALTER TABLE wp_postmeta ENGINE=INNODB;
ALTER TABLE wp_posts ENGINE=INNODB;
ALTER TABLE wp_term_relationships ENGINE=INNODB;
ALTER TABLE wp_term_taxonomy ENGINE=INNODB;
ALTER TABLE wp_terms ENGINE=INNODB;
ALTER TABLE wp_usermeta ENGINE=INNODB;
ALTER TABLE wp_users ENGINE=INNODB;
ALTER TABLE xd_termmeta ENGINE=INNODB;

mysql数据库升级:
mysql_upgrade -uroot -p

lnmp无法删除.user.ini

在使用linux进行开发的时候,我们经常会用到一个文件.user.ini,但是当我们进行删除的时候,会提示我们如下的错误:

Linux删除.user.ini文件报错Shell

rm: 无法删除’.user.ini’: 不允许的操作
这将导致我们不能删除这个文件夹

其实作者在设计的时候主要是为了目录的安全性,所以添加了这个文件,我们可以通过如下命令解除禁止赋予可以修改的权限

chattr -i .user.ini

这时候我们进行删除就可以了,如果我们想再修改回之前的权限,只需要做如下的操作就可以了。

chattr +i .user.ini

指定前缀信用卡卡号生成

函数代码

from random import Random
import copy
 
def completed_number(prefix, length):
    """
    'prefix' is the start of the CC number as a string, any number of digits.
    'length' is the length of the CC number to generate. Typically 13 or 16
    """
    generator = Random()
    generator.seed()    # Seed from current time
    ccnumber = prefix
    # generate digits
    while len(ccnumber) < (length - 1):
        digit = str(generator.choice(range(0, 10)))
        ccnumber.append(digit)
  # Calculate sum
    sum = 0
    pos = 0
    reversedCCnumber = []
    reversedCCnumber.extend(ccnumber)
    reversedCCnumber.reverse()
    while pos < length - 1: odd = int(reversedCCnumber[pos]) * 2 if odd > 9:
            odd -= 9
        sum += odd
        if pos != (length - 2):
            sum += int(reversedCCnumber[pos + 1])
        pos += 2
  # Calculate check digit
    checkdigit = ((sum // 10 + 1) * 10 - sum) % 10
    ccnumber.append(str(checkdigit))
    return ''.join(ccnumber)
 
def credit_card_number(prefixList, howMany=1, length=16):
    generator = Random()
    generator.seed()    # Seed from current time
    if type(prefixList)==str:
        prefixList=[[i for i in prefixList]]
    if type(prefixList[0])==str:
        prefixList=[[i for i in List] for List in prefixList]
    result = []
    while len(result) < howMany:
        ccnumber = copy.copy(generator.choice(prefixList))
        result.append(completed_number(ccnumber, length))
    return result

调用示例
#生成前缀为’123456′,1个,卡号长度16位

fakecard = credit_card_number('123456')

#生成前缀为’123456′,1个,卡号长度16位

fakecard = credit_card_number('123456',1,16)

#生成前缀为’123’或’234’的信用卡卡号,共15个,卡号长度16位

fakecard = credit_card_number(['123','234'], 15,16)

简单封装

wget https://raw.githubusercontent.com/malaohu/ruyo-shell/master/credit_card_number.py
python credit_card_number.py

原文链接: https://51.ruyo.net/8293.html