常用操作

vim中tab和空格转换

  1. TAB替换为空格:
  2. :set ts=4
  3. :set expandtab
  4. :%retab!
  5. 空格替换为TAB
  6. :set ts=4
  7. :set noexpandtab
  8. :%retab!

开机加载模块和禁止加载模块

如何让开机加载/禁止加载 lib下的 驱动
/etc/modules:
内核模块文件,里面列出的模块会在系统启动时自动加载。
/etc/modprobe.d:
存放禁止加载或者加载内核模块脚本的目录。

  1. # 比如我想开机加载这两个驱动
  2. # 需要确定 /boot/config-$(uname -r) 中是否将该启动项设置为模块
  3. root@inno-MS-7B89:mdev# ls /lib/modules/5.4.0-58-generic/kernel/drivers/vfio/mdev
  4. mdev.ko vfio_mdev.ko
  5. # 然后修改/etc/modules即可

typora download

https://gitee.com/typora-mirror/Typora-Mirror/releases

图形界面打开和关闭

  1. sudo apt-get install ubuntu-desktop
  2. 1. 关闭用户图形界面
  3. sudo systemctl set-default multi-user.target && sudo reboot
  4. 2.开启用户图形界面
  5. sudo systemctl set-default graphical.target && sudo reboot

JDK环境搭建

https://blog.csdn.net/pxmxx/article/details/80106239
https://www.jianshu.com/p/6fe47f6a1b2a : 推荐源码下载安装

搜狗输入法

https://blog.csdn.net/nuoyanli/article/details/93303275
注:安装后,记得 sudo apt-get autoremove ibus 删除了,要不有很多麻烦

ubuntu 18.04 设置开机启动脚本

https://www.cnblogs.com/airdot/p/9688530.html

oh-my-zsh

https://www.jianshu.com/p/d194d29e488c?open_source=weibo_search

Apt-get相关管理

  1. apt-cache madison <<package name>> # 列出所有源的版本
  2. apt-cache policy <<package name>>
  3. apt-file search libz.so.1 #查看库所属包
  4. apt list --upgradable #列出可以升级的库
  5. sudo apt-get upgrade #升级
  6. sudo apt-get -f install 是修复损坏的软件包,尝试卸载出错的包,重新安装正确版本的。
  7. sudo apt-get update --fix-missing
  8. sudo apt-get autoremove && sudo apt-get clean && sudo apt-get install -f
  9. sudo apt-get update 更新源
  10. sudo apt-get install packagename 安装包
  11. sudo apt-get install packagename=xxxx 安装指定版本的软件
  12. sudo apt-get -f install 修复安装”-f = fix-missing
  13. sudo apt-cache search packagename 搜索包
  14. sudo apt-cache show packagename 获取包的相关信息,如说明、大小、版本等
  15. sudo apt-get install packagename --reinstall 重新安装包
  16. sudo apt-get remove packagename 删除包
  17. sudo apt-get remove packagename --purge 删除包,包括删除配置文件等
  18. sudo apt-get upgrade 更新已安装的包
  19. sudo apt-get dist-upgrade 升级系统
  20. sudo apt-get dselect-upgrade 使用 dselect 升级
  21. sudo apt-cache depends packagename 了解使用依赖
  22. sudo apt-cache rdepends packagename 是查看该包被哪些包依赖
  23. sudo apt-get build-dep packagename 安装相关的编译环境
  24. sudo apt-get source packagename 下载该包的源代码
  25. sudo apt-get clean 清理无用的包
  26. sudo apt-get autoclean 清理无用的包
  27. sudo apt-get check 检查是否有损坏的依赖

保存终端到文件

  1. sudo script screen.log exit

音量控制

  1. sudo alsamixer #可控制音量

Linux用户组管理

Linux 中将用户添加到组的指令

Linux下windows工具安装

https://github.com/linuxdeepin/deepin-terminal #听说好用的深度终端

VIM配置

https://starifly.github.io/FlyVim/
当然,我这里还是经常使用: vimrc 里边的配置

本地搭建ali镜像源

查看系统版本

  1. 使用lsb_release -a查看操作系统相关信息,主要需要注意Codename这一项。如ubuntu 18.04就是bionic

更改Ubuntu 18.04 软件源为国内版

  1. sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
  2. sudo vim /etc/apt/sources.list

更新为以下内容:

  1. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
  2. deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
  3. deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  4. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  5. deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  6. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  7. deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  8. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  9. deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  10. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

保存退出后执行:

  1. sudo apt-get update
  2. sudo apt-get upgrade
  3. sudo apt-get install apt-mirror

配置apt-mirror

修改/apt/mirror

  1. sudo mv /etc/apt/mirror.list /etc/apt/mirror.list.bak
  2. sudo vim /etc/apt/mirror.list
  3. ############# config ##################
  4. #
  5. # set base_path /var/spool/apt-mirror
  6. #
  7. # set mirror_path $base_path/mirror
  8. # set skel_path $base_path/skel
  9. # set var_path $base_path/var
  10. # set cleanscript $var_path/clean.sh
  11. # set defaultarch <running host architecture>
  12. # set postmirror_script $var_path/postmirror.sh
  13. # set run_postmirror 0
  14. set base_path /mnt/service/ubuntu
  15. set mirror_path $base_path/mirror
  16. set skel_path $base_path/skel
  17. set var_path $base_path/var
  18. set cleanscript $var_path/clean.sh
  19. set nthreads 20
  20. set _tilde 0
  21. #
  22. ############# end config ##############
  23. deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
  24. deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  25. deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  26. deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  27. deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  28. deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
  29. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
  30. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
  31. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
  32. deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
  33. clean http://archive.ubuntu.com/ubuntu

下载镜像

  1. #sudo apt-mirror # 此步骤约占用240G硬盘空间,等待5-8小时即可同步完成
  2. #sudo sh /service/ubuntu/var/clean.sh # 清除无用软件包

发布镜像源

  1. sudo apt-get update
  2. sudo apt-get dist-upgrade
  3. sudo apt-get install gnupg
  4. sudo apt-get install rng-tools
  5. rngd -r /dev/urandom
  6. cd /service/ubuntu/mirror/mirrors.aliyun.com/ubuntu/
  7. gpg --gen-key # 按提示设置用户名密码
  8. gpg -a --export username> username.pub # Username 为上一步设置的用户名
  9. apt-ftparchive packages pool > pool/Packages
  10. cd pool
  11. gzip -c Packages > Packages.gz
  12. apt-ftparchive release ./ > Release
  13. gpg --clearsign -o InRelease Release # 根据提示输入密码
  14. gpg -abs -o Release.gpg Release

开启apache服务

  1. sudo apt-get install apache2
  2. cd /etc/apach2
  3. vim apache2.conf
  4. 修改
  5. <Directory />
  6. Options FollowSymLinks
  7. AllowOverride None
  8. Require all denied
  9. </Directory>
  10. 改为
  11. <Directory />
  12. Options FollowSymLinks
  13. AllowOverride None
  14. Order deny,allow
  15. allow from all
  16. </Directory>
  17. 添加
  18. <IfModule alias_module>
  19. Alias /ubuntu /workspace/ubuntu/mirror/mirrors.163.com/ubuntu
  20. </IfModule>
  21. <Directory "/workspace/ubuntu/mirror/mirrors.163.com/ubuntu">
  22. Options Indexes FollowSymLinks
  23. AllowOverride None
  24. Require all granted
  25. </Directory>
  26. 保存退出
  27. # /etc/init.d/apache2 restart

客户端使用

  1. 加载gpg密钥
  2. apt-key add username.pub
  3. vim /etc/apt/source.list
  4. # 删掉所有内容,添加以下内容:
  5. deb https://10.0.60.101/pool /
  6. 10.0.60.101为搭建本地镜像源的服务器ip
  7. 保存退出
  8. sudo apt-get update
  9. sudo apt-get dist-upgrade

FAQ

open ssh 安装失败

  1. baiy@baiy-ThinkPad-E470c:~$ sudo apt-get install openssh-server
  2. 下列软件包有未满足的依赖关系:
  3. openssh-server : 依赖: openssh-client (= 1:6.6p1-2ubuntu2.13)
  4. 推荐: ssh-import-id 但是它将不会被安装
  5. E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
  6. sudo apt-get install openssh-client=1:6.6p1-2ubuntu1

VIM依赖崩溃

  1. vim : 依赖: vim-common (= 2:7.3.429-2ubuntu2) 但是 2:7.3.429-2ubuntu2.1 正要被安装
  2. sudo apt-get purge vim-common
  3. sudo apt-get update
  4. sudo apt-get upgrade
  5. sudo apt-get install vim

a start job is running for wait for network……?

a start job is running for wait for network to be configured
执行:
sudo systemctl mask systemd-networkd-wait-online.service