### 更改用户密码:
sudo passwd [username]
### 新增用户:
sudo useradd [username]
### GIT相关
1.拉取GIT项目免输入账号密码:
git config --global credential.helper store
输入账号密码,下次即可免密拉取
2.将dev合并到prod分支上:
git checkout prod
git pull
git merge dev
git status
git push origin prod
3.查看所有分支
git branch -a
4.删除远程分支Chapater6
git push origin --delete chapater2
5.删除本地分支 Chapater6
git branch -d chapater2
6.提交代码:
git add .
git commit -m '备注'
git push -u origin dev
### 使Ubuntu支持exfat格式U盘:
sudo apt-get install exfat-utils
### 编辑用户是否能够登录及用户文件夹:
sudo vim /etc/passwd
### 为用户创建用户目录:
mkhomedir_helper 用户名
### 将某个文件的权限设置为某个组所拥有:
sudo chgrp 组名 文件夹路径
sudo chmod g+s 文件夹路径
### 查看用户名及组信息:
id 用户名
### 将用户加入到某个组中:
比如将aaa用户加入到sudo组:
1.加入到属组,保留主组:
sudo usermod -a -G sudo aaa
2.更改主组:
sudo usermod -g sudo aaa
### 解决删除文件后磁盘空间不释放问题:
查看仍在使用删除后文件的进程:
lsof |grep delete
杀掉对应进程号即可释放空间:
sudo kill -9 进程号
### 按端口查进程:
lsof -i:8080
### 按进程名查进程:
ps -aux|grep xxx
### 全局环境变量添加方法:
方法一:
在~/.bashrc末尾添加如下代码:
sudo gedit ~/.bashrc
export PATH=/.../bin:$PATH
执行source ~/.bashrc使起生效
方法二:
修改文件:/etc/profile
### 开机启动添加方法:
在/etc/rc.local中添加如下代码:
sudo nohup /.../RunApServer.sh > /.../log/ApServer.log 2>&1 &
### APT-GET源配置:
sudo cp /etc/apt/sources.list /etc/apt/sources.list.old
#清空并用下列内容替换掉/etc/apt/sources.list内容:
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
以下是18.04版本源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
以下是20.04版本源:
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
以下是20.10版本源:
deb http://mirrors.aliyun.com/ubuntu/ groovy main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ groovy main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ groovy-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ groovy-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ groovy-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ groovy-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ groovy-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ groovy-backports main restricted universe multiverse
以下是20.10版本源(清华):
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy main universe restricted multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy main universe restricted multiverse
deb http://security.ubuntu.com/ubuntu/ groovy-security main universe restricted multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-security main universe restricted multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-updates main universe restricted multiverse
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ groovy-updates main universe restricted multiverse
更新源
sudo apt-get update
### 更新PIP源:
sudo mkdir ~/.pip
sudo touch ~/.pip/pip.conf
sudo gedit ~/.pip/pip.conf
加入以下内容:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
国内常用源有:
清华大学源:
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
阿里云:
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
中国科技大学:
index-url = https://pypi.mirrors.ustc.edu.cn/simple/
trusted-host = pypi.mirrors.ustc.edu.cn
临时使用指定源安装模块:
pip install xxx -i https://pypi.tuna.tsinghua.edu.cn/simple
### 提高NFS连接性能:
设置最大连接数:
sysctl -w sunrpc.tcp_slot_table_entries=128
重启服务器,查看是否生效:
sysctl -a | grep tcp_slot_table_entries
### 在线安装MYSQL环境:
安装mysql命令:
sudo apt-get install mysql-server
sudo apt install mysql-client
sudo apt install libmysqlclient-dev
离线安装MYSQL环境:
https://dev.mysql.com/downloads/mysql/
根据需要下载对应版本(deb tar包)
tar -xf mysql-server_5.7.30-1ubuntu16.04_amd64.deb-bundle.tar
sudo dpkg -i mysql-common_5.7.30-1ubuntu16.04_amd64.deb
依次安装DEB包:
sudo dpkg-preconfigure mysql-community-server_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i libmysqlclient20_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i libmysqlclient-dev_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i libmysqld-dev_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i libc6_2.19-0ubuntu6_amd64.deb (可根据需要安装)
sudo dpkg -i libaio1_0.3.110-2_amd64.deb(可根据需要安装)
sudo dpkg -i mysql-community-client_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-client_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i mysql-common_5.7.30-1ubuntu16.04_amd64.deb
sudo dpkg -i libmecab2_0.996-1.2ubuntu1_amd64.deb
sudo dpkg -i mysql-community-server_5.7.30-1ubuntu16.04_amd64.deb
注:
libmecab2_0.996-1.2ubuntu1_amd64.deb的下载地址为:
http://archive.ubuntu.com/ubuntu/pool/universe/m/mecab/libmecab2_0.996-1.2ubuntu1_amd64.deb
其他包均可通过https://pkgs.org/下载
安装成功后可以通过下面的命令测试是否安装成功:
sudo service mysql status
—进入mysql修改Root地址:
mysql -uroot -p;
use mysql;
select user,host from user;
update user set host='%' where user='root';
flush privileges;
select user,host from user;
让mysql可以远程访问:
编辑文件/etc/mysql/mysql.conf.d/mysqld.cnf
注释掉bind-address一行
重启mysql:
方式一:sudo /etc/init.d/mysql restart
方式二:sudo service mysql restart
解决用root账户装的mysql其他账户无法登录的问题:
use mysql;
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'Ss123456';
flush privileges;
### 安装JAVA环境:
创建文件夹并解压文件:
sudo mkdir /opt/java
sudo tar -zxvf jdk-8u231-linux-x64.tar.gz -C /opt/java/
编辑/etc/profile文件:
sudo gedit ~/.bashrc
追加以下内容:
#set java environment
export JAVA_HOME=/opt/java/jdk1.8.0_231
export PATH=${JAVA_HOME}/bin:${PATH}
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
刷新环境:
source ~/.bashrc
### 安装SAMBA:
配置文件: /etc/samba/smb.conf
重启服务:sudo /etc/init.d/samba restart
查看是否正在运行:ps -aux | grep samba
追加以下内容:
[deeplearning]
path = /home/amax/deeplearning
available = yes
browseable = yes
public = yes
writable = yes
### 安装SSH:
sudo apt-get install openssh-server
sudo /etc/init.d/ssh start
### 安装NVIDIA驱动(430.34):
禁用nouveau驱动:
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
加入以下内容:
blacklist nouveau
options nouveau modeset=0
使配置生效:
sudo update-initramfs -u
重启系统:
reboot
检查是否生效:
lspci | grep nouveau
没有内容输出,说明禁用成功
下载对应驱动:
http://www.nvidia.cn/Download/Find.aspx?lang=cn
或:https://www.nvidia.cn/Download/index.aspx?lang=cn
TitanXP驱动下载地址:https://us.download.nvidia.cn/XFree86/Linux-x86_64/430.34/NVIDIA-Linux-x86_64-430.34.run
Ubuntu18.04版本的RTX2080TI驱动下载地址:https://us.download.nvidia.cn/XFree86/Linux-x86_64/450.66/NVIDIA-Linux-x86_64-450.66.run
Ubuntu18.04版本的RTX3090驱动下载地址:https://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/455.45.01/NVIDIA-Linux-x86_64-455.45.01.run&lang=us&type=TITAN
进入命令行模式:
Ctrl+Alt+F1
关闭系统自带的 X 服务:
service lightdm stop
赋予安装文件的可执行权限:
sudo chmod +x ./*****.run
执行安装文件:
sudo ./*****.run --no-opengl-files
accept
yes
yes
ok
检查是否安装完成:
nvidia-smi
回到窗口模式:
Ctrl+Alt+F7
-------------------------------------------------------------------------
遇到:Please install your distribution's libc development package问题,执行如下命令:
sudo apt update
sudo apt upgrade
sudo apt search libc-dev
sudo apt install libc6-dev
sudo apt upgrade libc6-dev
### 安装CUDA(version<=10.0):
版本对照表:
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
https://tensorflow.google.cn/install/source?hl=en#gpu
方式一:
下载cuda安装文件:
https://developer.nvidia.com/cuda-toolkit-archive
RTX2080TICUDA下载地址:https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
或:https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
执行安装文件:
sudo sh cuda_10.0.130_410.48_linux.run
按住回车,直到服务条款显示到100%
accept
n(不要安装driver)
y
y
y
在~/.bashrc文件中追加以下环境变量:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64
export PATH=$PATH:/usr/local/cuda-10.0/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda-10.0
使环境变量生效:
source ~/.bashrc
检查是否安装成功:
nvcc --versionsite-packages/tensorflow/python
方式二:site-packages/tensorflow/python
选择合适docker镜像:
https://hub.docker.com/r/nvidia/cuda/tags
使用docker进行安装:
https://github.com/NVIDIA/nvidia-docker
---------------------------------------------------------------------------------------------------------------------------
出现问题:Could not load dynamic library 'libcusolver.so.10'; dlerror: libcusolver.so.10: cannot open shared object file时:
1.首先查找libcusolver.so文件,一般是libcusolver.so、libcusolver.so.9、libcusolver.so.11、libcusolver.so.12
2.建立文件链接:sudo ln -s /usr/local/cuda-11.0/libcusolver.so.11 /usr/local/cuda-11.0/libcusolver.so.10
3.还是不行,则直接将so库文件拷贝到 ...python3.6/site-packages/tensorflow/python 文件夹中:
如某个虚拟环境的文件夹是:/home/allen/Software/python3env/lib/python3.6/site-packages/tensorflow/python
### 安装CUDNN:
CUDNN下載地址:https://developer.nvidia.com/rdp/cudnn-download
下載以下三个安装包并依次执行以下安装命令:
sudo dpkg -i libcudnn8_x.x.x-1+cudax.x_amd64.deb
sudo dpkg -i libcudnn8-dev_8.x.x.x-1+cudax.x_amd64.deb
sudo dpkg -i libcudnn8-samples_8.x.x.x-1+cudax.x_amd64.deb
### 挂载磁盘:
安装NFS服务:
sudo apt install nfs-kernel-server
临时挂载命令:
sudo mount -t ext4 /dev/sdb /data
临时挂载NFS:
挂载:sudo mount -t nfs -o nolock test.ruicare.com:/volume1/aaa /data/aaa
卸载:sudo umount /data/aaa
永久挂载配置:
查看硬盘分区格式以及UUID:
sudo blkid
sudo fdisk -l
编辑硬盘配置文件:
sudo xed或gedit /etc/fstab
新增一行配置:
磁盘类型:/dev/sdb1 /data ntfs defaults 0 0
UUID类型:UUID=3fa07078-c996-47a2-a797-0ed20fe69bfc /data ext4 defaults 0 2
NFS类型:private.ruicare.com:/volume1/RuiCareFileServerDev /data/RuiCareFileServerDev nfs vers=4,nolock,proto=tcp,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,_netdev,noresvport 0 0
保存并重启:
sudo reboot
查看各分区硬盘使用状态:
df -hl
### 系统镜像:
ubuntu16.04下载地址:
中科大源:
http://mirrors.ustc.edu.cn/ubuntu-releases/16.04/
阿里云镜像站:
http://mirrors.aliyun.com/ubuntu-releases/16.04/
### 安装内外网远程桌面服务:
方法一(该方式会安装xfce4并使用xfce4作为远程桌面):
sudo apt-get install xrdp # 安装xrdp
sudo apt-get install vnc4server # 安装vnc4server
sudo apt-get install xubuntu-desktop # 安装桌面xubuntu-desktop
echo "xfce4-session" >~/.xsession # 向xsession中写入xfce4-session
sudo service xrdp restart # 开启xrdp服务
此处新增用户时需进入到用户目录并执行:
sudo chmod 777 -R /home/[username]
echo "xfce4-session" >~/.xsession
sudo service xrdp restart
然后重启服务器再尝试登录
方法二:
sudo apt-get install xrdp vnc4server xbase-clients
/usr/share/applications目录下打开“Desktop Sharing”选项,
仅选中每一项的中间一项,并设置密码
sudo apt-get install dconf-editor
打开dconf-editor软件找到:org > gnome > desktop > remote-access
取消钩选 “requlre-encryption”属性
windows远程桌面连接后使用vnc-any连接即可
### ubuntu chmod 777误操作解决办法:
pkexec chmod 0755 /etc/sudoers.d
### dpkg: error: dpkg status database is locked by another process解决办法:
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a
### 安装Shadowsocks:
安装libsodium:
apt-get install build-essential
wget https://github.com/jedisct1/libsodium/releases/download/1.0.11/libsodium-1.0.11.tar.gz
tar xf libsodium-1.0.11.tar.gz && cd libsodium-1.0.11
./configure && make -j2 && make install
ldconfig
安装Shadowsocks:
sudo pip3 install --upgrade pip
sudo pip3 install shadowsocks
sudo vim /etc/shadowsocks.json
加入以下配置:
{
"server":"::",
"server_port":8388,
"local_port":1080,
"password":"password",
"timeout":600,
"method":"aes-256-cfb"
}
启动:
sudo ssserver -c /etc/shadowsocks.json -d start
### 设置某个其他普通用户不可访问自己目录:
sudo chmod 0750 /home/[username]
### 安装anaconda:
下载安装文件:
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
执行安装文件:
sudo bash Anaconda3-5.3.1-Linux-x86_64.sh
### Ubuntu安装opencv:
sudo apt update
sudo apt install python3-opencv
sudo pip3 install --upgrade opencv-python
### Ubuntu设置默认python版本:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
列出设置过的python列表:
update-alternatives --list python
查看配置:
update-alternatives --config python
### 安装Pytorch:
sudo apt-get update
sudo pip3 install --upgrade pip
sudo apt-get install python3-dev
安装所需依赖:
sudo pip3 install numpy ninja pyyaml mkl mkl-include setuptools cmake cffi typing_extensions future six requests dataclasses
下载pytorch:
git clone --recursive https://github.com/pytorch/pytorch
cd pytorch
git submodule sync
git submodule update --init --recursive
编译pytorch:
sudo python3.6 setup.py install
配置系统默认python版本:
update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
将编译的源目录重新命名
测试pytorch:
import torch
x = torch.rand(5, 3)
print(x)
查看torch cudnn版本:
python3
import torch
torch.backends.cudnn.version()
错误解决办法:
1.No CMAKE_CXX_COMPILER could be found:
sudo apt-get update
sudo apt-get install -y build-essential
### docker打包镜像并上传到阿里云:
docker login --username=allen@rui registry.cn-hangzhou.aliyuncs.com
查看容器:
docker ps -a
将容器打包成镜像:
docker commit -a="allen@rui" -m="description" [容器id] [镜像名]:[版本]
查看打包好的镜像:
docker images
给镜像打上标签:
docker tag [ImageId] registry.cn-hangzhou.aliyuncs.com/ruicare/[镜像名]:[镜像版本号]
上传镜像到阿里云仓库:
docker push registry.cn-hangzhou.aliyuncs.com/ruicare/[镜像名]:[镜像版本号]
### Mysql数据库卡住解决办法
查看事务:
SELECT * FROM information_schema.INNODB_TRX;
查看进程:
show processlist;
杀掉进程:
kill xxxx;