Commonly used commands (updated)

1、python

(1) pip list

/usr/python3.7/bin/python3.7 -m pip list
apt-get install python3-pip

(2) Tsinghua mirror download

# 清华源
pip install scipy -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install (需要安装的库) -i https://pypi.tuna.tsinghua.edu.cn/simple

#百度
pip install scipy -i https://mirror.baidu.com/pypi/simple

2, gdb debugging

(1) Produce executable files that can be debugged by gdb

#include <stdio.h>
int main ()
{
    
    
    unsigned long long int n, sum;
    n = 1;
    sum = 0;
    while (n <= 100)
    {
    
    
        sum = sum + n;
        printf("%d \n", sum);
        n = n + 1;
    }
    return 0;
}
# main.c
# 加-g,生产的可执行文件,才能进行gdb调试
$ gcc main.c -o main -g
$ gbd main   # 启动调试
$ l          # list 代码
$ r          # run: 直接运行,运行完[Inferior 1 (process 55828) exited normally]  退出
$ b 10       # break 在第十行设置断点
$ r          # 开始运行,直到遇到断点
$ c          # continue 继续执行,直到遇到下一个断点
$ q          # quit  退出调试

result:

(gdb) c
Continuing.
sum = 3

Breakpoint 1, main () at main.c:11
11              sum = sum + n;

gdb learning

3、Linux

(1), centos installation specified path

yum -c /etc/yum.conf --installroot=/home/XXX/debuginfo-install --releasever=/  install debuginfo-install -y glibc-2.17

(2) Process tree

pstree

(3) locate

locate opencv

(4) Process

ps aux | grep nginx
ps -ef | grep nginx

(5) Compression

 tar czvf pytorch.tar pytorch

(6) ldd link library

ldd -r /path/to/.so
ldd /path/to/.so

(7) Use the command "which" to view the absolute path of the command "bash", and enter the following command

which cc
which gcc

(8) Hard disk occupation
https://blog.csdn.net/achenyuan/article/details/78674102
rookie tutorial

$ du --max-depth=1 -h  /source/code/
$ df -h
$ du -sh *   # 推荐

(9) View server CPU core information

$ cat /proc/cpuinfo

(10) Change Ubuntu software mirror to Tsinghua mirror sourcelist

#1、将原始的source list复制替换
sudo cp /etc/apt/sources.list  /etc/apt/sources.list.old
#2、使用vim打开source list
sudo vim  /etc/apt/sources.list
# 注释原因链接,添加下列镜像源
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

sudo apt-get update

4. Shell script

(1) Summary of shell script errors

if [ ! -f "$temp.txt"]; then
	echo "txt no exist"
fi
./test.sh: 第 50 行:[: 缺少 `]'
if [ ! -f "$temp.txt" ]; then   # 空格
	echo "txt no exist"
fi

5、nohup

CUDA_VISIBLE_DEVICES=3 nohup /usr/python3.8/bin/python3.8 server.py run > /path/to/log.file 2>&1

6. git

git clone --recursive https://github.com/ZeroE04/CenterNet_onnxruntime.git

Guess you like

Origin blog.csdn.net/weixin_40437821/article/details/111299783