How to Set Up on A New Machine
How to set up configs on a brand new machine (typically a ubuntu server).
For the usage of most of the rust tools, see my Unix CLI Tools.
My dotfiles are save in:
1 | https://github.com/LYK-love/dotfiles-for-servers |
Prerequisites: Set up SSH
You need to set up your ssh first.
Local -> Remote
Now we config the capability of connecting the server from one's local machine.
On your local machine, run:
1 | ssh-copy-id user@host |
where user
is your user account name on the remote server, and host
is the hostname or ip address of the remote server.
Or you can copy your ssh public key id_rsa.pub
of your local machine to ~/.ssh/authorized_keys
of the remote server.
Remote -> Github
Generate ssh key on the server:
1
ssh-keygen -t rsa
Look at
~/.ssh
:1
2
3
4
5
6
7❯ ls -l ~/.ssh
total 20
-rw-r--r-- 1 lyk lyk 27 2月 10 15:44 config
-rw------- 1 lyk lyk 2602 2月 9 17:18 id_rsa
-rw-r--r-- 1 lyk lyk 571 2月 9 17:18 id_rsa.pub
-rw------- 1 lyk lyk 3926 2月 19 12:58 known_hosts
-rw------- 1 lyk lyk 3182 2月 19 12:41 known_hosts.oldCopy the content of
id_rsa.pub
, i.e., the public key of this user, to the Github.The content can be got by
1
cat ~/.ssh/id_rsa.pub
Prerequisite: Softwares
Then, you need to install following softwares.
zsh
Install zsh:
1
sudo apt install zsh
By default, zsh will use
~/.zshrc
as config file.Switch your shell to zsh:
1
chsh -s /bin/zsh
Now log out and log in back to enable zsh. You will see:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19This is the Z Shell configuration function for new users,
zsh-newuser-install.
You are seeing this message because you have no zsh startup files
(the files .zshenv, .zprofile, .zshrc, .zlogin in the directory
~). This function can help you with a few settings that should
make your use of the shell easier.
You can:
(q) Quit and do nothing. The function will be run again next time.
(0) Exit, creating the file ~/.zshrc containing just a comment.
That will prevent this function being run again.
(1) Continue to the main menu.
(2) Populate your ~/.zshrc with the configuration recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).Just type
q
, since we want to use my own zsh config.Now you can see
1
2> echo $SHELL
/bin/zshMove to next section to install and config Oh-my-zsh.
Oh-my-zsh
Install it via -->repo:
1 | sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" |
- If you want to uninstall
oh-my-zsh
, just rununinstall_oh_my_zsh
from the command-line. It will remove itself and revert your previousbash
orzsh
configuration. (-->Source)
Then install Zsh plugins:
zsh-autosuggestions:
1
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
p10k
The official github repo of p10k is here.
Now we install p10k
, a theme of Oh-my-zsh.
1 | git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k |
After installation, you will see an interactive window to configure p10k. Since we will use my own config, and I already have one config file for p10k
, we can just skip this step.
In the future, you can change the config of p10k
manually with:
1 | p10k configure |
neovim
You may install neovim via sudo apt install neovim
. However, the neovim installed through this method is very old due to the slow updates of the official package source.
Therefore, in order to install the latest neovim, which is a must to use NvChad (need neovim>0.9.4), you can install neovim via:
- Neovim official github repo.
- Or use some PPA repository since it gets updated more often (-->).
For method 2, you should
Add unstable ppa repository:
1
sudo add-apt-repository ppa:neovim-ppa/unstable
If you wish to install the stable version of the PPA. Enter the command below in the terminal, the rest of the procedure is the same.
1
sudo add-apt-repository ppa:neovim-ppa/stable
The command above will ask you to confirm you want to add the unstable/stable PPA to the local package database. Press enter. This should update the local package database, but if it does not, then you will need to do it manually. We can do this by entering the command below.
1
sudo apt update
Time to do the thing. The command below will install Neovim.
1
sudo apt install neovim
NvChad
--> NvChad Installation Doc
1 | git clone https://github.com/NvChad/starter ~/.config/nvim && nvim |
openssh (if you don't have one)
openssh-server
is installed by default in many distros, you can check its installation via:
1 | sudo lsof -i :22 |
If no process is listening to port=22, then the openssh is not enabled or enven not installed.
Below is the instructions to install and enable it:
First, upate all softwares
1
sudo apt update
Install
openssh-server
:1
sudo apt install openssh-server
Verify OpenSSH Server Installation:
1
sudo systemctl status ssh
This command will show the current status of the SSH service. It should be active (running).
If the SSH service is not running, you can start it with:
1 | sudo systemctl start ssh |
If you want the SSH server to start automatically when your system boots, use:
1 | sudo systemctl enable ssh |
cargo
Run the command to download the
rustup
tool and install the latest stable version of Rust:1
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh
Next, run the following command to add the Rust toolchain directory to the PATH environment variable:
1
source $HOME/.cargo/env
Verify the Rust installation by requesting the version:
1
rustc --version
If you don't have a
gcc
, please install one.
Now rust and corresponding tools (rustup, cargo) have been installed
zellij
You must install cargo first in order to install Zellij.
1 | cargo install --locked zellij |
The installation of Zellij is a little bit slow.
yadm
yadm is a dotfile manaegr.
1 | sudo apt-get update |
zoxide
zoxide:
Install it.
1
cargo install zoxide --locked
Remove the completions cache of my zsh:
1
rm ~/.zcompdump*; compinit
(You should skip this since I have already done it.) Then, add this line to
~/.zshrc
file:1
eval "$(zoxide init zsh)"
Install fzf:
1
sudo apt install fzf
eza
1 | cargo install eza |
atuin
Install it:
1 | cargo install atuin |
The config of atuin has already been done in my config files. So you don't need to do anything else now.
Others
Useful unix tools:
-
1
cargo install ripgrep
btm:
1
cargo install bottom --locked
procs:
1
cargo install procs
dua: Disk Usage Analyzer
1
cargo install dua-cli
tealdeer:
1
cargo install tealdeer
hyperfine:
1
cargo install hyperfine
Tokei:
1
cargo install tokei
git-lfs
is essential for downloading repos in Hugginface.1
2sudo apt-get install git-lfs
git-lfs install
Set up terminal on a new machine
In this section we use my dotfiles to config:
- zsh
- Oh-my-zsh
- powerlevel10k
- NvChad
- Zellij
For forther customization, please refer to:
Remove original config files, if any, in your computer.
1
2
3
4rm ~/.zshrc # zsh
rm ~/.p10k.zsh
rm -rf ~/.config/nvim/lua/custom # NvChad
rm -rf ~/.config/zellijClone my dotfiles
1
2
3cd $HOME
yadm clone [email protected]:LYK-love/dotfiles-for-servers.git
yadm submodule update --init --recursiveThis will clone all the files in the repo to my
$HOME
.I use parameter
--recurse-submodules
because my NvChad dotfile, which is a distinct public repo, is added as a git submodule:1
2
3
4# In `.gitmodules`
[submodule "NvChad-custom-file"]
path = NvChad-custom-file
url = [email protected]:LYK-love/NvChad-custom-file.gitSee my dotfiles managed by
yadm
:1
yadm list -a
Source the zsh config file in my dotfiles, in order to enable some env variables.
1
source ~/zsh/.zshrc
You will see the config process of
p10k
again. Just quit it since I already have had my own config.Now you can check some env variables I set:
1
2
3
4
5
6
7
8
9
10
11> echo $DOT_FILE_HOME
/home/lyk/
> echo $ZSH_DOT_FILE_HOME
/home/lyk/zsh
> echo $NVIM_CUSTOM_HOME
/home/lyk/nvchad_custom
> echo $ZELLIJ_CONFIG_FILE
/home/lyk/zellij/config.kdlNow set the config files as the cooresponding ones in my dotfiles:
1
2
3
4
5ln -s $ZSH_DOT_FILE_HOME/.zshrc ~/.zshrc # zsh
ln -s $ZSH_DOT_FILE_HOME/.p10k.zsh ~/.p10k.zsh # p10k, the theme of oh-my-zsh.
ln -s $NVIM_CUSTOM_HOME/ ~/.config/nvim/lua/custom # NvChad
mkdir ~/.config/zellij # Zellij
ln -s $ZELLIJ_CONFIG_FILE ~/.config/zellij/After that, zsh, nvchad and Zellij should be correctly configured. Zsh plugins are enabled as well.
To enable the plugins of NvChad, in Nvim, type:
1
:MasonInstallAll
Set up other CLI tools.
For Atuin, start the sync server Offline (no sync):
1
2
3bash <(curl https://raw.githubusercontent.com/atuinsh/atuin/main/install.sh)
atuin import auto
Set up conda
--> Install Miniconda
For Linux:
These four commands quickly and quietly install the latest 64-bit version of the installer and then clean up after themselves. To install a different version or architecture of Miniconda for Linux, change the name of the .sh
installer in the wget
command.
1 | mkdir -p ~/miniconda3 |
After installing, initialize your newly-installed Miniconda. The following commands initialize for bash and zsh shells:
1 | ~/miniconda3/bin/conda init bash |
Set up CUDA, PyTorch, Jax
See:
Set up docker
See:
After installing Dokcer, it is recommended to install lazydocker as well:
1 | curl https://raw.githubusercontent.com/jesseduffield/lazydocker/master/scripts/install_update_linux.sh | bash |
The PATH
variable and the alias have been set in my ~/.zshrc
, so you don't need to set them again.
Add another user
Say the new username is lyk
Add user
1
sudo adduser lyk
Give the new user
sudo
permission:1
2sudo usermod -a -G adm lyk
sudo usermod -a -G sudo lykSwitch to the new user:
1
su - lyk