1、python
(1) pip list
/usr/python3.7/bin/python3.7 -m pip list
apt-get install python3-pip
(2) 清华镜像下载
# 清华源
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
(3) 软链接
# 将python3链接到python3.8
ln -s /usr/bin/python3.8 /usr/bin/python3
# 解除
rm -rf /usr/bin/python3
(4) 安装setuptools和pip
2、gdb调试
(1) 生产可进行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 退出调试
结果:
(gdb) c
Continuing.
sum = 3
Breakpoint 1, main () at main.c:11
11 sum = sum + n;
3、Linux
(1)、centos安装指定路径
yum -c /etc/yum.conf --installroot=/home/XXX/debuginfo-install --releasever=/ install debuginfo-install -y glibc-2.17
(2) 进程树
pstree
(3) locate
locate opencv
(4) 进程
ps aux | grep nginx
ps -ef | grep nginx
(5) 压缩
tar czvf pytorch.tar pytorch
(6) ldd链接库
ldd -r /path/to/.so
ldd /path/to/.so
(7) 使用指令"which"查看指令"bash"的绝对路径,输入如下命令
which cc
which gcc
# gcc 降级
sudo apt-get install gcc-7 g++-7
gcc -v
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 100
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 100
(8) 硬盘占用
https://blog.youkuaiyun.com/achenyuan/article/details/78674102
菜鸟教程
$ du --max-depth=1 -h /source/code/
$ df -h
$ du -sh * # 推荐
(9) 查看服务器CPU核心信息
$ cat /proc/cpuinfo
(10) 更改Ubuntu软件镜像为清华镜像 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
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://archive.ubuntu.com/ubuntu/ bionic main restricted
deb-src http://archive.ubuntu.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ bionic universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic universe
deb http://archive.ubuntu.com/ubuntu/ bionic-updates universe
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
deb-src http://archive.canonical.com/ubuntu bionic partner
deb http://security.ubuntu.com/ubuntu/ bionic-security main restricted
deb-src http://security.ubuntu.com/ubuntu/ bionic-security main restricted
deb http://security.ubuntu.com/ubuntu/ bionic-security universe
deb-src http://security.ubuntu.com/ubuntu/ bionic-security universe
deb http://security.ubuntu.com/ubuntu/ bionic-security multiverse
deb-src http://security.ubuntu.com/ubuntu/ bionic-security multiverse
sudo apt-get update
(11) ubuntu下buff/cache占用过大处理
su
echo 1 > /proc/sys/vm/drop_caches
echo 2 > /proc/sys/vm/drop_caches
echo 3 > /proc/sys/vm/drop_caches
(12)分割、合并大文件
split -b 100M -d train.zip train.zip.
cat train.zip.* > train.zip
4、shell脚本
(1) shell 脚本报错总结
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
7.切换gcc/g++版本
sudo update-alternatives --config gcc