Skip to content

Quick Reference

For tools and commands on a newly installed Linux system

对于新装linux 系统的指令、工具速查

Shell

一个好用的shell是一个linux的开始

  • busybox

    Most Simple Unix Basic Tools

    嵌入式设备的瑞士军刀

  • bash

    most linux default shell

  • fish

    简单易上手的shell

    bash
    # ubuntu/debian/raspi
    sudo apt update
    sudo apt install fish
    chsh -s $(which fish)
  • zsh

    现代化的增强的shell,扩展性强

    bash
    # ubuntu/debian/raspi
    sudo apt update
    sudo apt install zsh
    chsh -s $(which zsh)
    • oh my zsh

      bash
      sh -c "$(wget -O- https://install.ohmyz.sh/)"
      vi ~/.zshrc
      bash
      # replace the theme or a theme you like
      ZSH_THEME="agnoster"
    • p10k

      bash
      git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k
      
      # 国内gitee镜像
      git clone --depth=1 https://gitee.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k

      替换为p10k的主题

      bash
      # Linux
      sed -i 's|^ZSH_THEME=".*"$|ZSH_THEME="powerlevel10k/powerlevel10k"|' ~/.zshrc
      # MacOS
      # sed -i '' 's|^ZSH_THEME=".*"$|ZSH_THEME="powerlevel10k/powerlevel10k"|' ~/.zshrc

      加载

      bash
      source ~/.zshrc

SSH

bash
# 1) 如果还没装
sudo apt update
sudo apt install -y openssh-server

# 2) 检查配置是否有效
sudo sshd -t

# 3) 手动启动
sudo systemctl start ssh

# 4) 查看状态
sudo systemctl status ssh --no-pager

# 5) 设为开机自启
sudo systemctl enable ssh

Basic Tools

C/C++/Python
bash
sudo apt update
sudo apt install -y \
	vim build-essential cmake ninja-build gdb clang clangd ccache pkg-config \
    git git-lfs curl wget unzip zip tar ripgrep tmux htop jq tree ca-certificates \
    python3 python3-pip python3-venv pipx locales
UV for python
bash
# install uv
curl -LsSf https://astral.sh/uv/install.sh | sh

临时使用 USTC 源

bash
UV_DEFAULT_INDEX="https://mirrors.ustc.edu.cn/pypi/simple" uv pip install ruff

设为默认 USTC 源

bash
mkdir -p ~/.config/uv
cat > ~/.config/uv/uv.toml <<'EOF'
[[index]]
url = "https://mirrors.ustc.edu.cn/pypi/simple"
default = true
EOF
Docker

ubuntu

bash
# debian 系
sudo apt update
sudo apt install -y ca-certificates curl

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg \
  -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

codename=$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")

sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null <<EOF
Types: deb
URIs: https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu
Suites: ${codename}
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

sudo systemctl enable --now docker
sudo docker run hello-world
bash
# fish 系
set codename (grep '^UBUNTU_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
if test -z "$codename"
  set codename (grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
end

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

printf "Types: deb\nURIs: https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu\nSuites: $codename\nComponents: stable\nSigned-By: /etc/apt/keyrings/docker.asc\n" | sudo tee /etc/apt/sourc
es.list.d/docker.sources >/dev/null

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

raspi

bash
set codename (grep '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2 | tr -d '"')

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

printf "Types: deb\nURIs: https://mirrors.ustc.edu.cn/docker-ce/linux/debian\nSuites: $codename\nComponents: stable\nSigned-By: /etc/apt/keyrings/docker.asc\n" | sudo tee /etc/apt/sourc
es.list.d/docker.sources >/dev/null

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

当前用户入docker组

bash
  sudo groupadd docker 2>/dev/null || true
  sudo usermod -aG docker $USER
  newgrp docker # 直接本terminal生效

配置docker国内镜像加速

bash
sudo vim /etc/docker/daemon.json
json
{
	"dns": ["223.5.5.5", "1.1.1.1"],
    "registry-mirrors": [
        "https://registry-1.docker.io",
        "https://mirror.ccs.tencentyun.com",
        "https://docker.1ms.run",
        "https://docker.1panel.live",
        "https://docker.m.ixdev.cn",
        "https://hub.rat.dev",
        "https://docker.xuanyuan.me",
        "https://docker.xuanyuan.run",
        "https://docker.xuanyuan.dev",
        "https://dockerproxy.net",
        "https://docker-registry.nmqu.com",
        "https://docker.hlmirror.com",
        "https://hub3.nat.tf",
        "https://hub4.nat.tf",
        "https://docker.m.daocloud.io",
        "https://docker.kejilion.pro",
        "https://hub.1panel.dev",
        "https://dockerproxy.cool",
        "https://docker.apiba.cn",
        "https://proxy.vvvv.ee",
        "https://docker.fnnas.com"
    ]
}

重启docker

bash
sudo systemctl restart docker