搜索

有一些经常用的命令总是记不住,这里整理下吧

git更新
git stash
git pull origin master

更改默认python版本
cd /usr/bin
ls -l | grep python
rm -rf python
ln -s /usr/bin/python3  /usr/bin/python

pm2开机自启
pm2 startup
pm2 save

apt被占用
ps aux | grep -i apt</code></pre>

rclone挂载,卸载命令
rclone mount semesse:/ /OD --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 &amp;
fusermount -qzu /OD

设置cmd代理
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890

ssh保持连接
vim /etc/ssh/sshd_config
ClientAliveInterval 120
ClientAliveCountMax 720
systemctl restart sshd

.user.ini权限问题
chattr -i /www/wwwroot/honus.top/.user.ini</code></pre>


解压文件夹下所有zip文件
ls *.zip | xargs -n1 unzip -o -P infected

linux crontab任务
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
00 03    * * * ./etc/profile; /bin/sh /mnt/test1.sh

aws修改为密码登陆
#!/bin/bash
echo root:YourPassWord |sudo chpasswd root
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
sudo service sshd restart
paramiko模块
执行screen之类的命令应使用invoke_shell()
client=paramiko.SSHClient()
key=paramiko.AutoAddPolicy()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(ip, port, username=username, password=password,timeout=30)
chan = client.invoke_shell()
chan.send(&#039;screen -S a -d -m btfs/bin/btfs daemon\n&#039;)
sleep(1)
记得加\n与sleep(1)
apt安装直接确认不输入y/yes
apt-get -y install screen
yes|sh test.sh (待测试)
cmd中执行powershell指令(只允许将表达式作为通道第一个元素)
原命令
get-content config | %{$_ -replace &#039;5001&#039;,&#039;5002&#039;} &gt; config1
cmd命令,bat脚本
powershell -Command &quot;&amp; { get-content config | ForEach-Object {$_ -replace &#039;5001&#039;,&#039;5002&#039;} &gt; config1;}&quot;

powershell处理文件第n行范围
if ($_.ReadCount -ge 167 -and $_.ReadCount -le 170) 
{
        $_ -replace &#039;false&#039;,&#039;true&#039;
} 
else 
{
        $_     
}
vue nginx配置
location /api {
        rewrite ^/api/(.*) /$1 break;
        proxy_pass http://127.0.0.1:5000;
        proxy_redirect          off;
            proxy_set_header        Host $host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout   600;
            proxy_send_timeout     600;
            proxy_read_timeout     600;
    }
    location / {
        root /www/wwwroot/sql.honus.top/;
        index  index.html index.htm;
        try_files $uri $uri/ @rewrites;    
    }
    location @rewrites {
         rewrite ^(.+)$ /index.html last;
    }
安装python3.9
apt -y install wget build-essential libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
curl -O https://www.python.org/ftp/python/3.9.4/Python-3.9.4.tar.xz
tar -xf Python-3.9.4.tar.xz
cd Python-3.9.4
./configure --enable-optimizations
#编译安装
make altinstall

rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
ln -s /usr/local/bin/python3.9 /usr/bin/python3
ln -s /usr/local/bin/pip3.9 /usr/bin/pip3

安装之后pip安装模块会报错,需要修改
vim /usr/bin/lsb_release中的python版本为
#! /usr/bin/python3.7
python 类中使用装饰器
from functools import wraps
class Test:
    def on_message(fun):
        @wraps(fun)
        def print_me(self):
            fun(self)
        return print_me

    @on_message
    def test(self):
        print('res')
b=Test()
b.test()

版权属于:honus
作品采用:本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
0
查看目录

目录

来自 《一些常用命令》
评论

Honus

博主很懒,啥都没有