Study notes: my commonly used linux commands

1. Aliyun transfers files through the intranet

scp -r root@ip:/www/wwwroot/1.txt /www/

2. Install docker on ubuntu

reference link

# 升级apt-get
sudo apt-get update

# 安装依赖
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common
    
# 添加 Docker 的官方 GPG 密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# 验证密钥
sudo apt-key fingerprint 0EBFCD88

# 设置一个稳定的仓库
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"
   
# 再更新一次 apt
sudo apt-get update

# 安装最新的 docker
sudo apt-get install docker-ce docker-ce-cli containerd.io

3. Use of docker

systemctl enable docker # 开机自动启动docker
systemctl start docker # 启动docker
systemctl restart docker # 重启dokcer
systemctl stop docker # 关闭dokcer

docker pull 镜像 # 拉取镜像
docker images # 查看镜像
docker rmi 镜像id # 删除镜像

# 创建容器
docker run -i -t -d --name 容器名 -p 宿主机端口:容器内部端口 --privileged=true --restart=always -v 宿主机目录:容器内部目录 容器名 
docker stop 容器id # 停止容器
docker start 容器id # 启动容器
docker ps -a # 查看容器
docker rm 容器id # 删除容器
docker exec -it 容器名 /bin/bash # 进入容器
ctrl+p+q # 退出容器 

docker --help # 查看容器命令帮助

4. Use nohup to run in the background

nohup 命令 &
# 关闭nohup进程
ps -xf |grep 命令关键字
kill -9 进程id

Guess you like

Origin blog.csdn.net/qq_37428140/article/details/125949323