一些细节问题

  • 系统盘数据全部被清除,挂载盘(数据盘)重新挂载之后要初始化(也相当于被清除,因此要提前做快照备份)
  • ubuntu 系统默认无 root 用户,用户名默认为 ubuntu,很多命令需要增加 sudo,否则没有权限
  • 某些目录权限需要开放,否则无法读写,例如 sudo chmod 777 /data 给 /data 目录操作的权限
  • 更新之后更新软件命令: sudo apt update && sudo apt upgrade
  • ll 命令不可用、 ls 目录不显示颜色、终端用户名和命令行无颜色:

    • sudo chmod 777 /etc/profile.d/ 这一步是出现 Permission denied 错误时的解决方式。/etc/profile.d/ 目录和 /etc/profile 文件是等效的,自定义配置功能建议放在单独的 sh 文件里面。如果不想修改这个目录的权限,后面的 vim 操作要加 sudo
    • 命令行:vim /etc/profile.d/conf_2021.sh 进入 vim 编写文件
    • i 添加内容:alias ll='ls -lh --color=auto
    • 再添加 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35;1m\]\u\[\033[00;00;1m\]@\[\033[01;35;1m\]\h\[\033[00;31;1m\]:\[\033[00;34;1m\]\w \[\033[01;32;1m\]\$ \[\033[0;37;1m\]'
      或者 腾讯云重装 ubuntu 系统记录 - 图1

      1. PS1='${debian_chroot:+($debian_chroot)}\[\033[01;35;1m\]\u\[\033[00;00;1m\] \@\[\033[00;31;1m\]:\[\033[00;34;1m\]\w \[\033[01;32;1m\]\$ \[\033[0;37;1m\]'
      1. \u username
      2. \h hostname(一般不需要)
      3. \@ 12小时制的时间 (方便看时间)
      4. \w 完整目录(可配合设置 `PROMPT_DIRTRIM=3` 来控制显示最多3级目录,多余3级中间路径.../显示)
      5. \W 最后一级目录

      参考:https://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/、https://itectec.com/ubuntu/ubuntu-how-to-shorten-the-command-line-bash-prompt/

    • 依次按 EscCapslock (大写锁定键)、连续两次 ZZZ )退出 vim

    • 命令行:source ~/.bashrc 使设置生效

image.png

数据盘设置

  1. 初始化:https://cloud.tencent.com/document/product/362/32403
  2. 操作挂载数据盘的时候没有将挂载信息写入到/etc/fstab中,导致重启服务器之后系统没有自动挂载数据盘 ``` /dev/disk/by-id/virtio-disk-kwzbfhv6 /vdb ext4 defaults 0 0

/dev/vdb /vdb ext4 defaults 0 0

/vdb/swapfile swap swap defaults 0 0

  1. <a name="rgura"></a>
  2. # 安装和设置 pip3
  3. 1. `sudo apt install python3-pip`
  4. 1. `pip3 install pip -U` 腾讯云的服务器会自动把 pip 的镜像定位在腾讯的镜像上,如果没有自动改成国内的镜像,就参考[清华 pypi 镜像的帮助](https://mirror.tuna.tsinghua.edu.cn/help/pypi/)
  5. 1. 出现以下警告,则说明 pip 安装在了环境变量之外的目录下,因此需要把这个目录加进来
  6. ```bash
  7. WARNING: The scripts pip, pip3 and pip3.8 are installed in '/home/ubuntu/.local/bin' which is not on PATH.
  8. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

替换成你偏好的镜像源

replace-with = ‘tuna’

清华大学

[source.tuna] registry = “https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git

  1. 命令行运行:
  2. ```bash
  3. curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

其他镜像参考:Rust国内镜像源大全