Ubuntu基本配置
Ubuntu Win10双系统时间差问题
1 2 3 4 # 通过本地时间维护实时时钟 sudo timedatectl set-local-rtc 1 # 恢复 sudo timedatectl set-local-rtc 0
安装locate
1 2 3 sudo apt install mlocate # 更新索引 sudo updatedb
LInux 垃圾清理常用命令
1 2 3 4 5 6 7 sudo apt autoremove sudo apt autoclean sudo apt clean # 卸载 sudo apt-get remove #会删除软件包而保留软件的配置文件 sudo apt-get purge #会同时清除软件包和软件的配置文件
Docker
官方文档:https://docs.docker.com/engine/install/ubuntu/
此处完全根据官方文档操作,仅替换源为https://mirrors.ustc.edu.cn
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 # 更新apt包索引并安装包以允许apt通过 HTTPS 使用存储库: sudo apt-get update sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg \ lsb-release # 添加Docker官方的GPG密钥 curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg # 设置稳定存储库 echo \ "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu \ $ (lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # 安装Docker sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io # 启动Docker sudo systemctl enable docker sudo systemctl start docker # 建立Docker用户组,并将用户加入 sudo groupadd docker sudo usermod -aG docker $USER newgrp docker # 测试 docker run hello-world
Linux C/C++ 开发环境配置
1 2 3 4 5 6 7 8 9 10 11 12 # Complier sudo apt install build-essential sudo apt install gcc sudo apt install g++ sudo apt install gdb # Qt5 推荐https://download.qt.io/archive/qt/ 下载安装 sudo apt install qt5-default qtcreator # Qt5构建时 cannot find -lGL 错误 # 用locate查看libGL.so,找到目录/usr/lib/x86_64-linux-gnu/libGL.so.1.7.0 locate libGL.so # 添加软链接 sudo ln -s /usr/lib/x86_64-linux-gnu/libGL.so.1.7.0 /usr/lib/libGL.so
安装
1 2 3 sudo add-apt-repository ppa:linrunner/tlp sudo apt update sudo apt install tlp
使用
1 2 3 4 5 6 sudo tlp start #启动/重启TLP 在第一次安装后,如果不想重启,就可以使用这个命令启动TLP sudo tlp ac #开启交流电源模式(类似于windows中的性能模式) 相当于sudo tlp false sudo tlp bat #开启电池模式(节能模式) 相当于 sudo tlp true sudo tlp usb #将连接的USB设备空闲时自动挂起或关闭 sudo tlp bayoff #关闭MediaBay或Ultrabay中的光盘驱动器 tlp diskid #查看磁盘的id型号 其他是thinkpads only, 所有具体man tlp
查看tlp信息
使用以下命令检查TLP是否已启用并处于活动状态:
grub主题
下载:https://www.gnome-look.org/browse/,放在合适的位置,如EFI分区
编辑文件:sudo vim /etc/default/grub
添加
1 GRUB_THEME="具体主题路径/theme.txt"
如果是gpt分区,以uefi启动方式启动的话,启动时读取的文件是/boot/efi/EFI/fedora/grub.cfg ,这个时候更新时需更新这个文件
1 sudo grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg
如果是一般的启动方式,启动时读取的文件是/boot/grub2/grub.cfg,这个时候更新时需更新这个文件
1 sudo grub-mkconfig -o /boot/grub/grub.cfg
源配置文件
1 2 3 4 5 6 7 8 sudo vim /etc/apt/sources.list # sources.list deb http://mirrors.ustc.edu.cn/ubuntu/ focal main universe restricted multiverse deb-src http://mirrors.ustc.edu.cn/ubuntu/ focal main universe restricted multiverse #Added by software-properties deb https://mirrors.ustc.edu.cn/ubuntu/ focal-security restricted universe multiverse main deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates restricted universe multiverse main deb http://mirrors.ustc.edu.cn/ubuntu/ focal-backports restricted universe multiverse main
http://mirrors.ustc.edu.cn/ubuntu/
DSL拨号链接
在/usr/bin目录下
1 sudo ./nm-connection-editor
Arduino 开发板
涉及串口访问权限问题,按以下方法操作,否则无法烧录开发板
1 2 # root启动IDE,但VSCode无法使用(不安全也不推荐) sudo arduino
更好的方法,适用于VSCode等
1 2 3 4 5 6 # 将所用user添加到dialout用户组 sudo usermod -a -G dialout user_name # -G, --groups GROUPS 新的附加组列表 GROUPS # -a, --append GROUP 将用户追加至上边 -G 中提到的附加组中, # 并不从其它组中删除此用户
Linux Qt程序打包
下载linuxdeployqt,linuxdeployqt-x86_64.AppImage,下载地址:
https://github.com/probonopd/linuxdeployqt/releases
对于高版本的Ubuntu,按照https://www.bilibili.com/video/av884114337/编译。
1 sudo apt install patchelf
下载appimagetool:https://github.com/AppImage/AppImageKit
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # 为了我们后面使用时方便一点,将appimage重命名: sudo mv linuxdeployqt-7-x86_64.AppImage linuxdeployqt # appimagetool也做同样的操作 sudo mv appimagetool-x86_64.AppImage appimagetool sudo chmod 777 appimagetool sudo mv appimagetool /usr/local/bin # 修改为可执行权限 sudo chmod 777 linuxdeployqt # 移动至/usr/local/bin目录,可以在其他目录访问 sudo mv linuxdeployqt /usr/local/bin # 测试 linuxdeployqt --version
1 2 3 4 5 6 7 8 9 10 # 修改 .bashrc 文件 sudo vim ~/.bashrc # 在文件末尾追加以下内容 # add Qt env export PATH=/home/henry/Qt5.14.2/5.14.2/gcc_64/bin:$PATH export LD_LIBRARY_PATH=/home/henry/Qt5.14.2/5.14.2/gcc_64/lib:$LD_LIBRARY_PATH export QT_PLUGIN_PATH=/home/henry/Qt5.14.2/5.14.2/gcc_64/plugins:$QT_PLUGIN_PATH export QML2_IMPORT_PATH=/home/henry/Qt5.14.2/5.14.2/gcc_64/qml:$QML2_IMPORT_PATH # 最后source ~/.bashrc source ~/.bashrc
1 2 3 4 5 6 7 # release后,将可执行文件放在目录下,在该目录执行 # QtMagicOASystem即为可执行文件名 linuxployqt QtMagicOASystem -appimage # 如果成功,会在目录里生成lib等文件夹,并且产生AppRun,接着在desktop文件添加(可能被隐藏) Categories=Application; # 成功后,开始构建AppImage文件,QtMagicOASystem即为存放打包完成后文件的目录 appimagetool ./QtMagicOASystem
参考资料:https://blog.csdn.net/qq_43081702/article/details/115668609
Ubuntu安装微信
1 2 3 4 5 6 7 8 9 wget -O- https://deepin-wine.i-m.dev/setup.sh | sh sudo apt-get install com.qq.weixin.deepin # 微信查看图片依赖 sudo apt-get install libjpeg62-dev:i386 # 托盘微信图标 sudo apt-get install gnome-shell-extension-top-icons-plus gnome-tweaks # 注销重新登录后在tweak工具中启用对应插件
应用
包名
微信
com.qq.weixin.deepin
QQ
com.qq.im.deepin
TIM
com.qq.office.deepin
钉钉
com.dingtalk.deepin
阿里旺旺
com.taobao.wangwang.deepin
QQ音乐
com.qq.music.deepin
QQ视频
com.qq.video.deepin
爱奇艺
com.iqiyi.deepin
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 # 清理应用运行时目录 # 例如QQ/TIM会把帐号配置、聊天文件等保存~/Documents/Tencent Files目录下,而微信是~/Documents/WeChat Files,删除这些文件夹以移除帐号配置等数据。 # 清理wine容器 # deepin-wine应用第一次启动后会在~/.deepinwine/目录下生成一个文件夹(名字各不相同)用于存储wine容器(可以理解我一个“Windows虚拟机”),如果使用出了问题,可以试试删除这个目录下对应的子文件夹。 # 卸载软件包 # 执行命令把你安装过的包给移除。 sudo apt-get purge --autoremove <包名> # 移除软件仓库 sudo rm /etc/apt/preferences.d/deepin-wine.i-m.dev.pref \ /etc/apt/sources.list.d/deepin-wine.i-m.dev.list \ /etc/profile.d/deepin-wine.i-m.dev.sh sudo apt-get update
Java
https://www.oracle.com/java/technologies/javase-downloads.html
1 2 3 4 5 6 7 8 9 10 11 12 13 # 设置Java环境变量 sudo vim ~/.bashrc #/ect/bash.bashrc对所有用户生效 # 加入以下配置(修改对应路径) # add Java env export JAVA_HOME=/home/henry/jdk1.8.0_301 export JRE_HOME=${JAVA_HOME}/jre export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib export PATH=.:${JAVA_HOME}/bin:$PATH # 保存 source ~/.bashrc
Linux下profile和bashrc区别
/etc/profile
用来设置系统环境参数,比如$PATH. 这里面的环境变量是对系统内所有用户生效的。
/etc/bashrc(UBUNTU为/ect/bash.bashrc)
这个文件设置系统bash shell相关的东西,对系统内所有用户生效。只要用户运行bash命令,那么这里面的东西就在起作用。
~/.bash_profile
用来设置一些环境变量,功能和/etc/profile 类似,但是这个是针对用户来设定的,也就是说,你在/home/user/.bash_profile 中设定了环境变量,那么这个环境变量只针对 user 这个用户生效.
~/.bashrc
作用类似于/etc/bashrc, 只是针对用户自己而言,不对其他用户生效。
另外/etc/profile中设定的变量(全局)的可以作用于任何用户,而~/.bashrc等中设定的变量(局部)只能继承/etc/profile中的变量。
fcitx更换皮肤
皮肤文件目录
然后在fcitx输入法配置中点击外观,并勾选显示高级选项,将皮肤名称替换为自己的即可。
推荐rime输入法:https://rime.im/