Avatar

Organizations

3 results for Debian
  • Debian 12 只安装VNC及i3桌面,就可以低成本的实现远程桌面环境

    安装

    # 安装通用工具
    apt-get install -y nano net-tools bzip2 procps apt-utils iputils-ping netcat-openbsd
    # 安装中文字体
    apt-get install -y locales fonts-wqy-microhei fonts-wqy-zenhei xfonts-wqy && \
        sed -i -e "s/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/" /etc/locale.gen && \
        locale-gen zh_CN.UTF-8 &&\
        update-locale LANG=zh_CN.UTF-8 LANGUAGE=zh_CN:zh LC_ALL=zh_CN.UTF-8
    # 安装VNC
    apt-get install -y tigervnc-standalone-server
    # 安装i3桌面
    apt-get install -y i3-wm i3status i3blocks dmenu xfonts-base terminator dbus-x11 libdbus-glib-1-2 ; apt-get purge -y pm-utils *screensaver*
    
    apt-get clean
    

    配置i3桌面

    ~/.config/i3/config

    # This file has been auto-generated by i3-config-wizard(1).
    # It will not be overwritten, so edit it as you like.
    #
    # Should you change your keyboard layout some time, delete
    # this file and re-run i3-config-wizard(1).
    #
    
    # i3 config file (v4)
    #
    # Please see https://i3wm.org/docs/userguide.html for a complete reference!
    
    set $mod Mod1
    
    # Font for window titles. Will also be used by the bar unless a different font
    # is used in the bar {} block below.
    
    # This font is widely installed, provides lots of unicode glyphs, right-to-left
    # text rendering and scalability on retina/hidpi displays (thanks to pango).
    #font pango:DejaVu Sans Mono 8
    font pango:monospace 8
    
    # Start XDG autostart .desktop files using dex. See also
    # https://wiki.archlinux.org/index.php/XDG_Autostart
    # exec --no-startup-id dex --autostart --environment i3
    
    # The combination of xss-lock, nm-applet and pactl is a popular choice, so
    # they are included here as an example. Modify as you see fit.
    
    # xss-lock grabs a logind suspend inhibit lock and will use i3lock to lock the
    # screen before suspend. Use loginctl lock-session to lock your screen.
    # exec --no-startup-id xss-lock --transfer-sleep-lock -- i3lock --nofork
    
    # NetworkManager is the most popular way to manage wireless networks on Linux,
    # and nm-applet is a desktop environment-independent system tray GUI for it.
    # exec --no-startup-id nm-applet
    
    # Use pactl to adjust volume in PulseAudio.
    # set $refresh_i3status killall -SIGUSR1 i3status
    # bindsym XF86AudioRaiseVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ +10% && $refresh_i3status
    # bindsym XF86AudioLowerVolume exec --no-startup-id pactl set-sink-volume @DEFAULT_SINK@ -10% && $refresh_i3status
    # bindsym XF86AudioMute exec --no-startup-id pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status
    # bindsym XF86AudioMicMute exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status
    
    # Use Mouse+$mod to drag floating windows to their wanted position
    floating_modifier $mod
    
    # move tiling windows via drag & drop by left-clicking into the title bar,
    # or left-clicking anywhere into the window while holding the floating modifier.
    tiling_drag modifier titlebar
    
    # start a terminal
    bindsym $mod+Return exec i3-sensible-terminal
    
    # kill focused window
    bindsym $mod+Shift+q kill
    
    # start dmenu (a program launcher)
    bindsym $mod+d exec --no-startup-id dmenu_run
    # A more modern dmenu replacement is rofi:
    # bindcode $mod+40 exec "rofi -modi drun,run -show drun"
    # There also is i3-dmenu-desktop which only displays applications shipping a
    # .desktop file. It is a wrapper around dmenu, so you need that installed.
    # bindcode $mod+40 exec --no-startup-id i3-dmenu-desktop
    
    # change focus
    bindsym $mod+j focus left
    bindsym $mod+k focus down
    bindsym $mod+l focus up
    bindsym $mod+semicolon focus right
    
    # alternatively, you can use the cursor keys:
    bindsym $mod+Left focus left
    bindsym $mod+Down focus down
    bindsym $mod+Up focus up
    bindsym $mod+Right focus right
    
    # move focused window
    bindsym $mod+Shift+j move left
    bindsym $mod+Shift+k move down
    bindsym $mod+Shift+l move up
    bindsym $mod+Shift+semicolon move right
    
    # alternatively, you can use the cursor keys:
    bindsym $mod+Shift+Left move left
    bindsym $mod+Shift+Down move down
    bindsym $mod+Shift+Up move up
    bindsym $mod+Shift+Right move right
    
    # split in horizontal orientation
    bindsym $mod+h split h
    
    # split in vertical orientation
    bindsym $mod+v split v
    
    # enter fullscreen mode for the focused container
    bindsym $mod+f fullscreen toggle
    
    # change container layout (stacked, tabbed, toggle split)
    bindsym $mod+s layout stacking
    bindsym $mod+w layout tabbed
    bindsym $mod+e layout toggle split
    
    # toggle tiling / floating
    bindsym $mod+Shift+space floating toggle
    
    # change focus between tiling / floating windows
    bindsym $mod+space focus mode_toggle
    
    # focus the parent container
    bindsym $mod+a focus parent
    
    # focus the child container
    #bindsym $mod+d focus child
    
    # Define names for default workspaces for which we configure key bindings later on.
    # We use variables to avoid repeating the names in multiple places.
    set $ws1 "1"
    set $ws2 "2"
    set $ws3 "3"
    set $ws4 "4"
    set $ws5 "5"
    set $ws6 "6"
    set $ws7 "7"
    set $ws8 "8"
    set $ws9 "9"
    set $ws10 "10"
    
    # switch to workspace
    bindsym $mod+1 workspace number $ws1
    bindsym $mod+2 workspace number $ws2
    bindsym $mod+3 workspace number $ws3
    bindsym $mod+4 workspace number $ws4
    bindsym $mod+5 workspace number $ws5
    bindsym $mod+6 workspace number $ws6
    bindsym $mod+7 workspace number $ws7
    bindsym $mod+8 workspace number $ws8
    bindsym $mod+9 workspace number $ws9
    bindsym $mod+0 workspace number $ws10
    
    # move focused container to workspace
    bindsym $mod+Shift+1 move container to workspace number $ws1
    bindsym $mod+Shift+2 move container to workspace number $ws2
    bindsym $mod+Shift+3 move container to workspace number $ws3
    bindsym $mod+Shift+4 move container to workspace number $ws4
    bindsym $mod+Shift+5 move container to workspace number $ws5
    bindsym $mod+Shift+6 move container to workspace number $ws6
    bindsym $mod+Shift+7 move container to workspace number $ws7
    bindsym $mod+Shift+8 move container to workspace number $ws8
    bindsym $mod+Shift+9 move container to workspace number $ws9
    bindsym $mod+Shift+0 move container to workspace number $ws10
    
    # reload the configuration file
    bindsym $mod+Shift+c reload
    # restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
    bindsym $mod+Shift+r restart
    # exit i3 (logs you out of your X session)
    bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -B 'Yes, exit i3' 'i3-msg exit'"
    
    # resize window (you can also use the mouse for that)
    mode "resize" {
            # These bindings trigger as soon as you enter the resize mode
    
            # Pressing left will shrink the window’s width.
            # Pressing right will grow the window’s width.
            # Pressing up will shrink the window’s height.
            # Pressing down will grow the window’s height.
            bindsym j resize shrink width 10 px or 10 ppt
            bindsym k resize grow height 10 px or 10 ppt
            bindsym l resize shrink height 10 px or 10 ppt
            bindsym semicolon resize grow width 10 px or 10 ppt
    
            # same bindings, but for the arrow keys
            bindsym Left resize shrink width 10 px or 10 ppt
            bindsym Down resize grow height 10 px or 10 ppt
            bindsym Up resize shrink height 10 px or 10 ppt
            bindsym Right resize grow width 10 px or 10 ppt
    
            # back to normal: Enter or Escape or $mod+r
            bindsym Return mode "default"
            bindsym Escape mode "default"
            bindsym $mod+r mode "default"
    }
    
    bindsym $mod+r mode "resize"
    
    # Start i3bar to display a workspace bar (plus the system information i3status
    # finds out, if available)
    bar {
            status_command i3status -c $HOME/.config/i3/status.conf
    }
    
    # exec_always $HOME/chrome-startup
    

    ~/.config/i3/status.conf

    linux vnc tigerVNC i3 debian Created Tue, 12 Aug 2025 19:01:37 +0800
  • 其实网上相关的文章已经非常多了,所以这篇文章的作用只是记录和明确一条确定可行的操作路径,为以后的操作节省时间,毕竟像我一样大部分人都不是专业的系统管理员,能够快速解决问题就可以了,并不想做过多的专业研究与探索。

    本操作手册是官方手册与网上手册的结合版本,集两家之所长,亲自操作可用。

    Debian

    # 安装 Docker 证书
    sudo apt-get install -y ca-certificates curl
    sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc\
    sudo echo
          "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian
          $(. /etc/os-release && echo "$VERSION_CODENAME") stable" |
          sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
    sudo apt-get update
    
    # 安装 Docker
    sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    
    # 启动 Docker
    sudo systemctl enable docker.service
    sudo systemctl start docker.service
    
    # 测试
    sudo docker version
    > Client: Docker Engine - Community
    > ...
    > Server: Docker Engine - Community
    > ...
    sudo docker compose version
    > Docker Compose version v...
    
    # 使用非 root 用户管理 Docker
    # 创建 docker 用户组
    sudo groupadd docker
    # 将当前用户添加到 docker 用户组
    sudo usermod -aG docker $USER
    # 重启
    # 再次测试
    docker version
    > Client: Docker Engine - Community
    > ...
    > Server: Docker Engine - Community
    > ...
    docker compose version
    > Docker Compose version v...
    

    CentOS | Rocky

    # 查看系统版本
    cat /etc/redhat-release
    > CentOS Linux release 7.6.1810 (Core) // CentOs 7 以上版本
    
    # 查看系统内核版本
    uname -r
    > 4.10.4-1.el7.elrepo.x86_64 // 内核版本要>3.10
    
    # 卸载旧版本
    yum remove docker
                docker-client
                docker-client-latest
                docker-common
                docker-latest
                docker-latest-logrotate
                docker-logrotate
                docker-selinux
                docker-engine-selinux
                docker-engine
    
    # 安装依赖包
    yum install -y yum-utils lvm2
                    device-mapper-persistent-data
    
    # 添加 Docker 软件源
    # 如果系统已切换到阿里云镜像源地址,可跳过此步。
    # 阿里云镜像自带docker源
    yum-config-manager
        --add-repo
        https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
    
    # 使用官方源
    yum-config-manager
        --add-repo
        https://download.docker.com/linux/centos/docker-ce.repo
    
    yum makecache fast
    # CentOS 8 or Rocky 9 使用timer替换fast
    yum makecache timer
    
    # 安装 Docker
    # 如果在 Rocky 9 系统上,会提示containerd.io版本过低,或下载失败,需要独立安装containerd.io
    # 可以重试几次
    yum install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
    
    # 启动 Docker
    # 设为开机启动
    systemctl enable docker.service
    # 启动服务
    systemctl start docker.service
    
    # 测试
    docker run hello-world
    > Unable to find image 'hello-world:latest' locally
    > latest: Pulling from library/hello-world
    > 1b930d010525: Pull complete
    > Digest: sha256:6540fc08ee6e6b7b63468dc3317e3303aae178cb8a45ed3123180328bcc1d20f
    > Status: Downloaded newer image for hello-world:latest
    > 
    > Hello from Docker!
    > This message shows that your installation appears to be working correctly.
    > 
    > To generate this message, Docker took the following steps:
    >  1. The Docker client contacted the Docker daemon.
    >  2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    >     (amd64)
    >  3. The Docker daemon created a new container from that image which runs the
    >     executable that produces the output you are currently reading.
    >  4. The Docker daemon streamed that output to the Docker client, which sent it
    >     to your terminal.
    > 
    > To try something more ambitious, you can run an Ubuntu container with:
    >  docker run -it ubuntu bash
    > 
    > Share images, automate workflows, and more with a free Docker ID:
    >  https://hub.docker.com/
    > 
    > For more examples and ideas, visit:
    >  https://docs.docker.com/get-started/
    
    docker compose version
    > Docker Compose version v...
    

    若能正常输出以上信息,则说明安装成功。

    linux CentOS Debian rocky Docker Created Fri, 06 May 2022 11:05:23 +0800
  • APT

    Debian 全球镜像站

    查找延迟最小的镜像

    sudo apt install -y netselect-apt \
        && sudo netselect-apt \
        && sudo apt autoremove -y netselect-apt \
        && rm -f sources.list
    
    The fastest 10 servers seem to be:
    
            http://mirrors.bfsu.edu.cn/debian/
            http://mirrors.tuna.tsinghua.edu.cn/debian/
            http://mirrors.neusoft.edu.cn/debian/
            http://mirrors.jlu.edu.cn/debian/
            http://ftp.cn.debian.org/debian/
            http://debian.cs.nycu.edu.tw/debian/
            http://mirror.i3d.net/debian/
            http://mirrors.163.com/debian/
            http://mirror.bizflycloud.vn/debian/
            http://ftp.kaist.ac.kr/debian/
    
    Of the hosts tested we choose the fastest valid for http:
            http://mirrors.bfsu.edu.cn/debian/
    
    Writing sources.list.
    Done.
    

    修改仓库

    # PVE QEMU debian-12-generic-amd64.qcow2
    # echo 'http://mirrors.bfsu.edu.cn/debian/' | sudo tee /etc/apt/mirrors/debian.list
    # echo 'http://mirrors.bfsu.edu.cn/debian-security/' | sudo tee -a /etc/apt/mirrors/debian-security.list
    sed -i -e "s/deb.debian.org/mirrors.bfsu.edu.cn/" /etc/apt/mirrors/debian.list
    sed -i -e "s/deb.debian.org/mirrors.bfsu.edu.cn/" /etc/apt/mirrors/debian-security.list
    
    # PVE LXC debian-12-standard_12.7-1_amd64.tar.zst
    sed -i -e "s/deb.debian.org/mirrors.bfsu.edu.cn/" /etc/apt/sources.list
    sed -i -e "s/security.debian.org/mirrors.bfsu.edu.cn\/debian-serurity/" /etc/apt/sources.list
    
    # Docker imaage debian:12
    sed -i -e "s/deb.debian.org/mirrors.bfsu.edu.cn/" /etc/apt/sources.list.d/debian.sources
    
    # 启用非自由仓库
    sed -i 's/main$/main contrib non-free non-free-firmware/' /etc/apt/sources.list
    
    # update    
    apt update
    
    # 查询软件包版本信息、优先级和来源
    apt policy <package_name>
    apt-cache policy <package_name>
    
    # 安装指定版本的包
    apt install <package_name>=<version_number>
    

    YUM

    查询仓库

    yum repolist
    # 显示所有仓库
    yum repolist all
    # 显示所有启动的仓库
    yum repolist enabled
    # 显示所有禁用的仓库
    yum repolist disabled
    

    修改仓库

    最常用的修改操作就是启动和停用, 可以使用以下命令实现:

    CentOS debian repo yum apt Created Tue, 08 Feb 2022 10:28:50 +0800