一些细节问题
- 系统盘数据全部被清除,挂载盘(数据盘)重新挂载之后要初始化(也相当于被清除,因此要提前做快照备份)
- 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\]'
或者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\]'
\u username
\h hostname(一般不需要)
\@ 12小时制的时间 (方便看时间)
\w 完整目录(可配合设置 `PROMPT_DIRTRIM=3` 来控制显示最多3级目录,多余3级中间路径.../显示)
\W 最后一级目录
依次按
Esc
、Capslock
(大写锁定键)、连续两次Z
(ZZ
)退出 vim- 命令行:
source ~/.bashrc
使设置生效
数据盘设置
- 初始化:https://cloud.tencent.com/document/product/362/32403
- 操作挂载数据盘的时候没有将挂载信息写入到/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
<a name="rgura"></a>
# 安装和设置 pip3
1. `sudo apt install python3-pip`
1. `pip3 install pip -U` 腾讯云的服务器会自动把 pip 的镜像定位在腾讯的镜像上,如果没有自动改成国内的镜像,就参考[清华 pypi 镜像的帮助](https://mirror.tuna.tsinghua.edu.cn/help/pypi/)
1. 出现以下警告,则说明 pip 安装在了环境变量之外的目录下,因此需要把这个目录加进来
```bash
WARNING: The scripts pip, pip3 and pip3.8 are installed in '/home/ubuntu/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
vim /etc/profile.d/conf_2021.sh
- 加入内容
export PATH=$PATH:/home/ubuntu/.local/bin
source /etc/profile.d/conf_2021.sh
安装 jupyter
参考之前我使用 Centos 7 系统时写的文章:CentOS server 搭建云端 jupyter notebookc.NotebookApp.notebook_dir = 'jupyterFile' # 这个其实是 ~/jupyterFile 目录
安装 R 环境
UBUNTU PACKAGES FOR R
★ Ubuntu 下添加CRAN镜像安装r
为什么我收到“命令 ‘deb’ 未找到”?
在sudo echo "deb https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/linux/ubuntu focal-cran40/" | sudo tee /etc/apt/sources.list.d/r-tuna.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt-get update
sudo apt-get install r-base- r-base-dev
~/.Rprofile
在文末添加如下语句来设置 package 的下载镜像:
安装 Rstudio:options("repos" = c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
https://rstudio.com/products/rstudio/download-server/debian-ubuntu/添加登录用户
ubuntu 给用户的权限比较严格:Ubuntu 权限指令、Ubuntu 中创建新用户
默认会把 xxx 用户的主目录分到sudo useradd xxx -u 1997 #
sudo passwd xxx
sudo usermod -s /bin/bash xxx # 为 xxx 用户指定命令解释程序
sudo usermod -d /home/xxx xxx # 为 xxx 用户指定用户主目录
cat /etc/passwd # 查看用户
/home/xxx
下面,但是需要修改这个目录的权限sudo chmod 777 /home/xxx
,否则无法进行读写操作安装 Julia
Julia 官网最新稳定版下载
Julia 官网 linux系统下的安装指南安装 Rust
Rust 官网安装介绍
更改 rust 相关镜像:修改sudo vim /etc/profile.d/conf_2021.sh
,添加以下命令
更改 crates.io 相关镜像:修改或创建export RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup
~/.cargo/config
文件,添加以下内容 ```bash放到
[source.crates-io] registry = “https://github.com/rust-lang/crates.io-index“$HOME/.cargo/config
文件中
替换成你偏好的镜像源
replace-with = ‘tuna’
清华大学
[source.tuna] registry = “https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git“
命令行运行:
```bash
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
其他镜像参考:Rust国内镜像源大全