Ubuntu(linux)基础教程
2022年5月24日大约 4 分钟约 1212 字
系统发行版查询
# 查询操作系统版本
uname -a
cat /etc/issue
lsb_release -a
cat /etc/debian_version # 查询debian版本("sid"代表开发版或不稳定版,别名"unstable")
# 查询内核信息
cat /proc/version修改基础配置
# 修改主机名
sudo hostnamectl set-hostname "new-hostname"
cat /etc/hostname
reboot
# 修改root密码
sudo passwd root
# 修改网络配置(ip、dns、网关)
ls /etc/netplan/
vim /etc/netplan/50-cloud-init.yaml
netplan apply
dig
ip a
# 其他配置
sudo ln -s /usr/bin/python3 /usr/bin/python
# sudo 免密码
sudo visudo
# 本用户是属于sudo组的,直接修改sudo组即可。
%sudo ALL=(ALL:ALL) NOPASSWD:ALL
# Ctrl+x, y, Enter
# 时区配置
sudo timedatectl set-timezone Asia/Shanghai更新Ubuntu软件源
sudo sed -i 's@//.*archive.ubuntu.com@//mirrors.ustc.edu.cn@g' /etc/apt/sources.list.d/ubuntu.sources
sudo sed -i 's/http:/https:/g' /etc/apt/sources.list.d/ubuntu.sources # 使用https避免运营商缓存劫持
sudo sed -i 's/security.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list.d/ubuntu.sources # 替换 security 源
cat /etc/apt/sources.list.d/ubuntu.sources
sudo apt update && sudo apt upgrade -yhttps://mirrors.ustc.edu.cn/help/ubuntu.html
基础软件安装
sudo apt install python3-pip vim git -y
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
git config --global user.name "xionglilong"
git config --global user.email "xionglilong@vip.qq.com"ssh服务配置
apt update
apt install openssh-server
vim /etc/ssh/sshd_config
Port 19022
PermitRootLogin yes # 允许root登录
PasswordAuthentication yes # 使用密码登录
systemctl restart ssh
reboot # 有时候可能需要重启才能更新配置桌面软件安装
- 在桌面终端中,复制快捷键为
Shift+Ctrl+v。 - 键盘设置中,将
中文(智能拼音)拖动到第一位,使用Shift键切换中英文。 - 登录时,请在选项中选择
ubuntu-xorg来登录桌面,解决远程桌面软件无法使用问题。
环境优化:
# 安装 Nautilus文件管理器插件
sudo apt install nautilus-admin
# 安装deb包默认启动程序
sudo apt install gnome-software
xdg-mime default org.gnome.Software.desktop application/vnd.debian.binary-package # .deb关联ubuntu软件中心程序软件下载地址:
- 星火应用商店
- 星火应用商店 gitee
- 基础应用:
星火应用管理器Wine运行器Win字体Clash Verge - 通讯软件:
微信(Universal)企业微信(Spark)钉钉(Linux官方版)QQ NT腾讯会议Telegram - 常用软件:
Microsoft EdgeGoogle Chrome网易云音乐WPS Officebilibili客户端百度网盘迅雷WPS 看图 - 开发软件:
notepad--apifoxtyporaTodesk - clash deb包依赖说明
- 其他软件列表:
- openkylin 软件列表
- 搜索:
wechatwps
- 搜索:
- WPS Office
- ToDesk
- 钉钉
- Apifox
- 腾讯会议
- 百度网盘
- google浏览器
开源镜像站
IDE安装:
# 安装Pycharm
# 手动下载: https://www.jetbrains.com/zh-cn/pycharm/download/?section=linux
cd ~/下载
sudo tar -xzf pycharm-professional-*.tar.gz -C /opt
sudo mv /opt/pycharm-* /opt/pycharm
sudo ln -s /opt/pycharm/bin/pycharm.sh /usr/local/bin/pycharm
sudo vim /usr/share/applications/pycharm.desktop
[Desktop Entry]
Version=2024.1
Type=Application
Name=PyCharm Professional
Icon=/opt/pycharm/bin/pycharm.png
Exec="/opt/pycharm/bin/pycharm.sh" %f
Comment=Python IDE for Professional Developers
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-pycharm
# 安装 WebStorm
# 手动下载: https://www.jetbrains.com/zh-cn/webstorm/download/#section=linux
cd ~/下载
sudo tar -xzf WebStorm-*.tar.gz -C /opt
sudo mv /opt/WebStorm-* /opt/webstorm
sudo ln -s /opt/webstorm/bin/webstorm.sh /usr/local/bin/webstorm
sudo vim /usr/share/applications/webstorm.desktop
[Desktop Entry]
Version=2024.1
Type=Application
Name=WebStorm
Icon=/opt/webstorm/bin/webstorm.png
Exec="/opt/webstorm/bin/webstorm.sh" %f
Comment=JavaScript IDE by JetBrains
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-webstorm
# 安装 DataGrip
# 手动下载: https://www.jetbrains.com/zh-cn/datagrip/download/#section=linux
sudo tar -xzf datagrip-*.tar.gz -C /opt
sudo mv /opt/DataGrip-*/ /opt/datagrip
sudo ln -s /opt/datagrip/bin/datagrip.sh /usr/local/bin/datagrip
sudo vim /usr/share/applications/datagrip.desktop
[Desktop Entry]
Version=2024.1
Type=Application
Name=DataGrip
Icon=/opt/datagrip/bin/datagrip.png
Exec="/opt/datagrip/bin/datagrip.sh" %f
Comment=Database IDE by JetBrains
Categories=Development;IDE;
Terminal=false
StartupWMClass=jetbrains-datagripWine 安装方式二
# 安装 Wine
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install wine64 libwine:i386 wine32:i386 -y
winecfg
# 将 C:/Windows/Fonts/simsun.ttc 复制到 ~/.wine/drive_c/windows/Fonts/
cp ~/下载/simsun.ttc ~/.wine/drive_c/windows/Fonts/
sudo apt install binfmt-support wine-binfmt -y # 允许你直接运行exe文件
sudo update-binfmts --enable wine
vim ~/.local/share/applications/wine.desktop
[Desktop Entry]
Name=Wine Windows Program Loader
Comment=Run Windows programs
Exec=wine %f
Terminal=false
Type=Application
MimeType=application/x-ms-dos-executable;
Icon=wine
xdg-mime default wine.desktop application/x-ms-dos-executable # 设置exe默认打开方式
# 切换到显卡Nouveau驱动
sudo apt install xserver-xorg-video-nouveau
# 安装其他依赖
sudo apt install winbind winetricks
winetricks vcrun2015OneDrive 安装
# 安装OneDrive
# https://software.opensuse.org/download.html?project=home:npreining:debian-ubuntu-onedrive&package=onedrive
# https://pathos.page/blog/settings-on-ubuntu-desktop#8-%E5%9C%A8-ubuntu-%E4%B8%8A%E4%BD%BF%E7%94%A8-onedrive
echo 'deb http://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/xUbuntu_24.04/ /' | sudo tee /etc/apt/sources.list.d/home:npreining:debian-ubuntu-onedrive.list
curl -fsSL https://download.opensuse.org/repositories/home:npreining:debian-ubuntu-onedrive/xUbuntu_24.04/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/home_npreining_debian-ubuntu-onedrive.gpg > /dev/null
sudo apt update
sudo apt install onedrive
onedrive --synchronize
# 右键打开终端链接,登录微软账号成功后,将浏览器空白页URl复制到终端,开始首次同步
onedrive --monitor # 监视文件变化
# 随系统启动
sudo vim /etc/systemd/system/onedrive.service
# User 和 Group 都是你的电脑登录账号
[Unit]
Description=OneDrive Sync Client
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/onedrive --monitor
Restart=always
User=your_username
Group=your_groupname
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl start onedrive.service
sudo systemctl enable onedrive.service还有另外一个OneDrive三方包 abraunegg/onedrive,目前没有更新到24.04版本。
其他优化
# 信任桌面上的所有desktop文件
find ~/桌面 -name '*.desktop' -exec gio set {} metadata::trusted true \;
# 启用一些gnome扩展
gnome-shell-extension-prefs