0.Preliminary knowledge
0.1 Unzip
0.1.1 tar
- Pack the files:
tar -cvf log.tar log.txt #仅打包,不压缩
tar -zcvf log.tar.gz log.txt #以gzip压缩,最常见
tar -jcvf log.tar.bz2 log.txt #以bzip2压缩
- unzip:
tar -xvf /opt/soft/test/log.tar
tar -zxvf /opt/soft/test/log.tar.gz -C ~/Desktop/ #最常见
-zxvf is selected based on whether gzip is compressed, -C decompresses to the specified folder
0.1.2 zip
- Pack:
zip -r test.zip dirname/
- unzip:
unzip test.zip -d dirname
0.2 soft connection
Similar to shortcuts under Windows, "link file" can point to "source file"
ln -s 源文件 链接文件
1. Install the development environment
1.1 Java JDK
- download:
https://www.oracle.com/java/technologies/downloads/
- unzip:
tar -zxvf jdk-11.0.15_linux-x64_bin.tar.gz
- Configure environment variables:
Use root, use the text editor vim or gedit (Notepad), open /etc/profile:
sudo gedit /etc/profile
Add the following content at the end of the file, remember to change JAVA_HOME to the jdk folder you just decompressed:
export JAVA_HOME=/usr/local/jdk-11.0.1 #修改为刚才解压缩的jdk文件夹
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
- Finally, restart Linux, or execute the command:
source /etc/profile
- test:
java -version
[Note] Similar to jdk, if the bin folder is used as the software environment, you can use environment variables to add the bin folder to the $PATH environment variable. Assuming that the target executable file is located in /XXX/XXX/bin, add the following at the end of the /etc/profile file:
export PATH=/XXX/XXX/bin:$PATH
例如:
export PATH=/root/anaconda3/bin:$PATH
- Then restart Linux, or execute the command:
source /etc/profile
1.2 python
Linux basically comes with python, but only the python3 command can be used, so you can create a new soft link named python and point to the python3 command:
sudo ln -s /usr/bin/python3 /usr/bin/python
1.3 gcc、g++
These two basically come with them and do not need to be installed separately.
2. Configure domestic software mirroring
2.1 apt
- Replace with USTC image with one click:
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list
- Update software source:
sudo apt update
- have a test:
sudo apt install cowsay
cowsay "hello"
2.2 pip
- When installing the library package, add the Tsinghua mirror source:
pip install XXXX包 -i https://pypi.tuna.tsinghua.edu.cn/simple
2.3 npm
- Set domestic mirror source with one click:
npm config set registry http://mirrors.cloud.tencent.com/npm/
2.4 golang
- Set domestic mirror source with one click:
go env -w GOPROXY=https://goproxy.cn,direct
3. Other commands
3.1 View disk
df -h
3.2 Check port usage
- For example, view port 8250:
lsof -i tcp:8250
3.3 Executing commands in the background
nohup 应用程序名 &