临时的无需大规模计算的任务场景建议使用虚拟机或 WSL。
对于直接安装,这里简要叙述 Ubuntu + Windows 的安装方法,安装顺序为 Windows > Ubuntu,在支持 UEFI 的 PC 上可行。对于直接安装 Ubuntu 单系统的,也可以参考此方法。
# find your USB flash memory‘s path
$ sudo fdisk -l
# write the iso file into USB flash memory
$ sudo dd in=/path/to/image.iso of=/dev/sdx
/ ext4 150G
swap swap #depend on the size of memary
/boot ext4 512M
/home ext4 #remain
# 8G内存可以划分4G的swap,16G内存可以划分其1/3大小的swap
# 根据实际需要,可以将一些可能会很大的文件夹单独分区,如
/var ext4
/usr ext4
注意:删除 Ubuntu 时,不能直接删除分区,直接删除会导致错误的引导项。如果引导设置在 boot 分区,除删除所有的 ubuntu 分区外,还需删除 esp 分区中的 Ubuntu 文件夹,以及使用 bootice 删除 Ubuntu 的启动项。需要注意的是,这些都是非常危险的操作。
# backup and modify source.list
$ cp /etc/apt/source.list /etc/apt/source.list.backup
$ sudo vim /etc/apt/source.list
# add aliyun source
:0,$ s/cn.archive.ubuntu.com/mirrors.aliyun.com/
:wq
$ sudo apt update && sudo apt upgrade -y
$ timedatectl set-local-rtc 1
$ sudo apt install language-pack-zh-hans language-pack-zh-hant
为开发方便,在安装 Ubuntu 系统时可以选择英文作为默认语言,之后再安装中文,设置界面等元素使用中文而保持 ~
中文件夹均为英文名。$ apt install openssh-server
$ service ssh start
oh-my-zsh
# install zsh and change default shell to zsh
$ apt install zsh
$ chsh -s /usr/bin/zsh
# install oh-my-zsh
$ sh -c "$(wget -O- https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
# change theme of oh-my-zsh
$ vim ~/.zshrc
--------------------
.zshrc
ZSH_THEME="ys"
--------------------
$ source ~/.zshrc
fish shell
# install fish and change default shell to fish
$ apt install fish
# open a web server for fish‘s config
$ fish_config
$ apt install ibus-rime
在设置 -> 区域与语言 -> 输入源 -> +,选择 rime 即可。# show the device and find the data disk, for example /dev/vdb
$ fdisk -l
# partition
$ fdisk /dev/vdb
# formating
$ mkfs.ext4 /dev/vdb1
# add the partition info into system
$ echo /dev/vdb1 /data ext4 defaults 0 0 >> /etc/fstab # you can change /data to other file such like /mnt
# mount
$ mount -a
# upload authorized_key file to the server.
$ scp local/path/of/authorized_keys root@server_address:/root/.ssh/
# modify the config
$ sudo vim /etc/ssh/sshd_config
--------------------
# sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
--------------------
# restart ssh service and test
$ sudo service ssh restart
# if system don‘t have ssh server, install it using
$ sudo apt install openssh-server
# disable password login
$ sudo vim /etc/ssh/sshd_config
--------------------
# sshd_config
PasswordAuthentication no
ChallengeResponseAuthentication no
--------------------
# restart ssh service and test
$ sudo service ssh restart
$ do-release-upgrade
# if you want to upgrade to the latest non-LTS develoment release,
# set Prompt=normal in /etc/update-manager/release-upgrades.
这里的编译环境主要是以 Cpp 和 Python 为主。
安装一些常用的软件
# git, wget, curl, unzip, vim
$ sudo apt install git wget curl unzip vim
# gcc g++ make ... cmake clang
$ sudo apt install build-essential cmake clang llvm
安装 IDE 如 CLion(付费),或者使用 Visual Studio Code + CMake/make。
安装需要的第三方库
原文:https://www.cnblogs.com/ixtwuko/p/linux-development-environment.html