Common operation records of Ubuntu cloud host

background

Yesterday, I went to the computer room to flash the dell R750 machine from CentOS8 to Ubuntu. I was a little uncomfortable. I will record the use of Ubuntu here and continue to update and add.
In addition, I feel that Ubuntu is much easier to use than CentOS.
Insert picture description here

Create user

adduser xxx
ubnutu默认的root是最高权限,但是默认用于切换,不做登录
普通用户加上sudo 即可获得超限,
su root也能切换root,此时不再需要用sudo

cmake install

cd ~/Download
wget https://cmake.org/files/v3.13/cmake-3.13.0-Linux-x86_64.tar.gz
tar -xzvf cmake-3.13.0-Linux-x86_64.tar.gz

# 解压出来的包,将其放在 /opt 目录下,其他目录也可以,主要别以后不小心删了
sudo mv cmake-3.13.0-Linux-x86_64 /opt/cmake-3.13.0

# 建立软链接
sudo ln -sf /opt/cmake-3.13.0/bin/*  /usr/bin/

# 查看 cmake 版本
cmake --version

Soft link, hard link, system variable

(1) Environmental variables

  • Environment variable: In linux, environment variable means adding the path of the specified directory to the path variable, and then when the command is executed, it will find the corresponding program in the specified folder and execute it.
  • When the software is not installed in the directory specified in the path, the system will not find the program. But add the relative or absolute complete path of the program to execute the program.
  • When we install the software and forget to set the installation path of the software to the path specified by path, then we need to edit the /etc/profilefile:
# 编辑profile
vim  /etc/profile
# 保存环境变量
export PATH=/directory:$PATH   	#directory为可执行程序所在的目录
# 查看是否添加成功
echo $PATH

(2) Soft connection

  • Soft link: Create a soft link for the software executable program and put it directly into the directory specified by path. When the command is executed anywhere in the system, the system can also find the corresponding executable program.
  • Similar to the shortcut on the window system
  • Note that the source file path is written as an absolute path
  • The soft link can be deleted directly like a file, but does not affect the source file
  • The soft link will generate an image file on the selected location and will not occupy disk space.
# 常用方法
# 添加软连
ln -s	[源文件 / 目录]  [目标文件 / 目录]
# 修改软连
ln -snf	[源文件 / 目录]  [目标文件 / 目录]
#e.g
sudo ln -sf /opt/cmake-3.13.0/bin/*  /usr/bin/

(3) Hard connection

  • The properties are the same as the soft link, but the hard link will directly copy the source file to the specified location, occupying the same amount of disk space (usually not used)
  • ln without parameters is a hard link, it will generate a space the same size as the source file.

(4) Other parameters

Whether it is a soft link or a hard link, the files keep changing in sync. If all hard links to a file are deleted, the content of the file will be deleted. The soft link will only be invalid if the source link file is deleted.

常用参数:
-b	删除,覆盖以前建立的链接
-d	允许超级用户制作目录的硬链接
-f	强制执行
-i	交互模式,文件存在则提示用户是否覆盖。
-n	把符号链接视为一般目录
-s	软连接 
-v	显示详细的处理过程

(5) Take cmake installation as an example

  • Compile and install
# 解压
cd /usr/local/
tar -zxvf -f cmake-3.13.0-rc2.tar.gz
cd cmake-3.13.0-rc2
# 编译安装
./configure
make
make install
# 安装完成
cd ..
mv cmake-3.13.0-rc2 cmake
# 添加环境变量
vim /etc/profile
export PATH=/usr/local/cmake/bin:$PATH
# 使环境变量生效
source /etc/profile
# 检查
cmake --version
  • Create soft link directly
# 解压出来的包,将其放在 /opt 目录下,其他目录也可以,主要别以后不小心删了
tar -xzvf cmake-3.13.0-Linux-x86_64.tar.gz
sudo mv cmake-3.13.0-Linux-x86_64 /opt/cmake-3.13.0

# 建立软链接
sudo ln -sf /opt/cmake-3.13.0/bin/*  /usr/bin/
# 查看 cmake 版本
cmake --version
  • Software installation problems encountered:
    Insert picture description here
    This may be caused by no export, and the system cannot find the file directory. Therefore,:
vim /etc/profile
export PATH=/opt/cmake3.18.0/bin:$PATH

Regarding direct decompression or compilation and installation

In the Linux environment, the downloaded tar.gz installation package, some can be used directly after decompression, and some need to be compiled and installed before using
tar -zxvf to decompress, enter the directory and read README.md to know the answer.
In addition, if you download Binary is the compiled version that can be used directly, even if it is tar.gz, it can be used after decompression;
Source is the source code version, you need to compile it yourself

Guess you like

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