Linux cloud host common operations CentOS

Install python environment zhihu

Use the wget command to download the Python 3.6.4 installation package

wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz

Use the tar command to decompress Python 3.6.4

tar zxvf Python-3.6.4.tgz

Enter the Python-3.6.4 directory cd Python-3.6.4 to compile and install, execute the ./configure
script./configure to execute the installation

make
make install

After the installation is successful, the installation directory of Python 3.6 is:

/usr/local/lib/python3.6

Insert picture description here

Install pip3

  • Install pip3
sudo yum -y install python3-pip
  • Use pip3 to install third-party packages
sudo pip3 -install scrip
  • Specify software source during pip installation
sudo pip3 install xxx -i https://pypi.mirrors.ustc.edu.cn/simple/ 

Upload and download files

上传
rz -y
下载文件
sz 文件名

Insert picture description here

Rename, move, copy, delete

  • Renamed
sudo mv A new B 
  • mobile
mv [选项] 源文件或目录 目标文件或目录 

 - I 交互方式操作。如果mv操作将导致对已存在的目标文件的覆盖,此时系统询问是否重写,要求用户回答y或n,这样可以避免误覆盖文件。
 - f 禁止交互操作。在mv操作要覆盖某已有的目标文件时不给任何指示,指定此选项后,i选项将不再起作用。
  如果所给目标文件(不是目录)已存在,此时该文件的内容将被新文件覆盖。为防止用户在不经意的情况下用mv命令破坏另一个文件,建议用户在使用mv命令移动文件时,最好使用i选项。 
  • copy
cp [选项] 源文件或目录 目标文件或目录 

参数:
  - a 该选项通常在拷贝目录时使用。它保留链接、文件属性,并递归地拷贝目录,其作用等于dpR选项的组合。
  - d 拷贝时保留链接。
  - f 删除已经存在的目标文件而不提示。
  - i 和f选项相反,在覆盖目标文件之前将给出提示要求用户确认。回答y时目标文件将被覆盖,是交互式拷贝。 
  - p 此时cp除复制源文件的内容外,还将把其修改时间和访问权限也复制到新文件中。 
  - r 若给出的源文件是一目录文件,此时cp将递归复制该目录下所有的子目录和文件。此时目标文件必须为一个目录名。
  - l 不作拷贝,只是链接文件。 
  需要说明的是,为防止用户在不经意的情况下用cp命令破坏另一个文件,如用户指定的目标文件名是一个已存在的文件名,用cp命令拷贝文件后,这个文件就会被新拷贝的源文件覆盖,因此,建议用户在使用cp命令拷贝文件时,最好使用i选项。
  • delete
rm [选项] 文件

如果没有使用- r选项,则rm不会删除目录。 
  参数:
  - f 忽略不存在的文件,从不给出提示。 
  - r 指示rm将参数中列出的全部目录和子目录均递归地删除。
  - i 进行交互式删除。 
  使用rm命令要格外小心。因为一旦一个文件被删除,它是不能被恢复的。例如,用户在输入cpmv或其他命令时,不小心误输入了rm命令,当用户按了回车键并认识到自己的错误时,已经太晚了,文件已经没有了。为了防止此种情况的发生,可以使用rm命令中的 i选项来确认要删除的每个文件。如果用户输入y,文件将被删除。如果输入任何其他东西,文件将被保留。在下一个例子中,用户要删除文件test和example。然后会被要求对每个文件进行确认。用户最终决定删除example文件,保留test文件。

Use the find command to replace the original mv operation (the number of files is too long)

find 源文件路径 -type f -name '*.jpg' -exec mv {
    
    } 目标路径 \;

unzip files

*.tar 用 tar –xvf 解压 
*.gz 用 gzip -d或者gunzip 解压 
*.tar.gz和*.tgz 用 tar –xzf 解压 
*.bz2 用 bzip2 -d或者用bunzip2 解压 
*.tar.bz2用tar –xjf 解压 
*.Z 用 uncompress 解压 
*.tar.Z 用tar –xZf 解压 
*.rar 用 unrar e解压 
*.zip 用 unzip 解压 

Unzip .7z

#centos RHEL Fedora
yum install -y epel-release && yum clean all && yum makecache
yum install -y p7zip
7za e  test.7z

Pytorch installation tutorial — zhihu

Add path path

  • Edit the file directly ~/.bashrc
vim ~/.bashrc
使用vim编辑器添加
  • Use the export command to add
export PYTHONPATH=/usr/local/lib64/python3.6/site-packages

sudo yum specify the installation source

yum install XXX --enablerepo=YYY

rpm

How to install rpm file in Linux
Install rpm file

rpm -ivh XXX

Uninstall the software in rpm

rpm -e XXX

Upgrade package

rpm -Uvh XXX

View disk space

df -hl

Insert picture description here

Visual link

https://blog.csdn.net/qq_38451119/article/details/82461855
https://blog.csdn.net/wwwgeyang777/article/details/10214827/

  • Download Kinetics data set:

Open port

https://www.cnblogs.com/heqiuyong/p/10460150.html

Get current path

pwd

CentOS install .deb type software

  • Install alien, used for subcontracting type .rpm
yum install alien
  • Use alien
alien -r XXX.deb
  • installation
rpm -ivh XXX.rpm

Change software source

Reference blog

  1. Back up old configuration files
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
  1. Download the new CentOS-Base.repo to /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo

And replace some fields (needed for non-Alibaba Cloud machines)

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

3. Generate cache

 yum makecache

Ubuntu create user

https://blog.csdn.net/jiangjiang_jian/article/details/81169258

Guess you like

Origin blog.csdn.net/weixin_44307065/article/details/107654145