Ubuntu:修订间差异
跳到导航
跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
(→安裝) |
(→總結) |
||
(未显示同一用户的76个中间版本) | |||
第1行: | 第1行: | ||
'''Ubuntu'''是一種[[Linux]]作業系統。 | '''Ubuntu'''是一種[[Linux]]作業系統。 | ||
== 移除 == | |||
目前社群的建議都是先移除掉Snap: | |||
<syntaxhighlight lang="bash"> | |||
sudo apt purge -y snapd; sudo apt autoremove --purge -y; sudo apt clean | |||
</syntaxhighlight> | |||
並且移除掉Ubuntu Pro的廣告: | |||
<syntaxhighlight lang="bash"> | |||
sudo systemctl disable apt-news.service; sudo systemctl disable esm-cache.service; sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak | |||
</syntaxhighlight> | |||
== 安裝 == | == 安裝 == | ||
=== apt === | === apt === | ||
先更新系統的套件庫以及系統: | |||
<syntaxhighlight lang="bash"> | |||
sudo apt update; sudo apt upgrade -y | |||
</syntaxhighlight> | |||
這邊列出常用的套件: | 這邊列出常用的套件: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo apt install -y apache2-utils build-essential curl dstat git jq moreutils most mtr-tiny net-tools p7zip-full pigz rsync sharutils software-properties-common sysstat unrar unzip vim-nox wget | sudo apt install -y apache2-utils apt-transport-https aptitude bash-completion bpfcc-tools build-essential curl dnsutils dstat git jc jq locales moreutils most mtr-tiny net-tools netcat-openbsd p7zip-full pigz prometheus-node-exporter rsync sharutils software-properties-common sysstat telnet ubuntu-minimal unrar unzip vim-nox wget zstd; sudo apt clean | ||
</syntaxhighlight> | |||
另外建議每台機器都把除錯用的套件裝起來,遇到狀況時可以馬上處理<ref>{{Cite web |url=https://blog.gslin.org/archives/2024/03/25/11715/brendan-gregg-%e6%8e%a8%e8%96%a6%e5%b9%b3%e5%b8%b8%e5%9c%a8-linux-%e4%b8%8a%e5%85%88%e8%a3%9d%e5%a5%bd%e7%9a%84%e5%b7%a5%e5%85%b7/ |title=Brendan Gregg 推薦平常在 Linux 上先裝好的工具 |language=zh-tw |accessdate=2024-03-25 |date=2024-03-25}}</ref>: | |||
<syntaxhighlight lang="bash"> | |||
sudo apt install -y bpfcc-tools bpftrace cpuid ethtool gdb iproute2 linux-tools-common msr-tools nicstat numactl procps sysstat tcpdump tiptop trace-cmd util-linux; sudo apt clean | |||
</syntaxhighlight> | </syntaxhighlight> | ||
第14行: | 第40行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo apt install -y keychain mosh; sudo apt clean | sudo apt install -y byobu keychain mosh zsh zsh-syntax-highlighting; sudo apt clean | ||
</syntaxhighlight> | |||
開發機可以裝這些,要注意這邊裝的是系統的版本,可能會偏舊: | |||
<syntaxhighlight lang="bash"> | |||
sudo apt install -y build-essential bison byobu cmake cvs debhelper default-jdk devscripts git-flow golang mercurial nasm python3-minimal subversion tig; sudo apt clean | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 設定 == | == 設定 == | ||
有些機器沒有對應的locale,可以讓系統產生: | |||
<syntaxhighlight lang="bash"> | |||
sudo locale-gen en_US.UTF-8 zh_TW.UTF-8 | |||
</syntaxhighlight> | |||
在VPS或是雲端上的機器通常會利用swapfile增加一些記憶體使用空間: | 在VPS或是雲端上的機器通常會利用swapfile增加一些記憶體使用空間: | ||
第23行: | 第61行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
sudo fallocate -l 512M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | sudo fallocate -l 512M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab | ||
</syntaxhighlight> | |||
但還是要避免使用到Swap: | |||
<syntaxhighlight lang="bash"> | |||
echo "vm.swappiness=1" | sudo tee /etc/sysctl.d/99-vm.conf; sudo sysctl -p /etc/sysctl.d/99-vm.conf | |||
</syntaxhighlight> | </syntaxhighlight> | ||
第29行: | 第73行: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
echo -e "net.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf | echo -e "net.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf | ||
</syntaxhighlight> | |||
如果無法使用TCP BBR,可以改用Westwood: | |||
<syntaxhighlight lang="bash"> | |||
echo -e "net.ipv4.tcp_congestion_control=westwood" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== 使用者 == | == 使用者 == | ||
這邊是增加我自己的帳號(以及[[Sudo]]權限),然後設定密碼: | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
echo "gslin ALL = (ALL:ALL) NOPASSWD: ALL" | tee /etc/sudoers.d/gslin; sudo useradd -g staff -G adm,sudo -m -s /bin/ | echo "gslin ALL = (ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/gslin; sudo useradd -g staff -G adm,sudo -m -s /bin/bash gslin; sudo passwd gslin | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== 總結 == | |||
一般性的快速安裝: | |||
<syntaxhighlight lang="bash"> | |||
sudo fallocate -l 512M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab; echo "vm.swappiness=1" | sudo tee /etc/sysctl.d/99-vm.conf; sudo sysctl -p /etc/sysctl.d/99-vm.conf; echo -e "net.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf; sudo apt purge -y snapd; sudo systemctl disable apt-news.service; sudo systemctl disable esm-cache.service; sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak; sudo apt update; sudo apt dist-upgrade -y; sudo apt install -y apache2-utils apt-transport-https aptitude bash-completion bpfcc-tools bpfcc-tools bpftrace build-essential cpuid curl dnsutils dstat ethtool gdb git iproute2 jc jq linux-tools-common locales moreutils most msr-tools mtr-tiny net-tools netcat-openbsd nicstat numactl p7zip-full pigz procps prometheus-node-exporter rsync sharutils software-properties-common sysstat sysstat tcpdump telnet tig tiptop trace-cmd ubuntu-minimal unrar unzip util-linux vim-nox wget zstd; sudo apt autoremove --purge -y; sudo apt clean; sudo locale-gen en_US.UTF-8 zh_TW.UTF-8 | |||
</syntaxhighlight> | |||
伺服器的部分可以停掉自動更新: | |||
<syntaxhighlight lang="bash"> | |||
sudo apt purge -y unattended-upgrades; sudo systemctl disable apt-daily.timer; sudo systemctl disable --now packagekit.service | |||
</syntaxhighlight> | |||
== 參考文獻 == | |||
{{Reflist|2}} | |||
== 外部連結 == | == 外部連結 == | ||
* {{Official|https://www.ubuntu.com/}} | |||
* {{Official|https://www.ubuntu.com/}} {{en}} | |||
[[Category:軟體]] | [[Category:軟體]] |
2024年5月4日 (六) 21:50的版本
Ubuntu是一种Linux作业系统。
移除
目前社群的建议都是先移除掉Snap:
sudo apt purge -y snapd; sudo apt autoremove --purge -y; sudo apt clean
并且移除掉Ubuntu Pro的广告:
sudo systemctl disable apt-news.service; sudo systemctl disable esm-cache.service; sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak
安装
apt
先更新系统的套件库以及系统:
sudo apt update; sudo apt upgrade -y
这边列出常用的套件:
sudo apt install -y apache2-utils apt-transport-https aptitude bash-completion bpfcc-tools build-essential curl dnsutils dstat git jc jq locales moreutils most mtr-tiny net-tools netcat-openbsd p7zip-full pigz prometheus-node-exporter rsync sharutils software-properties-common sysstat telnet ubuntu-minimal unrar unzip vim-nox wget zstd; sudo apt clean
另外建议每台机器都把除错用的套件装起来,遇到状况时可以马上处理[1]:
sudo apt install -y bpfcc-tools bpftrace cpuid ethtool gdb iproute2 linux-tools-common msr-tools nicstat numactl procps sysstat tcpdump tiptop trace-cmd util-linux; sudo apt clean
跳板机会多装这些:
sudo apt install -y byobu keychain mosh zsh zsh-syntax-highlighting; sudo apt clean
开发机可以装这些,要注意这边装的是系统的版本,可能会偏旧:
sudo apt install -y build-essential bison byobu cmake cvs debhelper default-jdk devscripts git-flow golang mercurial nasm python3-minimal subversion tig; sudo apt clean
设定
有些机器没有对应的locale,可以让系统产生:
sudo locale-gen en_US.UTF-8 zh_TW.UTF-8
在VPS或是云端上的机器通常会利用swapfile增加一些记忆体使用空间:
sudo fallocate -l 512M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
但还是要避免使用到Swap:
echo "vm.swappiness=1" | sudo tee /etc/sysctl.d/99-vm.conf; sudo sysctl -p /etc/sysctl.d/99-vm.conf
然后设定TCP BBR,需要Linux Kernel 4.9+(如果是Ubuntu 16.04,预设是4.4,会需要安装linux-image-generic-hwe-16.04
):
echo -e "net.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf
如果无法使用TCP BBR,可以改用Westwood:
echo -e "net.ipv4.tcp_congestion_control=westwood" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf
使用者
这边是增加我自己的帐号(以及Sudo权限),然后设定密码:
echo "gslin ALL = (ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/gslin; sudo useradd -g staff -G adm,sudo -m -s /bin/bash gslin; sudo passwd gslin
总结
一般性的快速安装:
sudo fallocate -l 512M /swapfile; sudo chmod 600 /swapfile; sudo mkswap /swapfile; sudo swapon /swapfile; echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab; echo "vm.swappiness=1" | sudo tee /etc/sysctl.d/99-vm.conf; sudo sysctl -p /etc/sysctl.d/99-vm.conf; echo -e "net.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr" | sudo tee /etc/sysctl.d/99-tcp.conf; sudo sysctl -p /etc/sysctl.d/99-tcp.conf; sudo apt purge -y snapd; sudo systemctl disable apt-news.service; sudo systemctl disable esm-cache.service; sudo mv /etc/apt/apt.conf.d/20apt-esm-hook.conf /etc/apt/apt.conf.d/20apt-esm-hook.conf.bak; sudo apt update; sudo apt dist-upgrade -y; sudo apt install -y apache2-utils apt-transport-https aptitude bash-completion bpfcc-tools bpfcc-tools bpftrace build-essential cpuid curl dnsutils dstat ethtool gdb git iproute2 jc jq linux-tools-common locales moreutils most msr-tools mtr-tiny net-tools netcat-openbsd nicstat numactl p7zip-full pigz procps prometheus-node-exporter rsync sharutils software-properties-common sysstat sysstat tcpdump telnet tig tiptop trace-cmd ubuntu-minimal unrar unzip util-linux vim-nox wget zstd; sudo apt autoremove --purge -y; sudo apt clean; sudo locale-gen en_US.UTF-8 zh_TW.UTF-8
伺服器的部分可以停掉自动更新:
sudo apt purge -y unattended-upgrades; sudo systemctl disable apt-daily.timer; sudo systemctl disable --now packagekit.service
参考文献
- ↑ Brendan Gregg 推荐平常在 Linux 上先装好的工具. 2024-03-25 [2024-03-25] (中文(台湾)).
外部连结
- 官方网站 (英文)