Linux系统初始配置
使用系统版本
Ubuntu 24.04
说明:本文末尾提供了配置脚本的下载地址,可直接使用
Rocky 9.4版本
Rocky 9.4初始设置
详细配置步骤
1. 更换 Ubuntu 软件源为阿里云镜像
cat > /etc/apt/sources.list << eof
deb https://mirrors.aliyun.com/ubuntu/ noble main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-updates main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-backports main restricted universe multiverse
deb https://mirrors.aliyun.com/ubuntu/ noble-security main restricted universe multiverse
eof
2. 关闭防火墙
systemctl disable --now ufw
3. 配置 SSH 远程连接
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config #修改ssh可以远程连接
echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config # 开启密码验证
4. 安装 VM-tools
apt install -y open-vm-tools open-vm-tools-desktop
5. 安装命令补全工具
apt install bash-completion -y
6. 自定义命令提示符样式
echo "PS1='\[\e[1;33m\][\u@\h \w] \$\[\e[0m\]'" >> /root/.bashrc
7. 安装帮助手册
apt install -y man-pages
8. 配置中文环境
apt install -y language-pack-zh-hans manpages-zh
cat > /etc/locale.conf << eof
LANG=zh_CN.UTF-8
LC_ALL=zh_CN.UTF-8
eof
9. 配置 Vim 编辑器
cat >> /root/.vimrc << eof
colorscheme murphy
runtime! ftplugin/man.vim
if exists('*minpac#init')
" Minpac is loaded.
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'})
" Other plugins
call minpac#add('tpope/vim-eunuch')
call minpac#add('yegappan/mru')
call minpac#add('bujnlc8/vim-translator')
endif
if has('eval')
" Minpac commands
command! PackUpdate packadd minpac | source $MYVIMRC | call minpac#update('', {'do': 'call minpac#status()'})
command! PackClean packadd minpac | source $MYVIMRC | call minpac#clean()
command! PackStatus packadd minpac | source $MYVIMRC | call minpac#status()
endif
if !has('gui_running')
if has('wildmenu')
set wildmenu
set cpoptions-=<
set wildcharm=<C-Z>
nnoremap <F10> :emenu <C-Z>
inoremap <F10> <C-O>:emenu <C-Z>
endif
endif
let g:translator_cache=1
let g:translator_cache_path='~/.cache'
let g:translator_channel='baidu'
let g:translator_target_lang = 'zh'
let g:translator_source_lang = 'auto'
let g:translator_outputype='popup'
noremap <leader>tc :<C-u>Tc<CR>
vnoremap <leader>tv :<C-u>Tv<CR>
autocmd FileType man setlocal readonly
set expandtab " Tab 转换为空格
set tabstop=2 " 显示 Tab 为 2 空格
set shiftwidth=2 " 缩进用 2 空格
set smarttab " 行首按 Tab 时用 shiftwidth 缩进,其他位置按 tabstop
eof
配置脚本下载地址
- GitHub:https://raw.githubusercontent.com/szq770/linux/master/conf.sh
- Gitee:https://gitee.com/shizhi__qi/linux/raw/master/conf.sh
Ubuntu 24.04初始化配置指南
2040

被折叠的 条评论
为什么被折叠?



