常用操作
vim中tab和空格转换
TAB替换为空格:
:set ts=4
:set expandtab
:%retab!
空格替换为TAB:
:set ts=4
:set noexpandtab
:%retab!
开机加载模块和禁止加载模块
如何让开机加载/禁止加载 lib下的 驱动
/etc/modules:
内核模块文件,里面列出的模块会在系统启动时自动加载。
/etc/modprobe.d:
存放禁止加载或者加载内核模块脚本的目录。
# 比如我想开机加载这两个驱动
# 需要确定 /boot/config-$(uname -r) 中是否将该启动项设置为模块
root@inno-MS-7B89:mdev# ls /lib/modules/5.4.0-58-generic/kernel/drivers/vfio/mdev
mdev.ko vfio_mdev.ko
# 然后修改/etc/modules即可
typora download
https://gitee.com/typora-mirror/Typora-Mirror/releases
图形界面打开和关闭
sudo apt-get install ubuntu-desktop
1. 关闭用户图形界面
sudo systemctl set-default multi-user.target && sudo reboot
2.开启用户图形界面
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相关管理
apt-cache madison <<package name>> # 列出所有源的版本
apt-cache policy <<package name>>
apt-file search libz.so.1 #查看库所属包
apt list --upgradable #列出可以升级的库
sudo apt-get upgrade #升级
sudo apt-get -f install 是修复损坏的软件包,尝试卸载出错的包,重新安装正确版本的。
sudo apt-get update --fix-missing
sudo apt-get autoremove && sudo apt-get clean && sudo apt-get install -f
sudo apt-get update 更新源
sudo apt-get install packagename 安装包
sudo apt-get install packagename=xxxx 安装指定版本的软件
sudo apt-get -f install 修复安装”-f = –fix-missing”
sudo apt-cache search packagename 搜索包
sudo apt-cache show packagename 获取包的相关信息,如说明、大小、版本等
sudo apt-get install packagename --reinstall 重新安装包
sudo apt-get remove packagename 删除包
sudo apt-get remove packagename --purge 删除包,包括删除配置文件等
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-get dselect-upgrade 使用 dselect 升级
sudo apt-cache depends packagename 了解使用依赖
sudo apt-cache rdepends packagename 是查看该包被哪些包依赖
sudo apt-get build-dep packagename 安装相关的编译环境
sudo apt-get source packagename 下载该包的源代码
sudo apt-get clean 清理无用的包
sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
保存终端到文件
sudo script screen.log exit
音量控制
sudo alsamixer #可控制音量
Linux用户组管理
Linux下windows工具安装
https://github.com/linuxdeepin/deepin-terminal #听说好用的深度终端
VIM配置
https://starifly.github.io/FlyVim/
当然,我这里还是经常使用: vimrc 里边的配置
本地搭建ali镜像源
查看系统版本
使用lsb_release -a查看操作系统相关信息,主要需要注意Codename这一项。如ubuntu 18.04就是bionic
更改Ubuntu 18.04 软件源为国内版
sudo mv /etc/apt/sources.list /etc/apt/sources.list.backup
sudo vim /etc/apt/sources.list
更新为以下内容:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
保存退出后执行:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apt-mirror
配置apt-mirror
修改/apt/mirror
sudo mv /etc/apt/mirror.list /etc/apt/mirror.list.bak
sudo vim /etc/apt/mirror.list
############# config ##################
#
# set base_path /var/spool/apt-mirror
#
# set mirror_path $base_path/mirror
# set skel_path $base_path/skel
# set var_path $base_path/var
# set cleanscript $var_path/clean.sh
# set defaultarch <running host architecture>
# set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set base_path /mnt/service/ubuntu
set mirror_path $base_path/mirror
set skel_path $base_path/skel
set var_path $base_path/var
set cleanscript $var_path/clean.sh
set nthreads 20
set _tilde 0
#
############# end config ##############
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
clean http://archive.ubuntu.com/ubuntu
下载镜像
#sudo apt-mirror # 此步骤约占用240G硬盘空间,等待5-8小时即可同步完成
#sudo sh /service/ubuntu/var/clean.sh # 清除无用软件包
发布镜像源
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install gnupg
sudo apt-get install rng-tools
rngd -r /dev/urandom
cd /service/ubuntu/mirror/mirrors.aliyun.com/ubuntu/
gpg --gen-key # 按提示设置用户名密码
gpg -a --export username> username.pub # Username 为上一步设置的用户名
apt-ftparchive packages pool > pool/Packages
cd pool
gzip -c Packages > Packages.gz
apt-ftparchive release ./ > Release
gpg --clearsign -o InRelease Release # 根据提示输入密码
gpg -abs -o Release.gpg Release
开启apache服务
sudo apt-get install apache2
cd /etc/apach2
vim apache2.conf
修改
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
改为
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
allow from all
</Directory>
添加
<IfModule alias_module>
Alias /ubuntu /workspace/ubuntu/mirror/mirrors.163.com/ubuntu
</IfModule>
<Directory "/workspace/ubuntu/mirror/mirrors.163.com/ubuntu">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
保存退出
# /etc/init.d/apache2 restart
客户端使用
加载gpg密钥
apt-key add username.pub
vim /etc/apt/source.list
# 删掉所有内容,添加以下内容:
deb https://10.0.60.101/pool /
10.0.60.101为搭建本地镜像源的服务器ip
保存退出
sudo apt-get update
sudo apt-get dist-upgrade
FAQ
open ssh 安装失败
baiy@baiy-ThinkPad-E470c:~$ sudo apt-get install openssh-server
下列软件包有未满足的依赖关系:
openssh-server : 依赖: openssh-client (= 1:6.6p1-2ubuntu2.13)
推荐: ssh-import-id 但是它将不会被安装
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
sudo apt-get install openssh-client=1:6.6p1-2ubuntu1
VIM依赖崩溃
vim : 依赖: vim-common (= 2:7.3.429-2ubuntu2) 但是 2:7.3.429-2ubuntu2.1 正要被安装
sudo apt-get purge vim-common
sudo apt-get update
sudo apt-get upgrade
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