A. 下载iso文件,制作启动U盘
aria2c -x 4 -s 12 "https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/24.04/ubuntu-24.04-desktop-amd64.iso" "https://mirrors.163.com/ubuntu-releases/24.04/ubuntu-24.04-desktop-amd64.iso" "https://mirrors.zju.edu.cn/ubuntu-releases/24.04/ubuntu-24.04-desktop-amd64.iso"
安装启动盘制作软件rufus47Please respect copyright.PENANA9XYr93oXT6
https://github.com/pbatard/rufus/releases/download/v4.5/rufus-4.5.exe47Please respect copyright.PENANA3i1Bspsdsy
U盘的容量必须大于7G,在rufus中选择U盘, iso文件,MBR分区类型,NTFS文件格式,点击开始,选择以ISO镜像模式写入。
官方参考资料:47Please respect copyright.PENANA3jeoStOwp2
https://ubuntu.com/tutorials/create-a-usb-stick-on-windows#1-overview
47Please respect copyright.PENANA3yNCc2HDTv
B. 安装ubuntu
从U盘启动电脑47Please respect copyright.PENANAVRXJuqQ6ZR
try or install ubuntu47Please respect copyright.PENANAbSnws5p8Kb
choose your language: english47Please respect copyright.PENANABjEqe97imO
accessibility in ubuntu: next47Please respect copyright.PENANATKhKFvrPCL
select your keyboard layout: english(US)47Please respect copyright.PENANAaWguSiRk56
connect to the internet: connect to a wi-fi network47Please respect copyright.PENANAonxgahBPxk
install ubuntu47Please respect copyright.PENANAPXmvw6nrwP
interactive installation47Please respect copyright.PENANAqt7nR6RxEs
extended selection47Please respect copyright.PENANAtKi5v3GOml
check: install third-party software for graphics and wi-fi hardware47Please respect copyright.PENANAQSspmeoSSz
check: download and install support for additional media formats47Please respect copyright.PENANAO67Ezvtabi
erase disk and install ubuntu47Please respect copyright.PENANAgRiE4O7KeC
choose sdb47Please respect copyright.PENANANmzXlZXHRn
your name: buda 47Please respect copyright.PENANAJptqGNd3RY
your computer's name: vultr47Please respect copyright.PENANAhvCNftwL5u
your username: buda 47Please respect copyright.PENANA3qMbxUqpzZ
timezone: shanghai47Please respect copyright.PENANAxX2t8Z3GSJ
install47Please respect copyright.PENANAAtMybcUFwh
restart now47Please respect copyright.PENANANp5vFFScX7
拔出U盘, 按enter键
47Please respect copyright.PENANAgbECATwMHV
C. 初始化設置
点击左下角ubuntu图标进入开始菜单,将terminal pin to dash47Please respect copyright.PENANAjYpTAeeftG
# sudo apt update && sudo apt upgrade -y
安装常用工具, 開發编译环境47Please respect copyright.PENANAUTvZbxzqE5
# sudo apt install nano net-tools build-essential gdb git glibc-source unzip openssl libssl-dev libzip-dev aria2 lsof47Please respect copyright.PENANABDpUrYbVdE
# cd /usr/src/glibc47Please respect copyright.PENANAxLF3Zz6vYf
# tar xvf glibc-2.39.tar.xz47Please respect copyright.PENANA884QsxLgh9
在gdb中指定glibc的源代碼:47Please respect copyright.PENANAOFfz0wagZj
gdb> directory /usr/src/glibc/glibc-2.39
將用戶加入root組47Please respect copyright.PENANA7Ccvs7bXfp
# usermod -a -G root buda47Please respect copyright.PENANAsdlDthPdOg
# groups buda
黑屏时间设置:15分钟无操作后黑屏47Please respect copyright.PENANAFcWcCzrDMm
点左下角进入开始菜单, search "power", click " (settings) Power" blank screen: 15 mins
apt search rethinkdb47Please respect copyright.PENANANlHiC1QCRW
apt show rethinkdb47Please respect copyright.PENANAEY2ckA4w9c
apt remove rethinkdb47Please respect copyright.PENANAUZGFLzqXO1
cd /etc/apt/sources.list.d/ #进入PPA源文件所在目录47Please respect copyright.PENANAR0w9WNwF0m
sudo rm XXX.list #删除一个PPA源list文件47Please respect copyright.PENANA482zySG6mM
sudo apt update
47Please respect copyright.PENANAp8CsC2tXNw
D. 安裝中文輸入法rime
# sudo apt install ibus-rime rime-data-luna-pinyin47Please respect copyright.PENANAvkdTq8h6Nc
点击左下角进入开始菜单,选择settings, keyboard,+ add input source...,others, chinese(rime)47Please respect copyright.PENANAmWI80O7NVP
点击chinese(rime)右边的小竖点,move up,将chinese(rime)移到Input Sources列表的第一行47Please respect copyright.PENANAeySUbAhu0J
编辑配置文件47Please respect copyright.PENANAnYvBLsHcGV
一次显示9个候选词、模糊音47Please respect copyright.PENANAbJB87ZFWnB
# nano ~/.config/ibus/rime/default.custom.yaml47Please respect copyright.PENANAStfzbK1xP2
---------default.custom.yaml的内容如下-----------47Please respect copyright.PENANAcEqbVQouyl
patch:47Please respect copyright.PENANAEAPvosCd3X
"menu/page_size": 9
'speller/algebra':47Please respect copyright.PENANAtt2zzcVfzP
- erase/^xx$/ # 第一行保留
# 模糊音定義47Please respect copyright.PENANALVnI0qIJJn
- derive/^([zcs])h/$1/ # zh, ch, sh => z, c, s47Please respect copyright.PENANAIQ0Ou9DpMg
- derive/^([zcs])([^h])/$1h$2/ # z, c, s => zh, ch, sh
- derive/^n/l/ # n => l47Please respect copyright.PENANAivSPovacka
- derive/^l/n/ # l => n
- derive/([ei])n$/$1ng/ # en => eng, in => ing47Please respect copyright.PENANAMwJuHSGpyz
- derive/([ei])ng$/$1n/ # eng => en, ing => in47Please respect copyright.PENANAodMHDLZd4u
--------------------------------------------------------------47Please respect copyright.PENANA1bVmtRfoAH
为了使模糊音生效,拷贝配置文件47Please respect copyright.PENANAeUt0G7Bmyu
# cp default.custom.yaml luna_pinyin_simp.custom.yaml && cp default.custom.yaml luna_pinyin.custom.yaml47Please respect copyright.PENANAq71moKgMJb
部署rime输入法:47Please respect copyright.PENANAkyDFyjUK79
# ibus restart47Please respect copyright.PENANACbknC3gmCp
# ibus engine rime47Please respect copyright.PENANAshOJ04o9VG
在输入时按F4或者Ctrl+\`可弹出菜单,选择菜单上的数字可进行简繁输入转换47Please respect copyright.PENANAydlsXLDLUQ
按shift键进行中英输入转换47Please respect copyright.PENANAaD6XMTLCHJ
有时候输入法失效时,可以重新运行一下部署rime的命令
参考资料:47Please respect copyright.PENANAJA8XuNjwDe
CustomizationGuide · rime/home Wiki · GitHub47Please respect copyright.PENANASIoU8qCW4e
https://www.cnblogs.com/keatonlao/p/12983158.html
47Please respect copyright.PENANAgbXVKTLQum
E. 安裝重要軟件
从code官网下载deb包,然后安装47Please respect copyright.PENANAquaEP25q06
# sudo apt install ./code_1.90.0-1717531825_amd64.deb
gimp图片编辑器, chromium浏览器47Please respect copyright.PENANAWTlXmATLQv
从app center安装
墙内安装node/npm47Please respect copyright.PENANAPKV194JEwj
https://nodejs.org/en/ 下载LTS版本47Please respect copyright.PENANAlV37LDUIVB
# cd ~/Downloads47Please respect copyright.PENANA5Fgr3pMXFO
# wget https://nodejs.org/dist/v20.15.0/node-v20.15.0-linux-x64.tar.xz47Please respect copyright.PENANA74mquVjzfC
# tar --strip-components 1 -xvf node-v20.15.0-linux-x64.tar.xz -C /usr/local47Please respect copyright.PENANA10RwecUNR3
# node -v47Please respect copyright.PENANAoRRSbvZLSb
# npm install npm@latest -g47Please respect copyright.PENANAahSnyCFI42
# npm config get registry47Please respect copyright.PENANAJlwAAjGnuD
# npm config set registry https://registry.npmmirror.com47Please respect copyright.PENANAKoni0GFuU2
如果想用回官方registry:47Please respect copyright.PENANAX9cRaT78hz
# npm config set registry https://registry.npmjs.org
墙外安装node/npm47Please respect copyright.PENANA6tCNbUUxf2
# curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash47Please respect copyright.PENANAlk4NwrFNVD
# export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"47Please respect copyright.PENANAiRXBEqfHoF
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm47Please respect copyright.PENANAkYeRE4sAiX
# nvm install --lts47Please respect copyright.PENANAewgesDHDhN
# npm install npm@latest -g
安装47Please respect copyright.PENANAlPljSYDyLH
npm i package_name47Please respect copyright.PENANAzBOVi0C4LZ
项目更新47Please respect copyright.PENANAthi1A4f6Ga
npm update
F. 配置服務器連接
1. ssh免密登录Linux服务器
在客户端检查是否存在证书47Please respect copyright.PENANANmgjgePDOV
# ls -al ~/.ssh/id_*.pub47Please respect copyright.PENANAtbN26mAt21
如果不存在,生成证书47Please respect copyright.PENANA8nKg9HJQ7U
# ssh-keygen -t rsa -b 4096 -C "jinmin.si@outlook.com"47Please respect copyright.PENANAx9kDObw9S8
生成证书的过程中使用空白的 passphrase47Please respect copyright.PENANA5WQAJ2r1GM
将证书拷贝到服务器47Please respect copyright.PENANAytMB9yyo4C
# ssh-copy-id root@server
2. 从windows登录linux
如果是从windows系统连接ubuntu,可以安装putty作为访问服务器的终端。 47Please respect copyright.PENANAICAt9QfP5p
下载putty: https://www.putty.org/
putty免密登录Linux服务器的方法
在putty的安装目录找到puttygen.exe,运行生成ssl私钥和公钥,保存私钥到文件,复制公钥。47Please respect copyright.PENANA8X9CI0T0ux
在putty的 connection/data 设置登录用户名为root,connection/ssh/auth/credentials中设置私钥的文件,保存设置。47Please respect copyright.PENANAWjXp0z0U7u
将公钥写入服务器的 ~/.ssh/authorized_keys 文件中, reboot ubuntu使修改生效47Please respect copyright.PENANAt3AfSdybCa
# nano ~/.ssh/authorized_keys47Please respect copyright.PENANAXPK1SI9VUQ
# reboot
如果想保持putty与服务器的连接保持不断线,可以在Putty中设置每隔一定的时间发一次心跳消息。
3. 保持与服务器的ssh连接不断线的方法
ssh连接服务器时如果容易断线,可以修改服务器sshd的设置,保持ssh连接不断线:47Please respect copyright.PENANAF4l0KHlJTj
# nano /etc/ssh/sshd_config47Please respect copyright.PENANAuwozkvGVWK
ClientAliveInterval 60 # 表示每60秒发送一次请求,从而保持连接不断线。47Please respect copyright.PENANA7R1zXEjeUJ
ClientAliveCountMax 10 # 表示服务器发出请求后客户端没有响应的次数达到10次,就自动断开连接47Please respect copyright.PENANAJGQvrZ2Lfz
# systemctl restart sshd
4. 從ubuntu remote windows用remmina
從app中心安裝remmina47Please respect copyright.PENANAHk9PrRJC3z
新建connection到windows
Basic標籤47Please respect copyright.PENANAlyAtC9u8Pg
server: ip/domain.name, username: Administrator, password: ***47Please respect copyright.PENANAYaf4xPq8EC
share folder中填寫ubuntu中的路徑,則可從windows訪問47Please respect copyright.PENANAvX1EzY3R22
resolution中可設置合適的屏幕大小
Advanced標籤47Please respect copyright.PENANAb6eeKePldx
output audio: 選擇local,則是windows發出的聲音
windows server 默認是麼有開啓聲音服務的,要設置一下才能發出聲音:47Please respect copyright.PENANAtXd469rz8Y
https://cloud.tencent.com/developer/article/1894933
G. 網絡安全設置
防火墙设置47Please respect copyright.PENANAqf2niITquk
# ufw allow 2247Please respect copyright.PENANAWVyq5X234W
# ufw allow 8047Please respect copyright.PENANA2BzQiApI2x
# ufw allow 44347Please respect copyright.PENANA2CKnPMavFW
# ufw enable47Please respect copyright.PENANAOwav67fOio
# ufw status
H. 常用命令
创建软链接47Please respect copyright.PENANAtAyPXhAR5a
# sudo ln -s 源文件 目标文件
修改密码47Please respect copyright.PENANAh84hChXMts
# passwd root47Please respect copyright.PENANAeTJoXcihHM
# usermod -a -G groupA username47Please respect copyright.PENANA2ecnoliG6W
# groups username
修改hostname47Please respect copyright.PENANArHYPRE2Qji
# hostnamectl set-hostname xiaoyue
查看cpu47Please respect copyright.PENANA8AnZFwCzEm
# lscpu
查看内存47Please respect copyright.PENANAHkl25bdASw
# free -h47Please respect copyright.PENANAjKRnf54wKH
# top
釋放被buff/cache占用的内存47Please respect copyright.PENANAg3xStEsed2
# sync; echo 3 > /proc/sys/vm/drop_caches # 清空页面缓存47Please respect copyright.PENANA6qdXxzOwtn
# sync; echo 1 > /proc/sys/vm/drop_caches # 清空目录项缓存47Please respect copyright.PENANAbErnN0mSVG
# sync; echo 2 > /proc/sys/vm/drop_caches # 清空SLAB缓存47Please respect copyright.PENANAKYvlTundUS
# sync; echo 3 > /proc/sys/vm/drop_caches # 清空所有缓存47Please respect copyright.PENANACVjMDmxeNU
用sudo执行:47Please respect copyright.PENANABMT4GHtHAy
# sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
47Please respect copyright.PENANA9A6qJzWuxz
查看硬盘47Please respect copyright.PENANAdTF69vk4fb
# sudo lshw -c disk47Please respect copyright.PENANANYrT93yyzJ
查看分区47Please respect copyright.PENANAM5dB9V4Uia
# sudo fdisk -l47Please respect copyright.PENANAQQ2epFjLVc
查看磁盘剩余空间47Please respect copyright.PENANAhWdo4326fN
# df -hl
文件壓縮和打包47Please respect copyright.PENANAfcwKluiuIE
將在windows上壓縮出的zip文件傳遞給Linux系統解壓縮時,文件名會出現亂碼,這是因爲在Windows上文件名的編碼取決於「控制面板-時鐘和區域-區域-管理-非unicode程序語言」中的設置,中國大陸默認是簡體中文,gb2312(cp936)編碼. 而在Linux系統上則統一是utf-8編碼。47Please respect copyright.PENANAKkosm0hKKu
如何解決?最簡單的辦法是在解壓縮的時候說明一下原來的編碼,這樣壓縮工具就會識別出原來的文件名而自動將文件名轉爲utf8編碼, 命令如下:47Please respect copyright.PENANAV3vZXfMSTk
unzip -O cp936 temp.zip
改變文件權限47Please respect copyright.PENANA7ICGeV9GYe
# chmod g+w <文件/目录路径>47Please respect copyright.PENANAwFhq6JxvOD
# chmod -R g+w /path/to/directory47Please respect copyright.PENANAbz7ETUujxk
设置所有者为 rwx,组为 r-x,其他用户为 r--:47Please respect copyright.PENANA7nfV25snFg
# chmod 755 <文件/目录路径>
u:所有者(user)。47Please respect copyright.PENANALx4DkSLd9C
g:所属组(group)。47Please respect copyright.PENANAUehSJ2MgAJ
o:其他用户(others)。47Please respect copyright.PENANA8mEU38qHMw
a:所有用户(u、g、o)。47Please respect copyright.PENANAWcm8Em1636
操作符:47Please respect copyright.PENANA7V36UVFy9s
+:添加权限。47Please respect copyright.PENANAvu2FtAbikE
-:移除权限。47Please respect copyright.PENANAE1fFaRuZP6
=:设置权限。47Please respect copyright.PENANAlPOwG1mV5w
權限:47Please respect copyright.PENANA7YXo8rJUE7
r(读) = 447Please respect copyright.PENANANzG8WQBBV6
w(写) = 247Please respect copyright.PENANA7iFdRqiZMV
x(执行) = 147Please respect copyright.PENANAN6asDGFsb2
-(无权限) = 047Please respect copyright.PENANACSO7M9D64X
通过加法得到最终的权限值。例如:47Please respect copyright.PENANAHqrCYIZmr3
7 = rwx(4 + 2 + 1)47Please respect copyright.PENANAtuHhU3Uufd
5 = r-x(4 + 1)47Please respect copyright.PENANARa9HCs5Sj2
6 = rw-(4 + 2)47Please respect copyright.PENANAwvMPkifjHe
47Please respect copyright.PENANAimqRNhAGsI
I. 创建自定义命令
# nano ~/.bash_aliases47Please respect copyright.PENANAoFi1CRj2Cn
添加alias, 比如:47Please respect copyright.PENANANBTV2dl6mm
alias gitbuda='gitbuda() { git add -A; git commit -m "$1"; git push; }; gitbuda'47Please respect copyright.PENANAeh2HQBH2Qk
其中$1表示命令的第一个参数,这样就可以用 gitbuda "commit message"来运行命令47Please respect copyright.PENANAWVFAWLcJRf
# source ~/.bash_aliases
Section X. Thanks
https://ubuntu.com
47Please respect copyright.PENANAIduIK4JCPj
Section Y. Contacts Me
If you found any errors or have any suggestions for this article, please let me know, my wechat: si_jinmin, my email: si.jinmin@gmail.com47Please respect copyright.PENANAWzE0WCY351
如果您发现本文有任何错误,或者对本文有好的建议,欢迎与我联系探讨,我的微信: si_jinmin, 我的email: si.jinmin@gmail.com
如果您對C/C++ programming, Linux, website development, Vue, Git, vscode感興趣,邀請您加入「Linux/C/C++ Website Development」微信群,請加我的微信(si_jinmin)以便拉您进群。
ns 15.158.61.48da2