Why Linux

【如果说Windows是一道菜的话,那Linux就是菜谱,你可以根据自己的口味制作你喜欢的菜】关于为什么我选择GNU/Linux作为主力系统,以及我在Linux作为日常办公桌面环境方面的一些使用经验。包括新装Debian Linux该做的事(快速打造我的日用工作台)。最后,还有我使用GNU/Linux以来的一些笔记,仅供参考。

Posted by Ryan Yim on 2020-09-21
Estimated Reading Time 420 Minutes
Words 91k In Total
Viewed Times

Windows系统使用建议相关的可以查看许景欣博文

本文是应许景欣邀约而作,主题是关于我为什么选择Linux作为主力系统和我在Linux日常使用的部分经验。由于这里我不是把Linux当作服务器使用,而是作为日常办公的桌面环境,加上本身不是计算机专业、不是Linux运维人员。故本文仅供参考,如果您有更好的建议请在下方留言。

Check Xu Jingxin’s Blog for Computer usage specifications and recommendations

This article was written at the invitation of Xu Jingxin. The topic is about why I chose Linux as the main system and my experience in daily use of Linux. Here I am not using Linux as a server, but as a desktop environment for routine office, and I am not a computer professional, not a Linux operation and maintenance personnel. Therefore, this article is for reference only, if you have better suggestions, please leave comments below.

快速导航

为什么我选择Linux - Why GNU/Linux

我的笔记本电脑配置:(目前已经换台式机了 Intel i5-12400 + 16GRAM + 1T SSD + AMD RX6600 GPU)

CPU:i5-7200U

RAM:12G(4+8)

HardDisk:256G SSD+512G SSD

GPU:Intel Corporation HD Graphics 620 + AMD Radeon M330


My Laptop Specifications:

CPU:Intel Core i5-7200U

Memory:12G RAM

Storage:256G SSD[Windows] + 512G SSD[Linux]

GPU:Intel Corporation HD Graphics 620 + AMD Radeon M330

Windows系统当然不错,用过Windows98、Windows Xp、Windows 7、Windows 8、Windows 8.1、Windows 10。最好用的当然是Windows 10了(不接受反驳)。

Win 10好用归好用,占用资源有点多,我装了360安全卫士和COMODO防火墙,待机状态下就有点发热。

关于360:你若问我为什么保留360安全卫士,你可听过一句话叫做“流氓治流氓”?360固然有点流氓,但是用它来治理一些流氓软件(比如Flash、迅雷、WPS,还有它自己的360手机助手我也用360自己杀自己杀掉了)可以说非常方便了。360有一个非常好的地方,就是一键解决,这非常实用。所以我也会推荐小白使用360,因为对电脑一窍不通的小白,360一键解决方法可以解决小白百分之五十的问题

如果说要我给小白关于使用360安全卫士的建议的话,我想说:用360可以,但不要一直按360的思路来,特别是它推荐你装一些没有必要的软件时(比如鲁大师、360手机助手)。

那为什么装了360安全卫士我还装了COMODO呢?为了HIPS和防火墙哈哈哈哈,COMODO比360敏感很多,疯狂隔离你的文件就是了。下面我简单总结下Windows的优缺点吧:

windows

WIndows优点 - Advantages

  • 驱动好。大多硬件在Windows都有良好的驱动支持。
  • 小白用户友好。Windows的界面对小白友好,你看过哪个小白第一次接触Windows系统不会用的?
  • 软件多,办公支持好。各种奇奇怪怪的软件WIndows可以说非常多了,你看看Adobe全家桶?看看微信、QQ、钉钉?
  • 破解软件多。你说这是优点吧,免费对吧,白嫖。你说缺点吧,破解版很容易导致电脑中毒、不稳定等等。所以我个人是不推荐使用盗版软件。
  • Office太好用。Office真的比WPS好用……
  • 游戏支持好、娱乐多。好多主流游戏Linux没有呢。

Windows缺点 - Disadvantages

  • 占用资源多。后台奇奇怪怪的东西太多,主要是流氓软件。你看看QQ、迅雷看看等等。
  • 权限管理一般。一般,自己体会。
  • 被巨硬(微软)后入的感觉。明明是自己的电脑,我想让Windows把自己删了 ,它不干。
  • 万恶的资源浏览器。用久了,虽然不卡,但是奇奇怪怪问题很多,特别是多任务,Explorer有时会崩溃,这个有时就很烦啊
  • 万恶的文件占用、磁盘占用。多少次,遇到“文件已被打开,请先关闭再删除”还有“磁盘正在使用,无法弹出”。每次都得接触占用,烦不烦?虽然不是经常,但偶尔就很烦,我懒。
  • 万恶的广告。说白就是流氓软件。比如Flash只有在大陆的Windows系统有广告,呵呵。我在Linux就没遇到广告……
  • 万恶的蓝屏。其实不能这么说,蓝屏我四年内掐指一算只遇到过3次的样子,还是我个人原因导致的蓝屏(我把必要驱动删了,蓝屏代码提示我说找不到加载啥啥啥)。但现在咱们说的是,应用卡死,任务管理器都出不来,怎么办????大多人都会强制关机重启吧……而Linux这边,图形界面卡死我还有tty终端可以用撒,结束卡死的程序,重启图形界面就好了。
  • 不稳定。Windows这边,明明设置好了的,过了一年多,可能就莫名其妙被改了,可能是被什么软件改了,也可能是系统更新改了。反正我的Windows一直保持更新,一直是最新版本。更新了这么多年,崩掉的软件有(小米WIFI、360随身WIFI、Anaconda)
  • 编译不友好。Windows这边搭建开发环境,有的时候真的很恼火,不像Linux一路apt就完事了。

Windows卡顿吗

从非专业的角度提供一些简单粗暴的解决办法,没耐心的直接看实操

先讲个知乎上关于电脑养蛊的鬼故事:

1
2
3
4
5
6
7
给妹子重装了系统,她装了360浏览器,很快地,我发现桌面上多了360安全卫士、360杀毒,360手机卫士、360安全导航。
然后又重装了系统,这次明令禁止安360浏览器,于是她装了猎豹浏览器。很快地,我发现桌面上多了金山卫士,悟空杀毒,金山手机管家。。。。。
然后又重装了系统,这次明令禁止安装360、猎豹,后来她装了QQ浏览器,我没发现多了什么东西,原来什么QQ管家,QQ音乐,QQ输入法早就被安装好了。。。

后来又重装了系统,这次我让她只能用Chrome,世界清静了。

妹子从此再也没找过我,我为此感到很自豪。

简单分析

至于电脑卡顿这个问题……因为这几年一直用的Linux系统 (除微软的Windows和苹果的MacOS以外的一种系统而已),所以Windows反倒有点生疏了。不过在这里我还是提供些简单粗暴的解决思路吧:

一般来讲,卡顿有两种原因:

  1. 硬件问题:配置较低,性能不足。比如买了一台廉价的低配电脑,虽然电脑是新的,但是配置低。这样的电脑用来运行大型应用就会有小牛拉大车的感觉。
  2. 软件问题:维护力度不足,流氓软件多。比如新电脑很流畅,用着用着越来越卡。

解决思路:

  1. 硬件问题:
    • 换硬件,买更高配置的电脑撒。
    • 使用硬件需求更低的软件,降低系统自身的资源占用。比如低配电脑带不带Windows 10,那就装个Windows 7呗,或者Linux系统也行。
  2. 软件问题(仅列举几个简单粗暴的):
    • 卸载不需要的软件,禁用不需要的服务。
    • 卸载流氓软件。
    • 减少应用多开。

实际操作(Windows 7为例)

相信在关闭无用的服务和软件后…你们的电脑应该会流畅一……一……一点……点点点点点吧…吧……啊……

  • 禁用没用或者少用的软件、服务(听起来像废话)

    1. Win+r快捷键打开“运行”,输入msconfig后回车出现系统配置对话框。

      msconfig.png

    2. 点击服务勾选 隐藏所有Microsoft服务 (记得勾选,除非你知道那些Microsoft服务干嘛用的,要不万一禁用了什么不得了的东西开不了机就肥肠有趣了),然后在列表中禁用掉没用的服务。

      怎么知道某个服务是干什么的呢?服务很多都是英文名,看不懂可以百度翻译撒。或者百度一下也行,不懂的多多百度(能材界有一句话嘛,叫做“做实验前多查文献,能保命”)。

      错误禁用服务会怎样?答:上文提到,你已经勾选了隐藏Microsoft服务,剩下可以看到的大多都是软件的服务。某软件服务被禁用可能导致你在使用该软件时出现一些奇奇怪怪的问题。但不用怕,解决办法很简单:重新在msconfig勾选、启用该服务,然后重启就行了。或者,每次需要用到该软件时,手动到services.msc中临时启动该服务即可。

      msconfig_service.png

      services.msc.png

    3. msconfig的对话框,点击启动 (Windows10则是在任务管理器中),禁用掉不需要开机自启的软件。注意,这里是针对开机自启的软件,禁用某软件开机自启后,软件开机时不会启动(但不排除通过其他途径自启,比如有些流氓软件嘛你懂的),需要用的时候再打开就好咯。

      msconfig_startup.png

  • 卸载无用、多余的软件。

    1. 只留一个杀毒软件。360安全卫士、360杀毒、 金山、腾讯管家,只留一个就好了。因为杀毒软件是很占用系统资源的,如果你在使用计算机方面有良好的习惯(不随意安装软件、几乎不用流氓软件、不随意接收可疑文件、防火墙流量过滤、及时升级系统、安装漏洞补丁等),依靠Windows自带的Windows Defender对抗病毒足矣(Windows10哈,Windows7就算了,EOL警告)。

      关于用什么防护软件:个人认为,如果您对电脑啥都不懂,直接上360安全卫士就够解决新手80%的电脑问题了。如果你有点懂电脑,建议使用Windows自带的Windows Defender或者火绒、COMODO(科摩多)。

      关于360安全卫士流氓的说法:是流氓没错,可它简单粗暴呀。很多人说装了360更卡了,请看下文。

    2. 配置好应用程序。就拿360安全卫士开刀:360安全卫士是简单粗暴地解决了电脑小白80%的问题。但是他也很流氓,毕竟商业软件要恰饭打广告撒。所以如果你放任它自由,很快它也会吧360全家桶往你的电脑使劲塞,自然电脑也会跟着卡到爆炸。所以安装360安全卫士后,如果它提示你安装什么手机助手、桌面助手、壁纸切换什么的花里胡哨的没用的东西,一律禁止、不安装就是。还有,360安全卫士的设置记得过一遍,取消勾选类似“展示我的荣誉勋章”、“开机助手”、“360资讯”等毫无意义的功能。对了,360手机助手千万别去动…因为装了就卸载不掉了(可以卸载,用360强制卸载去卸载360手机助手就行了)。

      关于去哪里下载软件:最好去官网!!这很重要,比如下载网易云音乐当然是去网易云音乐官网 -> https://music.163.com/#/download 下载微信当然是去腾讯官网下载:https://weixin.qq.com/

      不过…如果你实在不知道去哪里,那就去360软件管家这种地方下载吧…虽然上面也有流氓软件,但好歹有360公司…emmmm对吧,相对三无网站来说带病毒的可能性更小。

      360_conf.png

      360prod_sale.png

      360av_conf.png

    3. 精简软件列表。我发现有些人的电脑上乱七八糟的浏览器(360浏览器、极速浏览器、猎豹浏览器、2345浏览器)、输入法(QQ输入法、2345输入法、王牌输入法)一大堆。没必要真的,浏览器火狐、谷歌不香嘛(工作单位我推荐谷歌浏览器Chrome,因为大多数网页都是基于Chrome开发的。记得去官网下载 !当然,如果你觉得用着不顺手,国产浏览器也是可以,但一个就好,一个就好,记得设置过一遍,没用的功能都关了,比如360浏览器的资讯锁屏壁纸!)。同理,输入法也是一个就好了。还有一些多功能软件,一个定俩的那种你懂的。

      安装软件记得去官网!

      安装软件记得去官网!

      安装软件记得去官网!

      multi_browser.png

    4. 卸载流氓软件。流氓软件和盗版软件能不用就不用啦,除非你知道它没有问题,知根知底。一款软件的代替品有很多,虽然商业软件多数都比免费软件好用,但除专业用途,多少人又用得到专业软件特有的那些功能呢?就比如Adobe PS这款修图软件,我用的是GNU旗下开源免费的GIMP代替它;Adobe Pr我同样使用开源免费的Kdenlive代替它(有种买不起贵的后驱性能车[指商业付费软件]玩漂移,我可以买五菱宏光[指免费软件]的感觉。这不比买水车[指盗版、流氓软件]被交警查了香?「又及:水车可以,体验一下快乐一下,偶尔使用还行,记得做好安全措施就是」)。大部分功能还是有的,体验的话自然是Adobe这类商业软件更好。

      不知道去哪里找代替品?知乎、Alternative to了解一下?

      关于弹窗太多:有个治标不治本的办法是使用360弹窗拦截…流氓打流氓。

  • 关闭不用的软件。看看自己电脑右下角的系统托盘,是不是图标一大堆?有些还真的用不到,比如Windows 10可能有OneDrive、Skype、小娜等,不用的话可以打开、设置一下下次不再启动等。

    sys_tray.png

  • 桌面上东西不要太多,能分工作区就分工作区(比如这个文件夹专门存放临时文档,这个文件夹主题是xxx),完成任务后记得及时清理工作区。至于快捷方式呢,除了真天天用的,其他可以不要,因为开始菜单不是有搜索功能吗?

    start_menu.png

  • 养成系统备份的好习惯。有个东西叫做磁盘保护不知道你们听过没有,桌面右击我的电脑,点击属性,点击系统保护

    sys_pro.png

desktop.png

关于Linux - About

如果说Windows是一道菜的话,那Linux就是菜谱。

你可以根据自己的口味制作你喜欢的菜。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
From: https://manjaro.org/linux/
What is Linux
Linux is the name of the kernel powering the GNU system. GNU/Linux, also called Linux is a free and open source operating system, that can be freely used and distributed.

The kernel can be seen as the bridge between software and hardware and the central module of the operating system, it is responsible for process management for application execution, memory management, allocation, and input output, device management through the use of device drivers and system call control.

Originally developed in 1991 by Finnish Programmer Linus Torvalds, Linux is an exceptionally robust and reliable kernel, which combined with the GNU system is most commonly used for Internet servers, mobile phones, tablets mostly known as Android devices. Additionally, the use of GNU/Linux as an alternative operating system, for personal computers such as desktops or laptops, has also been growing over the years, with several million users having already discovered the benefits of it.

Benefits of using Linux
It is highly efficient, very fast and any hardware device works out of the box, only on rare occasions you will need to install a device driver, The 64 bit version of Manjaro with the Xfce desktop, boots up in only a few seconds and uses only 200MB of memory to run.

Linux systems are very secure and not affected by the huge amount of Windows viruses, trojans, worms or malware out there. Anti-virus software is not required.

什么是 Linux
Linux是驱动 GNU 系统的内核的名称。GNU/Linux,也称为Linux,是一个自由开源的操作系统,可以自由使用和分发。
内核可以看作是软件和硬件之间的桥梁,是操作系统的中心模块,它负责应用程序执行的进程管理、内存管理、分配和输入输出,通过使用设备驱动程序和系统进行设备管理通话控制。

最初由芬兰程序员Linus Torvalds于 1991 年开发,Linux 是一个异常强大和可靠的内核,它与 GNU 系统相结合,最常用于互联网服务器、手机、平板电脑,通常被称为 Android 设备。此外,使用 GNU/Linux 作为台式机或笔记本电脑等个人计算机的替代操作系统,这些年来也一直在增长,数百万用户已经发现了它的好处。

使用 Linux 的好处
它非常高效,速度非常快,任何硬件设备都可以开箱即用,只有在极少数情况下您需要安装设备驱动程序,带有 Xfce 桌面的 64 位 Manjaro 版本,即使在只有 200MB 的内存的设备也可以运行,而且只需几秒钟即可启动。

Linux 系统非常安全,不受大量 Windows 病毒、木马、蠕虫或恶意软件的影响。不需要防病毒软件。

Linux我是在用了一年半Windows后才接触到的。截至本文,用过Ubuntu、Debian、Audiophile Linux(Arch Linux)、Linux Lite,Deepin用到最后选择了Debian。原因是:稳定

Debian Linux现在已经成为了我的日用主力系统,我不玩游戏。所以Linux很好的满足了我的日常听音乐(听音乐建议Windows[foobar2000万岁]或者Audiophile Linux,至少我在Debian这边的播放音质我不满意,但Audiophile Linux可还行)、编程、编辑文档等工作。

Linux使用感想很多,至少现在用了快五年Linux了(截至2021年),完全不想回Windows。Windows我应该几百年没开了吧……虽然Linux用的很爽,但是我现在却想不到说啥。或许是因为太稳定了,没有让我特别操心的地方。或许就像白开水一样,百喝不厌,却又平淡无奇,很重要,却又最容易让人忽视(就像行政班,做好了没人表扬,出了事人人骂行政)。

Linux桌面 - GNOME or KDE?

我习惯了GNOME,简洁明了,不喜欢KDE的类似Windows的桌面。KDE我用了好几次,前前后后加起来使用了大概一年的样子,最后忍无可忍切回了GNOME,虽然没有KDE好看,但就像是Linux给我的感受一样,平平淡淡就是福。

下面是我的Linux桌面,隐藏了Dash to Dock和顶栏,没有任务栏和系统托盘。但我有tint2任务栏备用,随时可以开启系统托盘。

desktop

下图是工作区

multitask

workplace

debian

Linux权限管理比较严格,很多时候需要管理员确认

admin authority

在命令行浏览网页

w3m

应用市场

software

在Docker中测试语音识别

speech2text

Linux中GIMP、Kdenlive和Audacity可以满足我日常编辑图像、视频、音频。

gimp kdenlive audacity

使用Scrcpy控制手机、安卓手机用Termux开了个远程桌面:

scrcpy vnc

给办公室的电脑添加打印机:

pr lpstat

开启服务器分享文件

http

每天到办公室第一件事:git pull

gitpull

同样使用OBS直播,Linux这边不怎么发烫,虽然音质没有Windows好,有一说一。

我的设备 - Device

笔记本 - Laptop:

配置:

1
2
3
4
5
6
7
8
笔记本型号: 惠普HP Notebook TPN-I119 14-ar105TX
CPU:i5-7200U
RAM:12G(4+8
HardDisk:256G SSD+512G SSD
GPU:Intel Corporation HD Graphics 620 + AMD Radeon M330
OS:Debian 11 bullseye
Wireless:RTL8723BE(2.4G)
蓝牙:RTL8723BENF

Linux运行情况:良好

HPNotebook

台式机 - PC:

配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
型号: 组装机
CPU+Mother Board:i5-12400+ASUS PRIME B660M-K ¥1599
RAM:16G(8+8)Kigston DDR4 3200MHz ¥269
HardDisk:Samsung 980Pro 1TB PCIe 4.0502 + Kingston SNV2S250G PCIe 4.0169
GPU:Sapphire AMD RX6600 8G ¥1471元 + Intel Corporation UHD Graphics 730
CPU Radiator:利民Thermalright AX120R SE ¥89.9
Power and Case and Radiator:Case:Huntkey航嘉超越3+Fan:3*12cm风扇+Power:航嘉WD650K 650W ¥535
Radiator:Phanteks M25-120 1*14cm ¥65
Monitor:HKC T2752Q 2K ¥649
Keyboard:双飞燕A4-Tech FX60 ¥168.9
Mouse:讯飞iFlyTek XFSA-A002
Wireless:DWA-192(RTL8814AU)(2.4G/5G)
Camera:绿联UGREEN CM678
OS:Debian 12 bookworm
合计:¥ 5517.8
仅核显主机价:¥ 3228.9

PC-Device

Linux运行情况:良好

硬件详情:linux-hardware

硬件外设 - Hardware

USB摄像头

绿联CM678

USB键盘

双飞燕A4-Tech FX60

FN+Esc:是否锁定功能键

FN + ↑/↓:屏幕亮度

FN + ←/→:键盘背光亮度

USB刻录光驱

绿联CM138

USB蓝牙

(不支持)

绿联CM390(RTL8761BUV)

USB无线网卡

5GHz:AC600M RTL8811CU

2.4GHz:RTL8192CU 支持热点

其他设备

华为麒麟990(8核arm64)+Kylin v10 sp1(银河麒麟):https://linux-hardware.org/?probe=b3d022d177

华为鲲鹏920(8核arm64)+UOS(统信):https://linux-hardware.org/?probe=9c60527586

使用经验 - Something to share with you

1
2
3
4
5
我们信任您已经从系统管理员那里了解了日常注意事项。
总结起来无外乎这三点:
1) 尊重别人的隐私。
2) 输入前要先考虑(后果和风险)。
3) 权力越大,责任越大。

关于Linux的安全。Linux这边我就装了个Clam AV 病毒扫描软件。说实在的,要安全还是去Windows会好一点,杀毒软件会牛一点。因为Linux这边真的只能靠自己维护系统安全了,Linux病毒有,很多,很多挖矿病毒等等。所以我平时用Linux都很注意软件来源,不随便运行脚本。软件包几乎都是APT仓库的,或者Flatpak仓库。不得不说Flatpak很笨重……

Fluxbox [引用Install-Audiophile-Linux-v5-with-UEFI-GPT文章]

防火墙很重要,iptable[尽管这只是设置拦截规则吧]自己设置好。实在不会设置的小白去装个GUFW就很容易了。

Linux一般都有一个专门的软件仓库,就像苹果的App Store一样。

Linux发行版推荐 - About Linux Distributions

这里是作为桌面环境跟大家做推荐,高级用户用的Gentoo啦还有LFS我这里不讲。之外的LinuxfxSUSEDeepin等等我也不说,嘿嘿,我就说我喜欢的发行版和推荐理由,个人主观性强,仅供参考。

配置好的用Debian sid或者Manjaro。

  • Debian
    • Debian stable稳定是稳定,软件包太旧。所以选择sid,真香。至于Ubuntu啊,开箱即用当然比Debian好,但是自从它崩过两次,被我啦黑了,Debian开箱即用差点,调教好是真的爽。当然,如果你不在乎新软件,请使用Debian stable,因为Debian stable我用了三年,没啥毛病……被我当作实验品折腾(因为是当时刚转Linux,选了一个乱搞,什么Wine什么乱七八糟都搞过,嗯,比Ubuntu稳定「Ubuntu就是被我瞎搞,搞炸了……」)。
    • 习惯了apt !!而且,很多地方默认提供deb软件包,方便。
  • manjaro
    • 其实就是Arch家族啦,但manjaro开箱即用比Arch好,所以推荐它而不是推荐Arch。
    • 软件包新,rolling不香吗?sudo pacman -Syu不香吗??
    • pacman确实简单粗暴,不像apt啰哩啰唆的。

配置不好的用Arch Linux + Fluxbox。

  • Fluxbox:这是一个窗口管理器「Windows Manager」,不是桌面环境「Desktop Environment ,比如GNOME、KDE、Xfce4」,我也是有用它的,确实让我的旧电脑运行的舒畅的起飞,界面清新、反应迅速。
  • 或者Xfce4也可以,我把Xfce4配置成了Windows10的模样,这样给父母用会比较习惯。

Xfce4-Windows

[引用Install-Audiophile-Linux-v5-with-UEFI-GPT文章]

快速打造我的工作台 - Todo when setting up a new Debian GNU/Linux

Debian镜像默认没有闭源驱动,所以如果你想要载带有闭源驱动的镜像请点击 这里 | 固件打包下载在 这里 | 关于固件问题请查看 手册这里

脚本文件已经转移到

Github > https://github.com/rmshadows/rm_scripts

Gitee [不一定最新] > https://gitee.com/rmshadows/rm_scripts

1
2
3
4
5
6
7
git clone https://github.com/rmshadows/rm_scripts.git

git clone https://gitee.com/rmshadows/rm_scripts.git

wget https://gitee.com/rmshadows/rm_scripts/raw/main/Debian_GNOME_Init/Debian_Bullseye_GNOME_Setup.sh

wget https://github.com/rmshadows/rm_scripts/raw/main/Debian_GNOME_Init/Debian_Bullseye_GNOME_Setup.sh

脚本内容大致如下:(此未旧版本内容,新版本请查看仓库!)

更新时间:2021-10-27

检查点中如无必选两个字,默认为可选、可配置项目。

(滞后)表示放于脚本末尾执行。

  • 运行环境检查
    • 首先检查用户是否在sudo组中且免密码。如果没有,临时添加$USER ALL=(ALL)NOPASSWD:ALL/etc/sudoers文件中(运行结束或者Ctrl+c中断会自动移除)。
    • 检查是否时GNOME桌面,不是则警告、退出。
  • 检查点一
    • 临时成为免密sudoer(必选)。
    • 添加用户到sudo组。
    • 设置用户sudo免密码。
    • 默认源安装apt-transport-https ca-certificates wget gnupg2 gnupg lsb-release
    • 更新源、更新系统。
    • 配置unattended-upgrades
  • 检查点二
    • 替换vim-tiny为vim-full
    • 替换Bash为Zsh
    • 替换默认的ZSHRC文件
    • 添加/usr/sbin到用户的SHELL环境变量
    • 替换root用户的SHELL配置
    • 安装bash-completion
    • 安装zsh-autosuggestions
  • 检查点三
    • 自定义自己的服务(运行一个shell脚本)
    • 配置Nautilus右键菜单以及Data、Project、Vbox-Tra、Prog、Mounted文件夹
    • 配置启用NetworkManager、安装net-tools
    • 设置网卡eth0为热拔插模式以缩短开机时间。如果没有eth0网卡,发出警告、跳过
    • 配置GRUB网卡默认命名方式
  • 检查点四

    • 从APT源安装常用软件
    • 脚本最后再安装的应用(滞后)
    • 安装Python3

      • 配置Python3源为清华大学镜像
    • 安装配置Apache2

      • 配置Apache2 共享目录为 /home/HTML(必选)
      • 是否禁用Apache2开机自启
    • 安装配置Git

      • 配置User Email
    • 安装配置SSH

    • 安装配置npm

      • 安装cnpm
      • 安装hexo
      • 安装nodejs(必选)
    • 安装VirtualBox(滞后)

    • 安装Anydesk(滞后)

    • 安装Typora(滞后)

    • 安装sublime text(滞后)

    • 安装teamviewer(滞后)

    • 安装wps-office(滞后)

    • 安装skype(滞后)

    • 安装docker-ce(滞后)

    • 安装网易云音乐(滞后)

    • 禁用第三方软件仓库更新(提升apt体验)(滞后)

  • 检查点五

    • 配置中州韵输入法(fcitx、ibus、fcitx5)
    • 配置词库(github导入公共词库、导入本地词库)
  • 检查点六

    • 配置SSH Key(新密钥,导入)
  • 检查点七(谨慎使用!可能弄坏您的应用程序!)

    • 备份原有的dconf配置
    • 导入GNOME Terminal的dconf配置
    • 导入GNOME 您自定义修改的系统内置快捷键的dconf配置
    • 导入GNOME 自定义快捷键的dconf配置
    • 导入GNOME 选区截屏配置
    • 导入GNOME 屏幕放大镜配置
    • 导入GNOME 电源配置
  • 最后一步

    • 设置用户目录权限

截屏

使用演示:

Debian 11 部署脚本 2021-10:

Debian 10 部署脚本 2020-10:

使用截屏(旧版本):

scr01

scr02

Linuxvswin

软件包清单——Applications

  • aircrack-ng——aircrack-ng
  • apt-listbugs——apt显示bug信息
  • apt-listchanges——apt显示更改
  • apt-transport-https——apt-transport-https
  • arp-scan——arp-scan
  • axel——axel下载器
  • bash-completion——终端自动补全
  • bleachbit——系统清理软件
  • blender——3D开发
  • bridge-utils——网桥
  • build-essential——开发环境
  • bustle——D-Bus记录
  • calibre——Epub等多格式电子书阅读器
  • cewl——CeWL网站字典生成(关键词采集)
  • cifs-utils——访问Windows共享文件夹
  • clamav——Linux下的杀毒软件
  • cmake——cmake
  • cowpatty——wireless hash
  • crunch——字典生成
  • cups——cups打印机驱动
  • curl——curl
  • dislocker——查看bitlocker分区
  • dos2unix——将Windows下的文本文档转为Linux下的文本文档
  • drawing——GNOME画图
  • dsniff——网络审计
  • ettercap-graphical——ettercap-graphical
  • extremetuxracer——滑雪游戏
  • flatpak——flatpak平台
  • fonts-lexi-saebom——韩文字体,韩文支持
  • freeplane——思维导图
  • fritzing——电路设计
  • fping——fping
  • fuse——配合dislocker查看bitlocker分区
  • g++——C++
  • gajim——即时通讯
  • gcc——C
  • gedit-plugin*——Gedit插件
  • gimp——gimp图片编辑
  • glance——一个可以代替htop的软件
  • gnome-recipes——GNOME西餐菜单
  • gnome-shell-extension-appindicator——GNOME扩展
  • gnome-shell-extension-arc-menu——GNOME扩展+ARC菜单
  • gnome-shell-extension-autohidetopbar——GNOME扩展+自动隐藏顶栏
  • gnome-shell-extension-bluetooth-quick-connect——GNOME扩展+蓝牙快速连接
  • gnome-shell-extension-caffeine——GNOME扩展+防止屏幕休眠
  • gnome-shell-extension-dashtodock——GNOME扩展+DashtoDock侧栏
  • gnome-shell-extension-dash-to-panel——GNOME扩展+任务栏
  • gnome-shell-extension-desktop-icons——GNOME扩展+桌面图标
  • gnome-shell-extension-disconnect-wifi——GNOME扩展+断开wifi
  • gnome-shell-extension-draw-on-your-screen——GNOME扩展+屏幕涂鸦
  • gnome-shell-extension-freon——GNOME扩展+顶栏显示磁盘温度
  • gnome-shell-extension-gamemode——GNOME扩展+游戏模式
  • gnome-shell-extension-hard-disk-led——GNOME扩展
  • gnome-shell-extension-hide-activities——GNOME扩展
  • gnome-shell-extension-hide-veth——GNOME扩展
  • gnome-shell-extension-impatience——GNOME扩展
  • gnome-shell-extension-kimpanel——GNOME扩展
  • gnome-shell-extension-move-clock——GNOME扩展+移动时钟
  • gnome-shell-extension-multi-monitors——GNOME扩展+多屏幕支持
  • gnome-shell-extension-no-annoyance——GNOME扩展
  • gnome-shell-extension-panel-osd——GNOME扩展
  • gnome-shell-extension-pixelsaver——GNOME扩展
  • gnome-shell-extension-prefs——GNOME扩展
  • gnome-shell-extension-redshift——GNOME扩展
  • gnome-shell-extension-remove-dropdown-arrows——GNOME扩展
  • gnome-shell-extensions——GNOME扩展
  • gnome-shell-extensions-gpaste——GNOME扩展+GNOME剪辑板
  • gnome-shell-extension-shortcuts——GNOME扩展
  • gnome-shell-extension-show-ip——GNOME扩展+顶栏菜单显示IP
  • gnome-shell-extension-system-monitor——GNOME扩展+顶栏资源监视器
  • gnome-shell-extension-tilix-dropdown——GNOME扩展
  • gnome-shell-extension-tilix-shortcut——GNOME扩展
  • gnome-shell-extension-top-icons-plus——GNOME扩展
  • gnome-shell-extension-trash——GNOME扩展
  • gnome-shell-extension-volume-mixer——GNOME扩展
  • gnome-shell-extension-weather——GNOME扩展+天气
  • gnome-software-plugin-flatpak——GNOME Flatpak插件
  • gnucash——GNU账本
  • grub-customizer——GRUB或BURG定制器
  • gtranslator——GNOME本地应用翻译编辑
  • gufw——防火墙
  • handbrake——视频转换
  • hugin——全景照片拼合工具
  • homebank——家庭账本
  • hostapd——AP热点相关
  • hping3——hping3
  • htop——htop彩色任务管理器
  • httrack——网站克隆
  • inotify-tools——inotify文件监视
  • kdenlive——kdenlive视频编辑
  • konversation——IRC客户端
  • krename——KDE社区开发的批量文件重命名
  • krfb——KDE社区开发的VNC服务器
  • libblockdev*——文件系统相关的插件
  • libgtk-3-dev——GTK3
  • linux-headers-$(uname -r)——Linux Headers
  • lshw——显示硬件
  • make——make
  • masscan——masscan
  • mc——MidnightCommander
  • mdk3——mdk3
  • nautilus-extension-*——nautilus插件
  • ncrack——ncrack
  • neofetch——系统信息
  • net-tools——ifconfig等工具
  • nmap——nmap
  • nodejs——nodejs
  • npm——nodejs包管理器
  • obs-studio——OBS
  • openssh-server——SSH
  • paperwork-gtk——办公文档扫描
  • pavucontrol——PulseAudioVolumeControl
  • pkg-config——pkg-config
  • pulseeffects——pulse audio的调音器
  • pwgen——随机密码生成
  • qmmp——qmmp音乐播放器
  • reaver——无线WPS测试
  • sed——文本编辑工具
  • silversearcher-ag——Ag快速搜索工具
  • slowhttptest——慢速HTTP链接测试
  • smbclient——SMB共享查看
  • sqlmap——sqlmap
  • sshfs——挂载远程SSH目录
  • sslstrip——https降级
  • supertuxkart——Linux飞车游戏
  • sweethome3d——室内设计
  • synaptic——新立得包本地图形化管理器
  • tcpdump——tcpdump
  • tig——tig(类似github桌面)
  • tree——树状显示文件夹
  • traceroute——路由跟踪
  • vim——VIM编辑器
  • vlc——vlc视频播放器
  • wafw00f——网站防火墙检测
  • websploit——Web渗透测试
  • wget——wget网络下载工具
  • wireshark——wireshark
  • xdotool——X自动化工具
  • xprobe——网页防火墙测试
  • zenity——显示GTK+对话框
  • zhcon——tty中文虚拟
  • zsh——zsh
  • zsh-autosuggestions——zsh插件

GNU/Linux Notes

下文记录的是个人使用Debian Linux、Kali Linux、Arch Linux四年来的部分笔记。大部分是通用的,但有一部分只能在Debian上实现,有一部分只能在Kali上实现,还有一部分只能在Arch上实现,所以仅供参考。

Debian官方给新手的指导

部分常用命令示例

  • ar —— 查看归档文件

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    # 查看deb归档内容
    $ ar t /var/cache/apt/archives/apt_1.4~beta1_amd64.deb
    debian-binary
    control.tar.gz
    data.tar.xz
    # 查看debian-binary中的归档格式
    $ ar p /var/cache/apt/archives/apt_1.4~beta1_amd64.deb debian-binary
    # 查看control.tar.gz 这里面一般包含包的源信息
    $ ar p /var/cache/apt/archives/apt_1.4~beta1_amd64.deb control.tar.gz | tar -tzf -
    # 最后一个data文件包含将要安装到系统内的文件
    $ ar p /var/cache/apt/archives/apt_1.4~beta1_amd64.deb data.tar.xz | tar -tJf
  • update-alternatives :设置版本偏好,见下文Linux的使用技巧。

  • blkid : 显示GPT磁盘信息uuid

  • cd - :回到上个工作区

  • chgrp 【grp】 【file】 :修改文件所有组为【】

  • chmod u=【】,g=【】,o=【】 【file】 :修改权限

  • chmod -R a+X 【path】 :只要path中有文件存在x参数则a=ugo全部添加x参数

  • chown -hR 【username】 . :当前目录及子目录所有者为【】

  • df 【option】 :显示磁盘剩余(可选项null、-h【人性化显示】、-T【显示文件系统类型】)

  • dmesg : 查看内核日志

  • du :显示文件大小

    • du -sh ./* :显示当前文件夹大小
    • du -h --max-depth=1 :指定深度
    • du -s | sort -nr :排序
  • echo 【String】 :显示字符

  • echo 【String】> 【path:file】 :修改某文件内容为String

  • echo 【String】>> 【path:file】 :在某文件原内容下行加上String

  • echo $PATH | tr ':' '\n' :把‘:’替换为“\n”

  • find 【path】 【string】 :搜索文件 如: find /test -name ‘epc

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    (1)find / -amin -10   # 查找在系统中最后10分钟访问的文件(access time)
    (2)find / -atime -2   # 查找在系统中最后48小时访问的文件
    (3)find / -empty   # 查找在系统中为空的文件或者文件夹
    (4)find / -group cat   # 查找在系统中属于 group为cat的文件
    (5)find / -mmin -5   # 查找在系统中最后5分钟里修改过的文件(modify time)
    (6)find / -mtime -1   #查找在系统中最后24小时里修改过的文件
    (7)find / -user fred   #查找在系统中属于fred这个用户的文件
    (8)find / -size +10000c  #查找出大于10000000字节的文件(c:字节,w:双字,k:KB,M:MB,G:GB)
    (9)find / -size -1000k   #查找出小于1000KB的文件

    find / -name [software]
  • flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo :Flatpak添加远程仓库 https://flathub.org/home

  • free 【option】 :显示内存(可选项:null、-m【MB显示】、-g【GB显示】)

  • grep 【string】 :在……搜索string,如ps aux|grep top

    1
    2
    3
    4
    5
    6
    (1)grep ‘test’ d*  #显示所有以d开头的文件中包含 test的行
    (2)grep ‘test’ aa bb cc    #显示在aa,bb,cc文件中包含test的行
    (3)grep ‘[a-z]{5}’ aa   #显示所有包含每行字符串至少有5个连续小写字符的字符串的行
    (4)grep magic /usr/src  #显示/usr/src目录下的文件(不含子目录)包含magic的行
    (5)grep -r magic /usr/src  #显示/usr/src目录下的文件(包含子目录)包含magic的行
    (6)grep -w pattern files :只匹配整个单词,而不是字符串的一部分(如匹配’magic’,而不是’magical’)
  • gzip :压缩文件gzip -c 、解压gunzip

  • id :显示当前用户权限

  • journalctl 【option】 :日志(可选项:null、-r【倒序】、-f【连续输出】、-u【指定服务单元】)

  • kill -9(强制)/-15(优雅结束) 【pid】 :结束进程

  • killall -9 【service name】 :结束服务相关进程

  • less 【big txt file】 :查看大文件

  • ln

    • ln -s [file path] [目标文件夹] :创建软链接
    • ln -spwd/ehbio2.fa ../data :“`”为键盘 Esc 下面的按键,写在反引号内的命令会被运行,运行结果会放置在反引号所在的位置
  • ls 【选项】 :列出文件夹内容(可选项:-l【详细选项、所有者】、-a【显示隐藏文件】、-h【人性化显示单位】)

    • lsusb :;列出USB设备
    • lspci : 列出PCI设备
    • lshw : 列出
    • lsmod :列出驱动模块
    • lsof -i : 列出联网情况(netstat -nlpss -lntpd | grep :22lsof -i tcp:22也差不多)
  • man 【选项】 【要查询的命令】 :查看命令的详细帮助手册

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    举例:man 2 read ——> 查看分类2下的read命令帮助
    man手册分类:
    1. 可以从命令行执行的命令
    2. 系统调用(内核函数)
    3. 库函数 lib
    4. 设备 dev
    5. 配置文件
    6. 游戏
    7. 宏、标准等
    8. 系统管理命令
    9. 内核例程
    • apropos 【问题】 :和manpinfo类似的帮助手册
    • pinfo :友好的命令帮助手册,和man命令类似
    • yelp :GNOME的帮助手册
  • netstat -nlp : 查看进程、端口使用情况

  • passwd 【-l/-u】 【username】 :冻结 或者 解冻账户

  • pkill -9 pts/0 :踢出pts:0的用户

    • echo “你被管理员踢出了” > /dev/pts/0 && fuser -k /dev/pts/0
    • echo “你被管理员踢出了” > /dev/tty5 && fuser -k /dev/tty5
  • ps aux :显示正在运行的进程

    • ps -ef :查看服务进程
  • pwd :显示当前工作区

  • pwgen :密码生成器

  • rename 'test' 'here' test*.txt : 把test*.txt的文件中带有test的字符串替换为here

  • rmdir :目录删除

  • rpm :Cent OS 的包管理器

    • rpm -qa :查看rpm安装的软件
    • rpm -e 【package name】 : rpm卸载软件
    • rpm -e 【package name】 -nodeps :忽略依赖关系卸载软件
    • rpm -ivh 【package】:安装软件
    • rpm -Uvh 【package】 :升级软件
  • seq :产生数字

    • seq 1 10 :产生从 1 到 10 的数
    • seq -s ' ' 1 10 :步长为 1,用空格分割
    • seq -s ' ' 1 2 10 :如果有 3 个数,中间的数为步长,最后一个始终为最大值
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    cat <(seq 0 3 17) <(seq 3 6 18) >test
    ct@ehbio:~$ cat test
    0
    3
    6
    9
    12
    15
    3
    9
    15
  • systemctl 【选项】 【服务名】 :Linux服务管理命令(很重要 ,systemctl:比service更为强大)

    • systemctl status 【服务名】 :显示服务状态
    • systemctl enable/disable 【服务名】 :设置开机启动、禁止
    • systemctl start/stop/reload/restart 【服务名】 :启动、停止、重载、重启服务
    • systemctl list-unit-files :查看所有服务情况
    • systemctl list-unit-files |grep enabled :查看开机启动的服务
    • systemctl mask NAME.service :禁止某服务设定为开机自启
    • systemctl umask NAME.service :取消禁止某服务设定为开机自启
    • systemctl is-active NAME.service :查看某服务当前激活与否的状态
    • systemctl list-units --type service :查看所有已激活的服务
    • systemctl list-dependencies NAME.service :查看服务的依赖关系
    • systemd-cgls :以树形列出正在运行的进程,它可以递归显示控制组内容
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    # Kali默认开机自启的服务
    accounts-daemon.service enabled
    anacron.service enabled
    autovt@.service enabled
    binfmt-support.service enabled
    console-setup.service enabled
    cron.service enabled
    dbus-org.freedesktop.ModemManager1.service enabled
    dbus-org.freedesktop.nm-dispatcher.service enabled
    dbus-org.freedesktop.timesync1.service enabled
    getty@.service enabled
    haveged.service enabled
    keyboard-setup.service enabled
    lxc.service enabled
    ModemManager.service enabled
    network-manager.service enabled
    networking.service enabled
    NetworkManager-dispatcher.service enabled
    NetworkManager-wait-online.service enabled
    NetworkManager.service enabled
    pppd-dns.service enabled
    rsync.service enabled
    rsyslog.service enabled
    smartd.service enabled
    smartmontools.service enabled
    syslog.service enabled
    systemd-fsck-root.service enabled-runtime
    systemd-remount-fs.service enabled-runtime
    systemd-timesyncd.service enabled
    dm-event.socket enabled
    lvm2-lvmpolld.socket enabled
    pcscd.socket enabled
    uuidd.socket enabled
    nfs-client.target enabled
    remote-fs.target enabled
    apt-daily-upgrade.timer enabled
    apt-daily.timer enabled
    e2scrub_all.timer enabled
    exim4-base.timer enabled
    fwupd-refresh.timer enabled
    ======================================================================================
    对于target类型的文件是如何进行管理的,我们在刚才的文章中写道unit的常见类型,其中target类型就是用于实现其系统启动的运行级别,一共有七个运行级别,从0开始,到6结束,我们介绍一下这七个运行级别。

    0:关机;
    1:单用户模式,无网络连接,不运行守护进程,不允许非超级用户登录;
    2:多用户模式,无网络连接,不运行守护进程;
    3:多用户模式,正常启动系统;
    4:用户自定义;
    5:多用户模式,图形界面;
    6:重启;
  • tail /var/log/kern.log :查看最新内核日志

    1
    2
    /lib/modules/[kernel version]/kernel :内核模块
    /lib/modules/[kernel version]/modules.dep:depend文件
  • uname -a :显示系统信息(kernel【内核】+hostname【主机名】+kernel release【内核发布】+kernel version【内核版本】+machine type【设备架构】+name of the OS【系统名】)

    1
    Linux Blanc 4.19.0-11-amd64 #1 SMP Debian 4.19.146-1 (2020-09-17) x86_64 GNU/Linux
  • usermod -l 【new name】 【old name】 :修改用户名

  • w :显示当前登录的用户

  • which/type 【command】 :显示某命令位置

  • whois 【查询的域名】 : 域名注册查询

    • nslookupdig 命令也可以查询。dig更权威,nslookup只是查询本地cache数据。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    dig @ns.watson.ibm.com ycyijia.cn/wx 指定DNS查询域名
    whois -h whois.apnic.net [IP]

    一些在线查询网站:
    http://www.cz88.net/ IP物理地址
    http://www.maxmind.com
    https://searchdns.netcraft.com/
    https://toolbar.netcraft.com/site_report?url= 后面接网址
    http://www.ip-adress.com/reverse_ip 反向查询IP

    https://www.exploit-db.com/google-dorks GHDB利用谷歌收集信息
    SiteDigger or SearchDiggity Windows下的检索工具
  • yum list installed :yum包管理器列出已安装的。

软件管理相关

APT & DPKG

apt和dpkg是Debian系Linux的软件包管理器。可以帮助你从Linux官方仓库(类似苹果的App Store)安装软件。其他包管理器还有yum、pacman等。

对于小白,apt至少需要掌握:

1
2
3
4
5
6
7
8
9
学会编辑apt源文件: /etc/apt/sources.list —— vi /etc/apt/sources.list
apt-get update —— 更新软件包索引列表(一般都是要先运行这个命令)
apt-get upgrade —— 更新软件
apt-get dist-upgrade —— 更新系统(包括软件)
apt-get install 【软件包名】 —— 安装某软件,软件包名可以按Tab按键补齐,前提是安装了bash-completion软件包(apt install bash-completion)。
apt install 【】 —— 安装本地deb文件
apt-get remove 【软件包名】 —— 卸载软件
apt-get search 【软件包名】 —— 搜索软件
apt install -f —— 【修复破损的安装】

对于小白dpkg至少要掌握:

1
2
dpkg -i 【本地deb软件包】 —— 安装本地deb软件包,一般是安装在/opt/目录
dpkg -r 【本地deb软件包】 —— 卸载已安装的软件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apt-get ==>  apt 					
|_________|
|
V
GUI(third party designed)
____|____
| |
synaptic aptitude

dpkg -i xxx.deb ==> dpkg --unpack xxx.deb + dpkg --configure xxx.deb + Processing triggers ➥ 3.4.1-9 (报错示例)

当某些安装包中有已经安装的模块组件,dpkg会拒绝安装他,但是可以用下面命令覆盖
dpkg -i --force-overwrite zsh_5.2-5+b1_amd64.deb 强制安装

dpkg: error processing /var/cache/apt/archives/libgdm_3.8.3-2_amd64.deb (--unpack):
trying to overwrite ’/usr/bin/gdmflexiserver’, which is also in package gdm3

APT常用命令解析

  • sudo apt remove --dry-run [软件包]:apt模拟运行

  • apt list 【包名】 :显示软件包状态

    1
    2
    正在列表... 完成
    zhcon/stable,now 1:0.2.6-16 amd64 [已安装,自动]
  • apt list --installed :查看已安装的

  • apt list --upgradable :显示可更新的包

  • apt -o Dpkg::Options::=”--force-overwrite” install zsh :要求强制安装覆盖—通过向dpkg 传递参数

  • {APT::Clean-Installed} 参数可以防止删除当前安装的deb包裹,因为APT通常在安装完成后自动删除包


  • apt-cache :显示APT的数据库,每次apt update 会不同

  • apt-cache depends 【package】 :查看依赖

  • apt-cache dumpavail : 所有可用包的头信息,即标题

  • apt-cache pkgnames : 显示至少在cache中出现过一次的包的列表

  • apt-cache policy :显示包优先度及单包

  • apt-cache rdepends 【package】 :查看被依赖关系

  • apt-cache search 【keyword】 : 搜索包含关键词的包。apt-cache search仅仅是低级搜索,返回信息可能太多或无用,所以axi-cache search term 用来高级搜索。

    • axi-cache search 【forensics graphical】 :【】内是搜索的关键词,结果以相关度进行排序。
    • apt-cache search ^linux-source: 显示kali包装的最新版本内核
  • apt-cache show package :显示包的头信息,版本、依赖组件、维护者、简介

    This feature is particularly useful in determining the packages that are installed via meta-packages, such as kali-linux-wireless, kali-linux-web, and kali-linux-gpu .apt show, aptitude search, and aptitude show也是一样的。

    apt-cache show nginx | grep -i version :查询其他版本


  • apt-get autoremove : 清除自动安装的不需要的依赖
  • apt-get autoclean :只清理/var/cache/apt/archives/中不再需要的、无法从镜像中再安装的包

  • apt-get build-dep 【package】 :安装该包的编译环境

  • apt-get check :检查依赖是否被破坏
  • apt-get clean : 完全清空/var/cache/apt/archives/

  • apt-get dist-upgrade :升级系统

    避免失败的更新:查看新版本的更改,apt-listchanges 更新说明:/usr/share/doc/package/NEWS.Debian

  • apt-get dselect-upgrade :使用 dselect 升级

  • apt-get full-upgrade :完全升级系统

    • 对于重要的版本升级,应使用apt full-upgrade ,这将会删除旧的没用的包,添加新的组件 (apt-get 没有)—— It is so simple that it hardly needs explanation: APT’s reputation is based on this great functionality.
    • 关于更新:apt-get 要求比 apt 高,因为它拒绝安装此前未安装过的包。
  • apt-get install -s apache2 :apt模拟安装某包

  • apt-get install 【包名】 : 安装软件

    • 通过添加后缀来同事安装、卸载包裹:
      • apt install package1 package2-
      • apt remove package1+ package2
    • apt install package=version :指定版本
    • apt install package/distribution :指定源
    • apt install PackageName:architecture :指定架构来安装包
    • apt install 【本地deb文件】 :apt安装本地Deb软件包
  • apt-get purge 【包名】 : 清除关联文件和依赖组件 「谨慎」

  • apt-get reinstall 【包名】 或者 apt-get install 【package】 --reinstall : 当不小心修改了某些文件导致某包被破坏,重新安装应使用--reinstall。如果系统被攻击了,则不应该使用--reinstall 因为aptdpkg可能已经被恶意软件所代替。

    1
    Using apt --reinstall to restore packages modified during an attack will certainly not recover the system as it was.After an attack, you can’t rely on anything: dpkg and apt might have been replaced by malicious programs, not reinstalling the files as you would like them to. The attacker might also have altered or created files outside the control of dpkg
  • apt-get remove 【包名】 : 卸载软件

    将保留配置文件与用户数据,但会删除依赖包。

    APT will automatically delete the packages that depend on the package that is being removed.

  • apt-get search :搜索软件包

  • apt-get show 【包名】 :显示包信息

    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
    Package: zhcon
    Version: 1:0.2.6-16
    Priority: optional
    Section: utils
    Maintainer: Debian Chinese Team <chinese-developers@lists.alioth.debian.org>
    Installed-Size: 437 kB
    Depends: zhcon-data, libc6 (>= 2.15), libgcc1 (>= 1:3.0), libgpm2 (>= 1.20.7), libncurses6 (>= 6), libpth20 (>= 2.0.7), libstdc++6 (>= 5.2), libtinfo6 (>= 6), unicon-imc2
    Tag: accessibility::input, accessibility::ocr, culture::chinese,
    culture::japanese, culture::korean, culture::taiwanese,
    interface::commandline, interface::framebuffer, interface::text-mode,
    role::program, scope::utility, uitoolkit::ncurses, use::converting,
    works-with::text, works-with::unicode
    Download-Size: 296 kB
    APT-Manual-Installed: no
    APT-Sources: https://mirrors.tuna.tsinghua.edu.cn/debian buster/main amd64 Packages
    Description: Fast console CJK system using FrameBuffer (main program)
    Zhcon is a fast Linux console Chinese system which supports framebuffer
    device. It can display Chinese, Japanese or Korean double byte characters
    on console.
    .
    Features include:
    * Full support for Linux FrameBuffer device (from 640x480x8bpp to
    1024x768x32bpp)
    * Multiple language support (GB2312, GBK, BIG5, JIS, KSC)
    * Auto-detect and convert between GB2312 and BIG5 encoding (like hztty)
    * Hot key to change language encoding on the fly
    * Can use input method from MS Windows 98 Chinese version or UCDOS for
    MS-DOS
  • apt-get source 【package】 :获取源代码包

  • apt-get update : 更新软件包索引

  • apt-get upgrade :升级软件

    • apt -t kali-rolling upgrade :指定源进行更新。

      如果每次都想指定该源进行更新,在/etc/apt/apt.conf.d/local文件中加入:APT::Default-Release ”[name of the distribution](如kali-rolling)”;


  • apt-key add < key.asc :用于添加第三方源的key
  • apt-key fingerprint :显示/etc/apt/trusted.gpg 信任的密钥
    • gui-apt-key :利用图形界面

  • apt源:

    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
    /etc/apt/sources.list
    举例:
    deb https://mirrors.tuna.tsinghua.edu.cn/debian/ buster main contrib non-free
    deb http://http.kali.org/kali kali-rolling main non-free contrib

    参数一:
    • deb for binary packages,
    • deb-src for source package
    参数二:
    URL 支持:file:// ;http:// ;ftp:// ;cdrom:// ;分别是本地源、网络、FTP、CD;CD源需要另外设置!
    参数三:
    The syntax of the last field depends on the structure of the repository
    × Main contains all packages that fully comply with the Debian Free Software Guidelines
    × The non-free archive is different because it contains software that does not (entirely) conform to these principles but which can nevertheless be distributed without restrictions
    × Contrib (contributions) is a set of open source software that cannot function without some nonfree elements.

    关于Kali镜像源:
    如果Kali更新源失败
    curl -sI http://http.kali.org/README 查看被重定向的地址
    If the problem persists, you can edit /etc/apt/sources.list and hardcode the
    name of another known working mirror in place of (or before) the http.kali.org
    entry。
    http.kali.org 可以引导你到最近的镜像网站
    http://cdimage.kali.org
    If you want to request a list of official Kali Linux Mirrors, you can add .mirrorlist to any valid URLpointing to http.kali.org or cdimage.kali.org.
    http://http.kali.org/README.mirrorlist
    http://cdimage.kali.org/README.mirrorli
  • apt 优先级

    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    In more concrete terms, a package whose priority is less than 0 will never be installed. A package with a priority ranging between 0 and 100 will only be installed if no other version of the package is already installed. With a priority between 100 and 500, the package will only be installed if there is no other newer version installed or available in another distribution. A package of priority between 501 and 990 will only be installed if there is no newer version installed or available in the target distribution. With a priority between 990 and 1000, the package will be installed except if the installed version is newer. A priority greater than 1000 will always lead to the installation of the package even if it forces APT to downgrade to an older version

    priority:
    <0 ==> 优先级小于0的包永远不会被安装 ,除非显示指定
    0-100 ==> 只有在尚未安装包的其他版本时,才会安装
    100-500 ==> 只有不存在更新版本的包在其他源或者系统内时才会被安装
    501-990 ==> 只有不存在更新版本的包在系统内或者目标源
    990-1000 ==> 除非有更新版本才不会安装
    >1000 ==> 即使是低版本也会被安装

    APT优先原则:/etc/apt/preferences 或者/etc/apt/preferences.d/中的任何文件:
    --------------------------------------------------------------
    # 正常情况下kali-bleeding-edge源的优先级是1
    Package: *
    Pin: release a=kali-bleeding-edge
    Pin-Priority: 1
    --------------------------------------------------------------
    # 指定尽量用kali源
    Package: *
    Pin: release o=Kali
    Pin-Priority: 900

    Package: *
    Pin: release o=Debian
    Pin-Priority: -10
    --------------------------------------------------------------
    # 指定某包的优先级 man apt_preferences 查看手册
    Package: perl
    Pin: version 5.22*
    Pin-Priority: 1001
    --------------------------------------------------------------
    # 添加comments(注释)
    Explanation: The package xserver-xorg-video-intel provided
    Explanation: in experimental can be used safely
    Package: xserver-xorg-video-intel
    Pin: release a=experimental
    Pin-Priority: 500
    --------------------------------------------------------------

    如果apt install package/unstable失败提示缺少依赖组件,加上 -t unstable 让APT从指定源寻找安装依赖。这种情况安装下的包在apt upgrade时只会按照安装源的信息更新。
    e.g.:
    1】假设从kali-rolling(由于是目标源v1在kali-rolling上是P=990)安装v1(P=100),而v2,v3分别在kali-dev(P=500)和debian-unsable可用(P=500)[未安装版本的优先级都是500]。所以更新只会安装P=990从kali-rolling.
    2】假设从kali-dev(由于是目标源v1在kali-rolling上是P=990)安装v2(P=100),而v1,v3分别在kali-rolling(P=990)[v1<v2,P<1000,丢弃]和debian-unsable可用(P=500)。所以更新只会安装P=500的更新版本v3,从debian-unstable。

    如果您不希望从Kali Dev安装的包迁移到Debian Unstable,那么必须为来自Debian Unstable的包分配低于500(例如490)的优先级。您可以修改/etc/apt/preferences以达到以下效果:
    Package: *
    Pin: release a=unstable
    Pin-Priority: 490

APT其他补充:

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
33
=========================================================================================
通过其他包的依赖安装的包叫做automatic,这通常还包括库。
apt autoremove 来卸载这些不再需要的依赖
apt-mark auto package 来标记某个你不怎么需要的包为依赖包,这样就可以在不需要他时由APT自动删除他
apt-mark manual package 则相反
如果你有aptitude,你可以使用aptitude why package来查看为什么这个包还存在于系统。
$ aptitude why python-debian
i aptitude Recommends apt-xapian-index
i A apt-xapian-index Depends python-debian (>= 0.1.15)
=========================================================================================
!!: 要谨慎使用 { --force-*} 的参数,因为这可能导致APT工具不能够正常使用,直到系统恢复正常。这通常见于在某次强制安装一个缺乏依赖组件或者不兼容的软件后。解决办法通常是安装缺失的依赖组件或者卸载那个有问题的包。出现这种情况的报错常见下图:
# apt full-upgrade
[...]
You might want to run ’apt-get -f install’ to correct these.
The following packages have unmet dependencies:
rdesktop: Depends: libc6 (>= 2.5) but 2.3.6.ds1-13etch7 is installed
E: Unmet dependencies. Try using -f .

如果你是勇敢的。坚信自己分析是正确的,你可以使用-f来忽略冲突。如果你希望继续能够使用APT等工具,你需要编辑、修改甚至重写/var/lib/dpkg/status 文件中的依赖项或者冲突关系。但这种做法很苟,非到极端情况不用{This manipulation is an ugly hack and should never be used, except in the most extreme case of necessity. }所以解决这个问题的最经常用的方法便是:重新编译问题包裹或者使用新版本或后台端口版本(backports (backports are newer versions especially recompiled to work in an older environment))
=========================================================================================
apt install w3af/kali-rolling {Remember that you can specify a specific distribution with apt as well, which means you can roll back to an older version of a package (if for instance you know that it works well), provided that it is still available in one of the sources referenced by the sources.list file:前提是它仍然在sources.list文件引用的其中一个源中可用}

In this sense, all of the files in /etc/apt/apt.conf.d/ are instructions for the configuration of APT. APT processes the files in alphabetical order, so that the later files can modify configuration elements defined in the earlier files.
=========================================================================================
有时会因为维护者提供的脚本有问题而终止更新,脚本储存在`/var/lib/dpkg/info/` —— 通常是postinst脚本出问题。

Dealing with Broken Maintainer Scripts Sometimes the upgrade gets interrupted because one of the package maintainer scripts fails (usually, it is the postinst). In those cases, you can try to diagnose the problem, and possibly work around it, by editing the problematic script. Here we rely on the fact that maintainer scripts are stored in /var/lib/dpkg/info/ and that we can review and modify them.Since maintainer scripts are usually simple shell scripts, it is possible to add a set -x line just after the shebang line and arrange them to be rerun (with dpkg --configure -a for postinst) to see precisely what is happening and where it is failing. This output can also nicely complement any bug report that you might file.With this newly gained knowledge, you can either fix the underlying problem or transform the failing command into a working one (for example by adding || true at the end of the line).Note that this tip does not work for a failing preinst since that script is executed even before the package gets installed so it is not yet in its final location. It does work for postrm and prerm although you will need to execute a package removal (respectively upgrade) to trigger them.
=========================================================================================
Delete wine.list/删除wine源
rm /etc/apt/sources.list.d/wine.list
=========================================================================================
There are two ways a system can get into a broken state like this. The first is caused by dpkg missing some subtle relationships between packages when performing upgrades. [3]. The second is if a package installation fails during an operation. In this situation a package may have been unpacked without its dependents being installed.
=========================================================================================

DPKG常用命令解析

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
+++++++++++++++++++++++++++++++++++++++++++++++++++
# 对比版本数字大小 |
dpkg --compare-versions 【xxx】 【op】 【yyy】 |
e.g.: |
$ dpkg --compare-versions 1.2-3 gt 1.1-4 |
$ echo $? |
0 |
$ dpkg --compare-versions 1.2-3 lt 1.1-4 |
$ echo $? |
1 |
$ dpkg --compare-versions 2.6.0pre3-1 lt 2.6.0-1 |
$ echo $? |
1 |
+++++++++++++++++++++++++++++++++++++++++++++++++++

# 返回结果:
lt ==> strictly less than >绝对低于
le ==> less than or equal to >低于或相同
eq ==> equal >相同
ne ==> not equal >不同
ge ==> greater than or equal to >更高级或相同
gt ==> strictly greater than >绝对更高
0 ==> 成功
!0 ==> 失败,返回非零数字

# 意外情况--最后一种带有‘pre’,指的是‘预发布的’,但dpkg把他诠释为字符串。这种情况下,2.6.0pre3-1按字母表排序大于2.6.0-1,所以用‘~’指示预发行。
$ dpkg --compare-versions 2.6.0~pre3-1 lt 2.6.0-1
$ echo $?
0

所以这个结果才是正确的,2.6.0~pre3-1 < 2.6.0-1
  • dpkg -P 【Package】 : 清除所有关联文件

  • dpkg -c /var/cache/apt/archives/gnupg_1.4.18-6_amd64.deb :显示deb中包含的文件

  • dpkg -I /var/cache/apt/archives/gnupg_1.4.18-6_amd64.deb :显示包的头信息

  • dpkg --print-architecture :返回本计算机dpkg只安装的包的架构版本

  • dpkg --get-selections | grep -v deinstall :获取在本地安装的软件包列表,-v标记”反转”grep返回不匹配行

  • dpkg -I 【package】 :查看apt包

    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
    $ dpkg -I apt_1.4~beta1_amd64.deb control        
    Package: apt
    Version: 1.4~beta1
    Architecture: amd64
    Maintainer: APT Development Team <deity@lists.debian.org>
    Installed-Size: 3478
    Depends: adduser, gpgv | gpgv2 | gpgv1, debian-archive-keyring, init-system-helpers (>= 1.18~), libapt-pkg5.0 (>= 1.3~rc2), libc6 (>= 2.15), libgcc1 (>= 1:3.0),➥ libstdc++6 (>= 5.2)

    依赖项:
    ,= AND
    | = OR
    | 的优先级大于 ==> 所以:it is an inclusive “OR,” not an exclusive “either/or" 兼或Inclusive or 异或exclusive or

    ##################################
    # OR inclusive | exclusive #
    # ----- | #
    # IN-1: 0 0 1 1 | 0 0 1 1 #
    # | #
    # IN-2: 0 1 0 1 | 0 1 0 1 #
    # | #
    # OUT : 0 1 1 1 | 0 1 1 0 #
    ##################################
    总结:inclusive:包含 exclusive:二选一
    (A OR B) AND C ==> A|B,C
    A OR (B AND C) ==> (A OR B) AND (A OR C) ==> A|B,A|C

    <<: less than;
    <=: less than or equal to;
    =: equal to (note that “2.6.1” is not equal to “2.6.1-1”);
    >=: greater than or equal to;
    >>: greater than
  • dpkg 【-i/-r/-L/-s/-l】 :安装、卸载、显示package中的文件、显示原信息、显示安装信息

    • dpkg -r 【package】 :这个卸载并不完全,所有配置文件、维护程序脚本、日志文件(系统日志)、守护进程生成的数据(例如LDAP服务器目录的内容或SQL服务器数据库的内容)以及包处理的大多数其他用户数据都保持完整,包括依赖组件。

    • dpkg -V 通过与/var/lib/dpkg/info/package.md5sums的比较,显示系统中已安装的包中被修改过的文件

      1
      2
      3
      4
      5
      $ dpkg -V
      ??5?????? /lib/systemd/system/ssh.service //人为修改
      ??5?????? c /etc/libvirt/qemu/networks/default.xml // c表示合法修改
      ??5?????? c /etc/lvm/lvm.conf
      ??5?????? c /etc/salt/roster
    • AIDE 用数据库来检测文件更改。

      1
      2
      3
      apt install aide
      aideinit 初始化
      可以修改配置:/etc/default/aide
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    -l:查看系统认识的包的列表及安装状态

    iU 表示软件包未安装成功
    ii 表示安装成功
    rc 表示软件包已经被卸载,但配置文件仍在 删除:dpkg -l | grep ^rc | cut -d' ' -f3 | sudo xargs dpkg --purge

    期望状态=未知(u)/安装(i)/删除(r)/清除(p)/保持(h)
    | 状态=未安装(n)/已安装(i)/仅存配置(c)/仅解压缩(U)/配置失败(F)/不完全安装(H)/触发器等待(W)/触发器未决(T)
    |/ 错误?=(无)/须重装(R) (状态,错误:大写=故障)
    ||/ 名称 版本 体系结构 描述
    +++-==============-============-============-========================================================
    ii zhcon 1:0.2.6-16 amd64 Fast console CJK system using FrameBuffer (main program)

    $ dpkg -l ’b*’
    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
     -L:所安装的文件
    /.
    /etc
    /etc/zhcon.conf
    /usr
    /usr/bin
    /usr/bin/zhcon
    /usr/share
    /usr/share/doc
    /usr/share/doc/zhcon
    /usr/share/doc/zhcon/README.Debian
    /usr/share/doc/zhcon/README.gz
    /usr/share/doc/zhcon/README.utf8
    /usr/share/doc/zhcon/THANKS
    /usr/share/doc/zhcon/TODO
    /usr/share/doc/zhcon/bpsf.txt.gz
    /usr/share/doc/zhcon/changelog.Debian.gz
    /usr/share/doc/zhcon/changelog.gz
    /usr/share/doc/zhcon/copyright
    /usr/share/doc/zhcon/manual.dvi.gz
    /usr/share/doc/zhcon/manual.ps.gz
    /usr/share/doc/zhcon/manual.tex.gz
    /usr/share/man
    /usr/share/man/man1
    /usr/share/man/man1/zhcon.1.gz
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    -s:查找文件头为xxx的包
    Package: zhcon
    Status: install ok installed
    Priority: optional
    Section: utils
    Installed-Size: 427
    Maintainer: Debian Chinese Team <chinese-developers@lists.alioth.debian.org>
    Architecture: amd64
    Version: 1:0.2.6-16
    Depends: zhcon-data, libc6 (>= 2.15), libgcc1 (>= 1:3.0), libgpm2 (>= 1.20.7), libncurses6 (>= 6), libpth20 (>= 2.0.7), libstdc++6 (>= 5.2), libtinfo6 (>= 6), unicon-imc2
    Conffiles:
    /etc/zhcon.conf b5a1e7387013bf373cbd4a33071093d6
    Description: Fast console CJK system using FrameBuffer (main program)
    Zhcon is a fast Linux console Chinese system which supports framebuffer
    device. It can display Chinese, Japanese or Korean double byte characters
    on console.
    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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    -S 【Package】
    zhcon-data: /usr/share/zhcon/input/py.mb
    zhcon: /usr/share/doc/zhcon/bpsf.txt.gz
    zhcon-data: /usr/share/zhcon/font
    zhcon: /usr/share/doc/zhcon
    zhcon-data: /usr/share/zhcon/input/ed.mb
    zhcon-data: /usr/share/zhcon/input/cjf.mb
    zhcon-data: /usr/share/doc/zhcon-data/copyright
    zhcon-data: /usr/share/zhcon/font/hzk12.bpsf
    zhcon-data: /usr/share/zhcon/font/asc16.bpsf
    zhcon: /usr/share/doc/zhcon/manual.tex.gz
    zhcon-data: /usr/share/zhcon/input/cjj.mb
    zhcon-data: /usr/share/zhcon/font/asc12x.bpsf
    zhcon-data: /usr/share/zhcon/font/big5-16.bpsf
    zhcon-data: /usr/share/zhcon/input/big5-cj.mb
    zhcon-data: /usr/share/zhcon/font/hzk14.bpsf
    zhcon-data: /usr/share/zhcon/font/ksc-16.bpsf
    zhcon-data: /usr/share/zhcon/input/wb.mb
    zhcon: /etc/zhcon.conf
    zhcon: /usr/share/doc/zhcon/copyright
    zhcon-data: /usr/share/zhcon/font/asc14.bpsf
    zhcon: /usr/share/man/man1/zhcon.1.gz
    zhcon: /usr/share/doc/zhcon/TODO
    zhcon: /usr/share/doc/zhcon/changelog.gz
    zhcon-data: /usr/share/zhcon/font/asc14b.bpsf
    zhcon-data: /usr/share/zhcon/input/big5-liu5.mb
    zhcon-data: /usr/share/zhcon/font/hzk16.bpsf
    zhcon-data: /usr/share/zhcon/input/jp.mb
    zhcon: /usr/share/doc/zhcon/README.gz
    zhcon-data: /usr/share/zhcon/input/winsp.mb
    zhcon-data: /usr/share/zhcon
    zhcon: /usr/share/doc/zhcon/manual.ps.gz
    zhcon: /usr/bin/zhcon
    zhcon-data: /usr/share/zhcon/input/big5-phone.mb
    zhcon-data: /usr/share/zhcon/input/dzm.mb
    zhcon: /usr/share/doc/zhcon/THANKS
    zhcon-data: /usr/share/zhcon/font/gb-24-kai.bpsf
    zhcon-data: /usr/share/zhcon/input/sp.mb
    zhcon-data: /usr/share/zhcon/input/wbew.mb
    zhcon-data: /usr/share/zhcon/input/winpy.mb
    zhcon-data: /usr/share/doc/zhcon-data/changelog.gz
    zhcon-data: /usr/share/zhcon/font/asc12.bpsf
    zhcon-data: /usr/share/zhcon/font/gb-16.bpsf
    zhcon-data: /usr/share/zhcon/font/big5-12-ming.bpsf
    zhcon: /usr/share/doc/zhcon/README.utf8
    zhcon-data: /usr/share/zhcon/font/gbk-16.bpsf
    zhcon: /usr/share/doc/zhcon/changelog.Debian.gz
    zhcon: /usr/share/doc/zhcon/manual.dvi.gz
    zhcon-data: /usr/share/zhcon/font/jis-16.bpsf
    zhcon: /usr/share/doc/zhcon/README.Debian
    zhcon-data: /usr/share/zhcon/input
    zhcon-data: /usr/share/doc/zhcon-data/changelog.Debian.gz
    zhcon-data: /usr/share/zhcon/input/pt.mb
    zhcon-data: /usr/share/doc/zhcon-data
    zhcon-data: /usr/share/zhcon/font/asc24.bpsf
    zhcon-data: /usr/share/zhcon/input/winzm.mb
    zhcon-data: /usr/share/zhcon/input/big5-ary30.mb
    zhcon-data: /usr/share/zhcon/input/wbh.mb

    -S 【Path】:搜索查找包含某参数的文件活的包或含有所需路径的包
    $ dpkg -S /etc/apache2/
    libapache2-mod-dnssd, javascript-common, apache2: /etc/apache2
  • Dpkg 部分日志记录

    1
    2
    3
    /var/lib/dpkg/status	     安装状态
    /var/lib/dpkg/info/*.list 包所安装的文件
    /var/lib/dpkg/info 配置的脚本
  • Dpkg添加、删除架构

    1
    2
    3
    4
    5
    dpkg --add-architecture i386
    dpkg --remove-architecture i386
    dpkg --get-selections | awk '/i386/{print $1}'
    apt-get update
    `dpkg --print-foreign-architectures` :显示外来结构

DPKG其他补充

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
=========================================================================================
$ dpkg -s libwine
dpkg-query: error: --status needs a valid package name but ’libwine’ is not: ambiguous
➥ package name ’libwine’ with more than one installed instance
Use --help for help about querying packages.
$ dpkg -s libwine:amd64 libwine:i386 | grep ^Multi
Multi-Arch: same
Multi-Arch: same
$ dpkg -L libgcc1:amd64 |grep .so
[...]
/usr/lib/x86_64-linux-gnu/wine/libwine.so.1
$ dpkg -S /usr/share/doc/libwine/copyright
libwine:amd64, libwine:i386: /usr/share/doc/libwine/copyright
=========================================================================================
# dpkg建议安装的包,不需要就不装
Suggests: apt-doc, aptitude | synaptic | wajig, dpkg-dev (>= 1.17.2), powermgmt-base,
➥ python-apt

# Incompatibilities: the Breaks Field:安装他将会破坏某包[已安装的],主要是版本不兼容
Breaks: apt-utils (<< 1.3~exp2~)

# 表示该包有权替换系统中已安装包的部分文件
Replaces: apt-utils (<< 1.3~exp2~)

Section: admin
Priority: important
Description: commandline package manager
This package provides commandline tools for searching and
managing as well as querying information about packages
as a low-level access to all features of the libapt-pkg library.
.
These include:
* apt-get for retrieval of packages and information about them
from authenticated sources and for installation, upgrade and
removal of packages together with their dependencies
* apt-cache for querying available information about installed
as well as installable packages
* apt-cdrom to use removable media as a source for packages
* apt-config as an interface to the configuration settings
* apt-key as an interface to manage authentication keys

!!:有些包有conflicts字段:表示有冲突的包

Provides:有关虚拟包的概念;相反,源包用来说明依赖项
the control.tar.gz archive for each Debian package may contain a number of scripts (postinst, postrm, preinst, prerm)
=========================================================================================
$ dpkg -I /var/cache/apt/archives/zsh_5.3-1_amd64.deb | head
new debian package, version 2.0.
size 814486 bytes: control archive=2557 bytes.
838 bytes, 20 lines control
3327 bytes, 43 lines md5sums
969 bytes, 41 lines * postinst #!/bin/sh
348 bytes, 20 lines * postrm #!/bin/sh
175 bytes, 5 lines * preinst #!/bin/sh
175 bytes, 5 lines * prerm #!/bin/sh
Package: zsh
Version: 5.3-1
$ dpkg -I zsh_5.3-1_amd64.deb preinst
#!/bin/sh
set -e
# Automatically added by dh_installdeb
dpkg-maintscript-helper symlink_to_dir /usr/share/doc/zsh zsh-common 5.0.7-3 -- ”$@”
# End automatically added section
=========================================================================================
dpkg数据库:/var/lib/dpkg/
已安装包的配置脚本:/var/lib/dpkg/info/ 如:
$ ls /var/lib/dpkg/info/zsh.*
/var/lib/dpkg/info/zsh.list
/var/lib/dpkg/info/zsh.md5sums
/var/lib/dpkg/info/zsh.postinst
/var/lib/dpkg/info/zsh.postrm
/var/lib/dpkg/info/zsh.preinst
/var/lib/dpkg/info/zsh.prerm
=========================================================================================
# 以下显示的是来自这个包的文件有哪些
$ head /var/lib/dpkg/info/zsh.list
/.
/bin
/bin/zsh
/bin/zsh5
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/zsh
/usr/lib/x86_64-linux-gnu/zsh/5.2
/usr/lib/x86_64-linux-gnu/zsh/5.2/zsh
[...]
=========================================================================================
# 以下同样是用来显示control信息
$ more /var/lib/dpkg/status
Package: gnome-characters
Status: install ok installed
Priority: optional
Section: gnome
Installed-Size: 1785
Maintainer: Debian GNOME Maintainers <pkg-gnome-
➥ maintainers@lists.alioth.debian.org>
Architecture: amd64
Version: 3.20.1-1
[...]
=========================================================================================
# ar p /var/cache/apt/archives/bash_4.4-2_amd64.deb control.tar.gz | tar -tzf -
./
./conffiles
./control
./md5sums
./postinst
./postrm
./preinst
./prerm
=========================================================================================
`dpkg --verify 【package】` :用于检查包的md5,检查包是否被修改过
conffiles文件列出了要被当做配置文件看待的文件
=========================================================================================
dpkg处理配置文件的更新时常中断工作来询问管理员要采用新或旧版本的配置文件,这可以用 --force-confold / --force-confnew 来回答dpkg这个问题。
--force-confask用于指定dpkg询问。
在APT中向dpkg指明使用新版本的配置文件
$ sudo apt -o DPkg::options::=”--force-confdef” -o DPkg::options::=”--force-confold” full-upgrade
或者通过修改配置文件:/etc/apt/apt.conf.d/local
DPkg::options { ”--force-confdef”; ”--force-confold”; }
=========================================================================================
关于postinst, postrm, preinst, prerm脚本文件:
preinst:安装前的准备
postinst:紧随其后(上面脚本)
prerm:在卸载前的引用对象
postrm:紧随其后(prerm)
=========================================================================================
安装活更新:
1. For an update, dpkg calls the old-prerm upgrade new-version.
2. Still for an update, dpkg then executes new-preinst upgrade old-version; for a first installation, it executes new-preinst install. It may add the old version in the last parameter if the package has already been installed and removed (but not purged, the configuration files having been retained).
3. The new package files are then unpacked. If a file already exists, it is replaced, but a backup copy is made and temporarily stored.
4. For an update, dpkg executes old-postrm upgrade new-version.
5. dpkg updates all of the internal data (file list, configuration scripts, etc.) and removes the backups of the replaced files. This is the point of no return: dpkg no longer has access to all of the elements necessary to return to the previous state.
6. dpkg will update the configuration files, prompting you to decide if it is unable to automatically manage this task. The details of this procedure are discussed in section 8.4.3, “Checksums, Conffiles” [page 214].
7. Finally, dpkg configures the package by executing new-postinst configure last version-configured
卸载包:
1. dpkg calls prerm remove.
2. dpkg removes all of the package’s files, with the exception of the configuration files and configuration scripts.
3. dpkg executes postrm remove. All of the configuration scripts, except postrm, are removed.If you have not used the purge option, the process stops here.
4. For a complete purge of the package (command issued with dpkg --purge or dpkg -P),the configuration files are also deleted, as well as a certain number of copies (*.dpkg-tmp,*.dpkg-old, *.dpkg-new) and temporary files; dpkg then executes postrm purge
=========================================================================================
总结:
• dpkg --listfiles package(or-L) lists the files that were installed by the specified package.
• dpkg --search file (or -S) finds any packages containing the file or path passed in the argument.
• dpkg --list (or -l) displays the list of packages known to the system and their installation status.
• dpkg --contents file.deb (or -c) lists all the files in a particular .deb file.
• dpkg --info file.deb (or -I) displays the headers of the specified .deb file.
• The various apt-cache subcommands display much of the information stored in APT’s internal database.
=========================================================================================
定期整理/var/cache/apt/archives/:
apt clean
apt autoclean
/etc/apt/apt.conf.d/ 来修改APT配置
https://bugs.debian.org/package 查看包的bug 同样,bugs.kali.org 查看kali的bug汇报
=========================================================================================

其他相关

查看软件依赖

https://blog.bfw.wiki/user1/16285810560586310044.html

如:ldd /bin/zsh

APT Upgrade Full-upgrade Dist-upgrade区别

  • apt upgrade:升级所有软件包,而不安装或删除软件包,即使这意味着某些软件包未升级
  • apt upgradeaptitude safe-upgrade:升级所有软件包,如果需要,安装新软件包,但不删除软件包,即使这意味着某些软件包未升级
  • apt full-upgradeaptitude full-upgradeapt-get dist-upgrade:升级所有软件包并安装新软件包或根据需要删除已安装的软件包

APT自定义不升级的软件包

1.sudo apt-mark hold nginx

特点(apt-mark hold):

简单易用:适合想要简单快速地阻止某个软件包自动升级的情况。
全面控制:防止任何版本更新,直到取消保持标记。

2.编辑sudo nano /etc/apt/preferences.d/ignore-version

1
2
3
Package: nginx
Pin: version 1.18.0*
Pin-Priority: -1
1
2
3
4
Package: unwanted-package
Pin: version *
Pin-Priority: -1
Explanation: prevent unwanted-package from being installed

特点

灵活性高:可以针对特定版本进行精细控制。
多种配置:可以为多个软件包设置不同的优先级。
更复杂:需要手动编辑配置文件,稍微复杂一些。

请注意,Package(显然是版本)接受模式。参见apt_preferences(5) 想要查询更多的信息。

(Note that Package (and version obviously) accept patterns. See apt_preferences(5) for more information.)

Linux知识

忠告

1
2
3
4
做事情前,请思考:
• Confidentiality: can actors who should not have access to the system or information access the system or information?
• Integrity: can the data or the system be modified in some way that is not intended?
• Availability: are the data or the system accessible when and how it is intended to be?

The Unix Way——One thing at a time

Unix操作系统家族的基本概念之一是,每个工具只能做一件事情,并且做得很好。然后,应用程序可以重用这些工具,以在顶部构建更高级的逻辑。这种哲学可以在许多化身中看到。外壳脚本可以是最好的例子:它们装配的非常简单的工具复杂的序列(如grepwcsortuniq等等)。可以在代码库中看到这种哲学的另一种实现:libpng库允许使用不同的选项和不同的方式读取和写入PNG图像,但只能这样做。毫无疑问,它包含显示或编辑图像的功能。

One of the fundamental concepts that underlies the Unix family of operating systems is that each tool should only do one thing, and do it well; applications can then reuse these tools to build more advanced logic on top. This philosophy can be seen in many incarnations. Shell scripts may be the best example: they assemble complex sequences of very simple tools (such as grep, wc, sort, uniq and so on). Another implementation of this philosophy can be seen in code libraries: the libpng library allows reading and writing PNG images, with different options and in different ways, but it does only that; no question of including functions that display or edit images.

Linux开机过程 和 Systemd

Linux Boot

1
2
3
4
在我们打开Linux电脑的电源后第一个启动的进程就是init。分配给init进程的PID是1。它是系统其他所有进程的父进程。当一台Linux电脑启动后,处理器会先在系统存储中查找BIOS,之后BIOS会检测系统资源然后找到第一个引导设备,通常为硬盘,然后会查找硬盘的主引导记录(MBR),然后加载到内存中并把控制权交给它,以后的启动过程就由MBR控制。如果是UEFI启动则是在UEFI分区寻找efi启动文件。
主引导记录会初始化引导程序(Linux上有两个著名的引导程序,GRUB和LILO,80%的Linux系统在用GRUB引导程序),这个时候GRUB或LILO会加载内核模块。内核会马上查找/sbin下的“init”程序并执行它。从这里开始init成为了Linux系统的父进程。init读取的第一个文件是/etc/inittab,通过它init会确定我们Linux操作系统的运行级别。它会从文件/etc/fstab里查找分区表信息然后做相应的挂载。然后init会启动/etc/init.d里指定的默认启动级别的所有服务/脚本。所有服务在这里通过init一个一个被初始化。在这个过程里,init每次只启动一个服务,所有服务/守护进程都在后台执行并由init来管理。
关机过程差不多是相反的过程,首先init停止所有服务,最后阶段会卸载文件系统。
以上提到的启动过程有一些不足的地方。而用一种更好的方式来替代传统init的需求已经存在很长时间了。也产生了许多替代方案,其中比较著名的有Upstart,Epoch,Muda和Systemd。而Systemd获得最多关注并被认为是目前最佳的方案。

关于Systemd

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
   开发Systemd的主要目的就是减少系统引导时间和计算开销。Systemd(系统管理守护进程),最开始以GNU GPL协议授权开发,现在已转为使用GNU LGPL协议,它是如今讨论最热烈的引导和服务管理程序。如果你的Linux系统配置为使用Systemd引导程序,它取替传统的SysV init,启动过程将交给systemd处理。Systemd的一个核心功能是它同时支持SysV init的后开机启动脚本。
Systemd引入了并行启动的概念,它会为每个需要启动的守护进程建立一个套接字,这些套接字对于使用它们的进程来说是抽象的,这样它们可以允许不同守护进程之间进行交互。Systemd会创建新进程并为每个进程分配一个控制组(cgroup)。处于不同控制组的进程之间可以通过内核来互相通信。systemd处理开机启动进程的方式非常漂亮,和传统基于init的系统比起来优化了太多。让我们看下Systemd的一些核心功能。

1. 和init比起来引导过程简化了很多。
2. Systemd支持并发引导过程从而可以更快启动。
3. 通过控制组来追踪进程,而不是PID。
4. 优化了处理引导过程和服务之间依赖的方式。
5. 支持系统快照和恢复。
6. 监控已启动的服务;也支持重启已崩溃服务。
7. 包含了systemd-login模块用于控制用户登录。
8. 支持加载和卸载组件。
9. 低内存使用痕迹以及任务调度能力
10.记录事件的Journald模块和记录系统日志的syslogd模块

Systemd同时也清晰地处理了系统关机过程。在麒麟操作系统中,在/lib/systemd/system目录下有三个脚本,分别叫systemd-halt.servicesystemd-poweroff.servicesystemd-reboot.service。这几个脚本会在用户选择关机,重启或待机时执行。在接收到关机事件时,systemd首先卸载所有文件系统并停止所有内存交换设备,断开存储设备,之后停止所有剩下的进程。

其他阅读:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Centos8启动流程:
1.在按下电源之后,BIOS会加载硬件信息并对硬件进行自检。
加载BIOS或UEFI初始化,开机自检
选择启动设备
引导装载程序,centos6是grub,centos7和8是grub2
加载装载程序的配置文件:/etc/grub.d/ /etc/default/grub /boot/grub2/grub.cfg
2.在自检完成之后,会读取由BIOS设置的第一个可启动设备,此时可以读入MBR引导记录中的主引导程序(boot loader)。Boot Loader 就是在操作系统内核运行之前运行的一段程序,GRUB是其中一种的引导程序的名称。
3.主引导程序可以指定哪个内核(Kernel)文件来进行启动,并将被指定的内核加载到内存当中运行。
4.在系统启动完成之后Linux才会调用外部程序开始准备软件执行的环境。并加载所有操作系统运行所需要的软件程序。
5.加载内核选项
6.加载initramfs初始化伪文件系统
内核初始化,centos8使用systemd代替init
执行initrd.target 所有单元,包括挂载/etc/fstab
从initramfs根文件系统切换到磁盘根目录
systemd执行默认target配置,配置文件/etc/systemd/system/default.target
systemd执行sysinit.target初始化系统及basic.target准备操作系统
systemd启动mulit-user.target下的本机与服务器服务
systemd执行multi-user.target下的/etc/rc.d/rc.local
systemd执行multi-user.target下的getty.target及登录服务
systemd执行graphical需要的服务

Linux 文件系统和文件权限

文件系统结构

  • /bin/:基本程序;
  • /boot/:早期启动过程所需的Linux内核和其他文件;
  • /dev/:设备文件;
  • /etc/:配置文件;
  • /home/:用户的个人文件;
  • /lib/:基本库;
  • /media/*:可移动设备(CD-ROM,USB密钥等)的安装点;
  • /mnt/:临时挂载点;
  • /opt/:第三方提供的额外应用程序;
  • /root/:管理员(根)的个人文件;
  • /run/:不稳定的运行时数据,不会在重新启动后持续存在;
  • /sbin/:系统程序;
  • /srv/:此系统上托管的服务器使用的数据;
  • /tmp/:临时文件;该目录通常在启动时清空;
  • /usr/:应用;此目录被进一步细分为binsbinlib(按照相同的逻辑,在根目录)。此外,还/usr/share/包含与体系结构无关的数据。/usr/local/是指由管理员用来手动安装应用程序,而不会覆盖打包系统(dpkg)处理的文件。
  • /var/:由守护程序处理的变量数据。这包括日志文件,队列,假脱机,高速缓存等。
  • /proc/并且/sys/特定于Linux内核(而不是FHS的一部分)。内核使用它们将数据导出到用户空间(有关此概念的说明,请参见第B.3.4节“用户空间”第B.5节“用户空间”)。

请注意,许多现代发行版(包括Debian)都在/bin/sbin/lib中存放指向/usr目录的符号链接,因此所有程序和库都可以在同一棵树中使用。它使保护系统文件的完整性以及在多个容器之间共享这些系统文件等变得更加容易。

文件权限

1
2
位:9876543210
示:drwxr-xr-x
  • 第九位——文件类型(p管道文件、d目录文件、l Link文件、s socket文件、c字符设备文件、b设备文件、-普通文件)
  • 第8、7、6;5、4、3;2、1、0位——表示+u(所有者)+g(所在群组)+o(其他群组)
  • 特殊权限:suid>guid
    • find / -perm -04000 -type f -ls:查找设置了suid的文件

八进制设置权限:r=4;w=2;x=1

1
2
3
4
5
6
7
8
rwx=7
rx=5
rw=6
wx=3
null=0
suid=4
guid=2
sticky=1

可执行文件一般是:775 rwxrwx-r-x

特殊权限文件(将以文件所有者权限运行,设置了uid):4754 srwxr-xr—

数据文件:644 rw-r—r—


关于umask:

1
2
3
4
终端输入umask得到四个数字:0022
初始权限 :0666
umask :0022
最终权限 :0644

关于Linux源码编译安装软件

在Linux下从源代码编译安装软件通常会比在Windows下方便的多。

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
# 源码编译三部曲
源码编译经典的三部曲 configure, make, make install。如果不出问题,一步步执行下来就安装好了,也不一定要
知其所以然。但出了问题,就不是比较容易解决的。

configure 是检查系统的库文件、类文件、依赖软件是否存在以及它们的版本是否满足需求,并根据实际检测结果生
成 Makefile 的工具。一般是一堆 bash 命令的组合。通常也需要在这一步配置一些参数。最常用的就是指定软件的
安装目录--prefix=/home/ct/soft/specific_name。

make 则是具体的编译过程。编译的语句都写在了 Makefile 中。make 默认编译 Makefile 中出现的第一个 target,
也可以指定 target 编译,并根据 Makefile 的设置方式依次编译所有依赖的东西。

有些软件的安装,在执行完 make 后就获得了可执行程序,可以跳过 make install 的过程,只需要把可执行程序放
入环境变量就可以运行了。但部分软件还需要一些依赖关系,所以需要执行 make install 才算完成了完整的安装。

make install 通常是拷贝 make 编译出来的可执行文件或者依赖的库文件 (如果有的话) 到 configure 时的--
prefix 指定的目录下

# 可能需要的组件:
aclocal
autoconf
libtoolize
autoheader
automake --add-missing
./configure
make
make install

常见进入BIOS的按键

Manufacturer Key
Acer - 宏碁 Esc,F12,F9
Asus - 华硕 Esc,F8
Clevo - 蓝天 F7
Dell - 戴尔 F12
Fujitsu - 富士通 F12,Esc
HP - 惠普 F9,Esc
Lenovo - 联想 F12,Novo,F8,F10
MSI - 微星 F11
Samsung - 三星 Esc,F12,F2
Sony - 索尼 F11,Esc,F10
Toshiba - 东芝 F12
Others - 其他 F12,Esc

Linux办公相关

中文输入法

以GNOME的中州韵输入法为例:

ibus:GNOME默认ibus,可以安装ibus-rime。安装完后在设置中启用即可(开始键+空格)。X11、Wayland都可以。

fcitx:安装fcitx-rime后,在im-config设置默认fcitx(im-config -n fcitx),最后fcitx配置添加中州韵即可(Ctrl+空格),建议在x11使用(注销后在用户登录界面的小齿轮选择运行于xorg的GNOME,GNOME默认wayland)。

fcitx5:安装fcitx5-rime后,在im-config设置默认fcitx5,最后fcitx5配置添加中州韵即可(Ctrl+空格),建议在X11使用。

打印机系统

gnome-cups-manager是GNOME桌面中的打印机属性管理工具。但是它的自述文件(README File)可能比程序本身更令人感兴趣:

很久很久以前,有一个打印机居住森林里。它很孤独,因为没人知道如何配置它。它希望有人能和它一起玩。
一天,风吹过打印机的小屋,“呼,呼”。打印机开始兴奋起来,也许风可成为它的朋友。
“你愿意做我的朋友吗?”打印机问。
“呼,呼”,风回答。
“什么意思”,打印机问。
“呼,呼”,风回答,它消失了。
打印机搞糊涂了,它把这天剩余的时间都花在思考上,打印纸被卡住了(小小打印机迷糊时就会这么做)。

第二天,一场暴风雨来临。大雨倾盆而下,使早晨的天空变暗,还破坏了打印机的花园。小小打印机很苦恼。“为什么这样对我?”它问。
“噼里啪啦,噼里啪啦,”雨回答。
“你将做我的朋友?”打印机害羞的问道。
“噼里啪啦,噼里啪啦,”雨回答。然后它离开了,太阳露出了脸。
打印机很悲伤,这天剩余的时间它都呆在里面,哭泣,悄悄的打着光信号(小小打印机悲伤时就会这么做)。

又有一天,一个小女孩无意闯入了打印机的领地。打印机看着这种奇特的情景,不知道怎么办。
“你愿意做我的朋友吗?”小女孩问。
“愿意,”打印机回答。
“你叫什么名字?”小女孩问。
“HP 4100TN”,打印机回答。
“我的名字叫gnome-cups-manager”,小女孩说。
打印机很快乐,剩下的时间它在玩和打印文档。小小打印机开心时就会如此。

打印机生产商一般都会提供Linux驱动,没有的话就去OpenPrinter找一下通用驱动。CUPS是苹果公司写给Unix用的。

通用驱动、通用打印系统

https://wiki.debian.org/PrintingGlossaryandIndex#ipp

CUPS

OPEN PRINTER

IPP Everywhere™

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
打印机的驱动程序可能来自以下任何来源。 请参阅 CUPS/Printer-specific problems 获取其他人设法使用的驱动程序的不完整列表。

要驱动一台打印机,CUPS 需要一个 PPD 文件,对于大多数打印机来说,还需要一些 过滤器。 有关 CUPS 如何使用 PPD 和过滤器的详细信息。

OpenPrinting 打印机列表 (英语) 提供了许多打印机的推荐驱动程序。它还为每台打印机提供了相应的 PPD 文件,但是大多数文件都可以通过 foomatic 或其它推荐的驱动程序包获得。

Linux 基金会旗下 OpenPrinting 工作组维护的 foomatic 为许多打印机提供了 PPD 文件,既有自由的也有非自由的。 有关 foomatic 功能的更多信息,请参阅 开发者眼中的 Foomatic (英语)。
要使用 foomatic,请安装 foomatic-db-engine包 和下列的至少一个软件包:
foomatic-db包 - foomatic-db-engine 用来生成 PPD 文件的 XML 文件集合。
foomatic-db-ppds包 - 预构建好的 PPD 文件。
foomatic-db-nonfree包 - 打印机制造商提供的、非自由许可协议下的、foomatic-db-engine 用于生成 PPD 文件的 XML 文件集合。
foomatic-db-nonfree-ppds包 - 非自由许可协议下的预构建 PPD 文件。
Foomatic 的 PPD 文件可能还需要额外的过滤器,比如 min12xxwAUR。

非 PDF 打印机需要安装 ghostscript包。对于 PostScript 打印机可能还需要安装 gsfonts包。

Gutenprint
Gutenprint 项目 提供了可与 CUPS 和 GIMP 搭配使用的佳能(Canon)、爱普生(Epson)、利盟(Lexmark)、索尼(Sony)、奥林巴斯(Olympus) 以及 PCL 打印机的驱动程序。

BROTHER

驱动下载地址:Brother Printer

爱普生——EPSON

驱动下载地址:

EPSON LINUX DRIVER

EPSON CN(选择UOS系统)

1
2
3
4
e.g.:M105
首先安装EPSON UOS驱动。
然后:
sudo apt install cups printer-driver-escpr

奔图——Pantum

驱动下载(国际版的驱动新):

国际版 · 国产系统版本

联想——Lenovo

驱动下载

1
2
Lenovo M7675DXF Debian12开箱即用
Lenovo M7615DNA CUPS驱动请选择Brother DCP-8080DN

惠普——HP

HP Linux Imaging and Printing

1
2
3
4
Debian 12:
sudo apt install hplip
sudo hplip-setup
记得使用SUDO,否则检查不到USB状态

打印机管理GUI

sudo apt install system-config-printer

CUPS

自行安装cups通用打印机驱动或者到打印机生产商官网下载驱动。

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
cups:
打印支持dnssd的打印机
lpinfo --include-schemes dnssd -v

列出驱动:
lpinfo -m

lpinfo -v 可以列出已连接打印机的 URI ,加上 -m 选项可列出所有系统上安装的驱动型号

为IP 11.22.33.44添加everywhere通用驱动
lpadmin -p printername -E -v ipp://11.22.33.44/ipp/print -m everywhere
格式:lpadmin -p queue_name -E -v uri -m model

添加打印机和驱动
lpadmin -p printername -E -v socket://11.22.33.44 -m drv:///sample.drv/laserjet.ppd
对于免驱动打印队列(Apple AirPrint 或 IPP Everywhere):
lpadmin -p AirPrint -E -v "ipp://10.0.1.25/ipp/print" -m everywhere
指定一个 PPD 文件而不是型号:
lpadmin -p Test_Printer -E -v "ipp://10.0.1.3/ipp/print" -m pxlmono.ppd
注意:
指定 PPD 时,请只使用文件名,而不要用完整路径(例如,应该使用 pxlmono.ppd 而不是 /usr/share/ppd/cupsfilters/pxlmono.ppd)。或者也可通过 -P 命令行开关使用完整路径。
到2021年时,许多新款打印机支持免驱打印设置。如上述第二个例子一样指定 -m everywhere,即可定义打印机,并通过查询网络上的打印机在 /etc/cups/ppd/ 中生成 .ppd 文件。

设置默认打印机:
lpoptions -d queue_name

列出选项:
lpoptions -p queue_name -l

设定一个选项:
poptions -p queue_name -o option=value

检查队列状态:
lpstat -s
lpstat -p queue_name

停用打印机:
cupsdisable queue_name
启用打印机:
cupsenable queue_name

设定打印机以接受任务:
cupsaccept queue_name

移除打印机:
cupsreject queue_name——首先将其设置为拒绝所有传入的条令
cupsdisable queue_name——然后禁用它
lpadmin -x queue_name——最后移除

打印文件:
lpr file

打印17次:
lpr -# 17 file
print the result of a command. The -p switch adds a header:
echo 'Hello, world!' | lpr -p
检查队列:
lpq
lpq -a # on all queues
清除队列:
remove last entry only:
lprm
remove all entries:
lprm -
查看墨水/粉量:
apt install ink
将用户添加到 lp 用户组:
usermod -aG lp <user>
注销登录后:
ink

Linux修改网卡名称

1
2
首先关闭网卡,然后:
sudo ip link set dev 【举例:ztwdjn27zy】 name 【举例:enp125s0f2】

Linux安装字体——包括WPS字体

安装字体:

将Windows字体复制到Linux的/usr/share/fonts/custom-fonts/(自己新建的文件夹)

然后cd /usr/share/fonts/custom-fonts/

sudo chmod 775 ./*

sudo mkfontscale

这个我没用到 :sudo mkfontdir

这个是强制刷新缓存sudo fc-cache -fv

查看已安装字体:fc-list

下面是安装wps字体简介:

WPS比较符合国人习惯,LibreOffice和Linux的适配性会更好,没有WPS烦人的更新提示和一些奇奇怪怪的bug。

字体文件可以在Windows系统盘的Windows/fonts/里面找到。然后:cp ./* /usr/share/fonts/

更新字体缓存:fc-cache -fv

ST开头的是华文XX,比如华文中宋等。我个人只拷贝了:

1
MTEXTRA.TTF STENCIL.TTF STHUPO.TTF STLITI.TTF STXIHEI.TTF STXINWEI.TTF symbol.ttf WINGDNG2.TTF STCAIYUN.TTF STFANGSO.TTF STKAITI.TTF STSONG.TTF STXINGKA.TTF STZHONGS.TTF wingding.ttf WINGDNG3.TTF

Rsync备份磁盘(本地)

https://zhuanlan.zhihu.com/p/624758678

https://blog.csdn.net/Luckiers/article/details/119217775

https://baijiahao.baidu.com/s?id=1767368490362524638&wfr=spider&for=pc

我自己用的:

1
2
3
4
5
6
#!/bin/bash
# rsync -aH -e ssh --delete --exclude Cache --link-dest=yesterdaystargetdir remote1:sourcedir todaystargetdir
RSRC="/yourdisk/RyanWS/"
RDST="./WSBackup/"
rsync -avzH --delete "$RSRC" "$RDST"
echo `date` > rsync.time

以管理员权限运行或者图形化编辑系统文件 —— Run as admin or Edit system files

  1. sudo是最简单粗暴的,su root更是糙。echo 【密码】 | sudo -S 【命令】sudo从标准输入读取密码)
  2. gedit admin:///etc/default/grub & 或者 gksu gedit /etc/grub.d/00_header /etc/grub.d/10_linux /etc/grub.d/30_os-prober 可以用Gedit来编辑系统文件。
  3. pkexec用于桌面环境,比如*.desktop文件

办公室以及局域网安

检测局域网中的DHCP服务器

Wireshark过滤DHCP包:bootp

1.检测端口67开放情况:sudo nmap -sU -p 67 --script=dhcp-discover 192.168.1.0/24 -e enxa446b4906694

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Starting Nmap 7.80 ( https://nmap.org ) at 2024-07-08 15:11 CST
Nmap scan report for 192.168.1.1
Host is up (0.00049s latency).

PORT STATE SERVICE
67/udp open|filtered dhcps
MAC Address: C4:70:AB:C5:2C:F7 (Unknown)

Nmap scan report for 192.168.1.11
Host is up (0.00035s latency).

PORT STATE SERVICE
67/udp open|filtered dhcps
MAC Address: A8:C9:8A:21:A2:9D (Unknown)

Nmap scan report for 192.168.1.13
Host is up (0.00065s latency).

PORT STATE SERVICE
67/udp closed dhcps
MAC Address: D0:17:C2:8C:38:FB (Asustek Computer)

2.使用DHCP CLient(推荐):sudo dhclient -v -i enxa446b4906694

1
2
3
4
5
6
7
8
9
10
11
12
13
14
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enxa446b4906694/a4:46:b4:90:66:94
Sending on LPF/enxa446b4906694/a4:46:b4:90:66:94
Sending on Socket/fallback
Created duid "\000\001\000\001.\036N\232\244F\264\220f\224".
DHCPDISCOVER on enxa446b4906694 to 255.255.255.255 port 67 interval 3 (xid=0x878ade36)
DHCPOFFER of 192.168.1.108 from 192.168.1.1
DHCPREQUEST for 192.168.1.108 on enxa446b4906694 to 255.255.255.255 port 67 (xid=0x36de8a87)
DHCPACK of 192.168.1.108 from 192.168.1.1 (xid=0x878ade36)
bound to 192.168.1.108 -- renewal in 13135 seconds.

设置DoH(DNS over HTTP)

https://sdns.360.net/dnsPublic.html#course

4个方法(推荐1和2):

  1. 传统DNS:

    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
    33
    34
    35
    36
    37
    38
    39
    40
    一、通过网络管理器来设置DNS(适用有图形界面的):
    1.单击“系统 > 首选项 > 网络连接”。 选择要为其配置360安全DNS的连接。例如:
    - 要更改以太网连接的设置,请选择“ 有线” 选项卡,然后在列表中选择您的网络接口。通常称为eth0。
    - 要更改无线连接的设置,请选择“ 无线” 选项卡,然后选择适当的无线网络。
    2.单击“ 编辑”,然后在出现的窗口中选择“ IPv4设置”选项卡。
    3.如果选中的方法是“ 自动(DHCP)”,请打开下拉列表,然后选择 “ 仅自动(DHCP)地址“。如果方法设置为其他,请勿更改。
    4.在DNS服务器字段中,输入360安全DNS IP地址,以逗号分隔:
    电信、移动、铁通:首选地址:101.226.4.6,备用地址:218.30.118.6
    联通:首选地址:123.125.81.6,备用地址:140.207.198.6
    5.请根据您所在的运营商,选择对应的DNS服务地址。
    6.测试您的设置是否正常工作。使用dig www.360.cn 验证。
    对要更改的其他网络连接重复该过程。

    二、适用服务器这类无图形界面的:
    1.如果您的Linux版不使用网络管理器,则DNS是通过/etc/resolv.conf指定的。
    编辑/etc/resolv.conf : sudo vi /etc/resolv.conf
    2.如果出现任何的nameserver,请记下IP地址以备将来参考。
    3.使用以下指令来替代原有nameserver,或添加以下指令(以电信网络为例):
    nameserver 101.226.4.6
    nameserver 218.30.118.6
    电信、移动、铁通:首选地址:101.226.4.6,备用地址:218.30.118.6
    联通:首选地址:123.125.81.6,备用地址:140.207.198.6
    请根据您所在的运营商,选择对应的DNS服务地址。
    4.保存并退出。
    5.在完成步骤 4 后,根据第 4 步的操作不同,出现如下图 ① ②不同的"Internet 协议版本4(TCP/IPv4)属性"窗口,如图所示在红色框选区域输入DNS 为您提供的公众 DNS 服务地址:
    电信、移动、铁通:首选地址:101.226.4.6,备用地址:218.30.118.6
    联通:首选地址:123.125.81.6,备用地址:140.207.198.6
    请根据您所在的运营商,选择对应的DNS服务地址。
    6.测试您的设置是否正常工作。使用dig www.360.cn 验证。
    7.此外,如果您正在使用会覆盖/etc/resolv.conf中设置的DHCP客户端软件,则需要通过编辑客户端的配置文件来设置DNS。
    三、在Debian服务器上配置DHCP客户端软件(附):
    1.备份/etc/resolv.conf : sudo cp /etc/resolv.conf /etc/resolv.conf.auto
    2.编辑/etc/dhcp/dhclient.conf(或/etc/dhcp3/dhclient.conf): sudo vi /etc/dhcp*/dhclient.conf
    3.如果有一行指令是,request后仅有domain-name-servers, 则删除该行。
    4.将该行指令替换为以下行,或添加以下行(以电信网络为例): prepend domain-name-servers 101.226.4.6, 218.30.118.6;
    电信、移动、铁通:首选地址:101.226.4.6,备用地址:218.30.118.6
    联通:首选地址:123.125.81.6,备用地址:140.207.198.6
    请根据您所在的运营商,选择对应的DNS服务地址。
    5.重新启动您正在使用的所有Internet客户端。
    6.测试您的设置是否正常工作。使用dig www.360.cn 验证。
  2. 浏览器配置(以火狐为例):

    1
    2
    3
    1. 从 Firefox 菜单栏中点击 【设置】。 
    2. 搜索框中输入“DNS”,点击【网络设置】中的【设置】按钮(新版本在隐私与安全中)。
    3. 在设置页面的底部,找到并勾选“启用基于HTTPS的DNS”,选择“自定义”的提供商,并输入接口地址: https://doh.360.cn,点击【确定】。
  3. systemd-resolved(我没试过):

    1
    2
    3
    4
    5
    6
    7
    1.登入linux主机系统。
    2.编辑文件/etc/systemd/resolved.conf,将其内容修改为:
    [Resolve]
    DNS=101.198.198.198
    DNS=101.198.199.200
    DNSOverTLS=yes
    3.执行命令 systemctl restart systemd-resolved重启服务。
  4. 360SDNS CLI 客户端(没必要):sh -c "$(curl -sL https://sdns.360.net/install)"

1
2
3
4
5
6
7
8
9
10
11
12
#### 国内加密 DNS(DoH)分享
阿里 DoH 地址:https://dns.alidns.com/dns-query
腾讯 DoH 地址:https://doh.pub/dns-query
360 DoH 地址:https://doh.360.cn/dns-query

#### 国外加密 DNS(DoH)分享
Google DoH 地址:https://dns.google/dns-query
Cloudflare DoH 地址:https://cloudflare-dns.com/dns-query
IBM Quad9 DoH 地址:
https://dns.quad9.net/dns-query
https://dns11.quad9.net/dns-query
OpenDNS DoH 地址:https://doh.opendns.com/dns-query

一些办公技巧

Word转txt

参见:https://github.com/rmshadows/rm_scripts

1
2
3
4
5
antiword:新版本worddocx用不了
早期的docantiwordxxx.doc

新版本docx请使用pandoc
pandoc -s input.docx -t plain -o output.txt

ls只显示一列

1
2
3
4
5
6
7
8
ls --format=single-column
# 包括隐藏文件夹
ls -a --format=single-column
并复制到剪贴板:
ls --format=single-column | xsel -b

zshrc:
alias lsx='ls --format=single-column | xsel -b'

解决zip压缩包乱码问题

如:╡┌4╒┬╩╡└²-╖╓╬÷╜ß╣√.xlsx

安装unar即可

示例:unar 1.zip

处理RAR压缩包

详情请见:https://www.rarlab.com/download.htm

压缩包文件名称过长

1
2
1.单独解压
2.在NTFS磁盘解压

清空文件内容

为了清除诸如日志文件之类的文件的内容,不要用 rm(1) 命令去删除文件然后创建新的空文件,因为这个文件可能在命令执行的期间还在被使用。以下是清除文件内容的正确方法。

1
$ :>file_to_be_cleared

批量转换jpg

1
2
# 批量转换png和jpeg到png
mogrify -format jpg *.png *.jpeg

磁盘检查、修复

遇到NTFS磁盘无法挂载,如"No object for D-Bus interface",可以采用修复后手动命令行mount挂载。也可使用gparted分配新UUID,然后修复磁盘后正常挂载。

Windows:

CHKDSK命令:检查磁盘上的文件系统错误,并对损坏的扇区进行恢复。

格式:CHKDSK 【驱动器:】 【参数】

示例:CHKDSK D: /R /F (检查D盘并修复错误)

SFC命令:检查和恢复Windows系统文件。可修复因误删除或磁盘损坏导致的系统文件丢失或损坏的问题。

示例:SFC /SCANNOW

Linux:

fsck命令:检查并修复Linux文件系统错误,恢复已损坏的超级块、inode、目录项等。格式:fsck 【文件系统类型】 【分区设备名称】

示例:fsck ext3 /dev/sda1 (检查并修复/dev/sda1分区的ext3文件系统)

固态硬盘检测

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# 安装检测工具:
sudo apt update
sudo apt install smartmontools nvme-cli

# 识别磁盘设备名称
lsblk -o NAME,SIZE,MODEL
└─$ lsblk -o NAME,SIZE,MODEL
NAME SIZE MODEL
nvme1n1 931.5G Samsung SSD 980 PRO 1TB
├─nvme1n1p1 128M
├─nvme1n1p2 500M
├─nvme1n1p3 186.3G
├─nvme1n1p4 14.9G
├─nvme1n1p5 465.7G
├─nvme1n1p6 186.3G
└─nvme1n1p7 77.8G
nvme0n1 232.9G KINGSTON SNV2S250G
├─nvme0n1p1 16M
├─nvme0n1p2 100M
├─nvme0n1p3 232G
└─nvme0n1p4 803M

# 以上面为例
sudo nvme smart-log /dev/nvme1n1
sudo nvme smart-log /dev/nvme0n1

输出:
$ sudo nvme smart-log /dev/nvme1n1
Smart Log for NVME device:nvme1n1 namespace-id:ffffffff
critical_warning : 0
temperature : 36°C (309 Kelvin)
available_spare : 100%
available_spare_threshold : 10%
percentage_used : 2%
endurance group critical warning summary: 0
Data Units Read : 29,636,902 (15.17 TB)
Data Units Written : 27,557,669 (14.11 TB)
host_read_commands : 405,775,882
host_write_commands : 469,098,463
controller_busy_time : 4,192
power_cycles : 1,103
power_on_hours : 697
unsafe_shutdowns : 43
media_errors : 0
num_err_log_entries : 0
Warning Temperature Time : 0
Critical Composite Temperature Time : 0
Temperature Sensor 1 : 36°C (309 Kelvin)
Temperature Sensor 2 : 40°C (313 Kelvin)
Thermal Management T1 Trans Count : 0
Thermal Management T2 Trans Count : 0
Thermal Management T1 Total Time : 0
Thermal Management T2 Total Time : 0


$ sudo nvme smart-log /dev/nvme0n1
Smart Log for NVME device:nvme0n1 namespace-id:ffffffff
critical_warning : 0
temperature : 30°C (303 Kelvin)
available_spare : 100%
available_spare_threshold : 10%
percentage_used : 0%
endurance group critical warning summary: 0
Data Units Read : 2,569,662 (1.32 TB)
Data Units Written : 2,049,472 (1.05 TB)
host_read_commands : 33,216,419
host_write_commands : 22,864,025
controller_busy_time : 63
power_cycles : 1,086
power_on_hours : 5,877
unsafe_shutdowns : 35
media_errors : 0
num_err_log_entries : 1,300
Warning Temperature Time : 0
Critical Composite Temperature Time : 0
Temperature Sensor 1 : 58°C (331 Kelvin)
Temperature Sensor 2 : 49°C (322 Kelvin)
Temperature Sensor 3 : 32°C (305 Kelvin)
Thermal Management T1 Trans Count : 0
Thermal Management T2 Trans Count : 0
Thermal Management T1 Total Time : 0
Thermal Management T2 Total Time : 0

# 分析
Samsung SSD 980 PRO 1TB(/dev/nvme1n1)
状态:非常健康,放心用。
项目 状态 解读
critical_warning 0 无关键故障
temperature 36°C 非常安全的温度
percentage_used 2% 仅用了 2% 的寿命,几乎是新盘
media_errors 0 无坏块
unsafe_shutdowns 43 稍微偏多,但不严重,可能是曾被强制关机或突然断电
power_on_hours 697 小时(约29天) 正常使用时间
data_written 14.1TB 写入量健康,正常范围
🔧 建议:
不用修复,一切正常。
如果担心 unsafe_shutdowns,可以检查一下系统是否经常非正常关机,防止电源突然断电(比如加 UPS 或优化休眠策略)。
⚠️ KINGSTON SNV2S250G(/dev/nvme0n1)
状态:总体健康,但有轻微注意事项。
项目 状态 解读
critical_warning 0 无关键故障
temperature 30°C(但传感器2高达58°C) 偶尔有过高温情况
percentage_used 0% 几乎全新
media_errors 0 无坏块
num_err_log_entries 1300 ⚠️ 日志中记录了 1300 次错误事件(不一定是坏块,但需注意)
unsafe_shutdowns 35 偏多
power_on_hours 5877 小时(约245天) 使用时间长于三星盘

🛠️ 可选操作(适合 Kingston)

  1. 执行 TRIM(整理空间):sudo fstrim -v /

    1
    2
    3
    4
    📌 什么是 TRIM
    当你在 SSD 上删除文件时,操作系统会把这块空间标记为“已删除”,但 SSD 本身不知道这块数据可以擦除。久而久之,这会让 SSD 变慢、写入效率下降。
    TRIM 就是告诉 SSD:
    “这些块的内容已经没用了,可以清理。”
  2. 检查文件系统错误(非破坏性):sudo fsck -n /dev/nvme0n1p3 (⚠️ -n 表示只检查不修复。若发现问题,可用 -y 自动修复。)

检查错误日志内容(查看到底错了啥)

使用:sudo nvme error-log /dev/nvme0n1

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# 结果分析
$ sudo nvme error-log /dev/nvme0n1
Error Log Entries for device:nvme0n1 entries:4
.................
Entry[ 0]
.................
error_count : 1300
sqid : 0
cmdid : 0x7019
status_field : 0x2002(Invalid Field in Command: A reserved coded value or an unsupported value in a defined field)
phase_tag : 0
parm_err_loc : 0xffff
lba : 0
nsid : 0
vs : 0
trtype : The transport type is not indicated or the error is not transport related.
cs : 0
trtype_spec_info: 0
.................
Entry[ 1]
.................
error_count : 0
sqid : 0
cmdid : 0
status_field : 0(Successful Completion: The command completed without error)
phase_tag : 0
parm_err_loc : 0
lba : 0
nsid : 0
vs : 0
trtype : The transport type is not indicated or the error is not transport related.
cs : 0
trtype_spec_info: 0
.................
Entry[ 2]
.................
error_count : 0
sqid : 0
cmdid : 0
status_field : 0(Successful Completion: The command completed without error)
phase_tag : 0
parm_err_loc : 0
lba : 0
nsid : 0
vs : 0
trtype : The transport type is not indicated or the error is not transport related.
cs : 0
trtype_spec_info: 0
.................
Entry[ 3]
.................
error_count : 0
sqid : 0
cmdid : 0
status_field : 0(Successful Completion: The command completed without error)
phase_tag : 0
parm_err_loc : 0
lba : 0
nsid : 0
vs : 0
trtype : The transport type is not indicated or the error is not transport related.
cs : 0
trtype_spec_info: 0
.................

error_count : 1300
status_field : 0x2002 (Invalid Field in Command)
parm_err_loc : 0xffff
lba : 0

显示:
✅ 含义解析:
0x2002 错误码 = 命令字段无效(例如系统发给 SSD 的 NVMe 命令格式有问题)
parm_err_loc = 0xffff = 无法定位具体哪个字段错了(可能是固件不支持某命令参数)
lba = 0 = 不是某个坏块引起的
错误 只出现在 entry[0],其他 entry 都是 Successful Completion(正常)
💡 这说明:
这 并不是物理层面的损坏,而是系统和 SSD 控制器之间的某些命令通信出错。很可能是:
操作系统或内核对某些 NVMe 命令实现有问题
SSD 固件不完全支持某些命令(比如温控、日志查询)
曾经系统 crash 导致 SSD 返回错误(但没实际写失败)
某些特定版本 Linux NVMe 驱动跟 Kingston SNV2S 有兼容性问题(在社区里也有人反馈过)
⚠️ 这种“Invalid Field in Command”错误一般是「历史错误」,对数据没有直接影响,但可以用来判断兼容性问题是否严重。

如果你怀疑硬件不稳定,可以做fio测试

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
sudo apt install fio
fio --name=test --filename=【/mnt/kingston】/testfile --size=2G --rw=randrw --bs=4k --runtime=60 --ioengine=libaio --iodepth=32 --direct=1

记得把 /mnt/kingston/ 改成你 Kingston 分区的挂载路径。完成后可以删除 testfile。

# 测试结果
$ fio --name=test --filename=/media/jessie/08F6C4E4F6C4D35C/testfile --size=2G --rw=randrw --bs=4k --runtime=60 --ioengine=libaio --iodepth=32 --direct=1 1
test: (g=0): rw=randrw, bs=(R) 4096B-4096B, (W) 4096B-4096B, (T) 4096B-4096B, ioengine=libaio, iodepth=32
fio-3.33
Starting 1 process
test: Laying out IO file (1 file / 2048MiB)
Jobs: 1 (f=1): [m(1)][100.0%][r=206MiB/s,w=207MiB/s][r=52.6k,w=53.0k IOPS][eta 00m:00s]
test: (groupid=0, jobs=1): err= 0: pid=11152: Sun Apr 6 11:07:52 2025
read: IOPS=51.6k, BW=202MiB/s (211MB/s)(1023MiB/5076msec)
slat (usec): min=4, max=164, avg= 6.86, stdev= 1.62
clat (usec): min=24, max=1250, avg=299.75, stdev=30.30
lat (usec): min=30, max=1256, avg=306.61, stdev=30.70
clat percentiles (usec):
| 1.00th=[ 251], 5.00th=[ 265], 10.00th=[ 273], 20.00th=[ 281],
| 30.00th=[ 285], 40.00th=[ 293], 50.00th=[ 297], 60.00th=[ 302],
| 70.00th=[ 310], 80.00th=[ 318], 90.00th=[ 330], 95.00th=[ 343],
| 99.00th=[ 400], 99.50th=[ 437], 99.90th=[ 553], 99.95th=[ 676],
| 99.99th=[ 930]
bw ( KiB/s): min=197288, max=214160, per=100.00%, avg=206515.20, stdev=5441.63, samples=10
iops : min=49322, max=53540, avg=51628.80, stdev=1360.41, samples=10
write: IOPS=51.7k, BW=202MiB/s (212MB/s)(1025MiB/5076msec); 0 zone resets
slat (usec): min=10, max=236, avg=11.65, stdev= 2.05
clat (nsec): min=835, max=1247.6k, avg=300786.92, stdev=30478.12
lat (usec): min=12, max=1259, avg=312.44, stdev=31.18
clat percentiles (usec):
| 1.00th=[ 253], 5.00th=[ 265], 10.00th=[ 273], 20.00th=[ 281],
| 30.00th=[ 289], 40.00th=[ 293], 50.00th=[ 297], 60.00th=[ 306],
| 70.00th=[ 310], 80.00th=[ 318], 90.00th=[ 330], 95.00th=[ 343],
| 99.00th=[ 400], 99.50th=[ 437], 99.90th=[ 570], 99.95th=[ 685],
| 99.99th=[ 1123]
bw ( KiB/s): min=198288, max=214728, per=100.00%, avg=206810.40, stdev=5278.43, samples=10
iops : min=49572, max=53682, avg=51702.60, stdev=1319.61, samples=10
lat (nsec) : 1000=0.01%
lat (usec) : 20=0.01%, 50=0.01%, 100=0.01%, 250=0.79%, 500=98.99%
lat (usec) : 750=0.18%, 1000=0.02%
lat (msec) : 2=0.01%
cpu : usr=6.42%, sys=26.31%, ctx=786649, majf=0, minf=13
IO depths : 1=0.1%, 2=0.1%, 4=0.1%, 8=0.1%, 16=0.1%, 32=100.0%, >=64=0.0%
submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0%
complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.1%, 64=0.0%, >=64=0.0%
issued rwts: total=261946,262342,0,0 short=0,0,0,0 dropped=0,0,0,0
latency : target=0, window=0, percentile=100.00%, depth=32

Run status group 0 (all jobs):
READ: bw=202MiB/s (211MB/s), 202MiB/s-202MiB/s (211MB/s-211MB/s), io=1023MiB (1073MB), run=5076-5076msec
WRITE: bw=202MiB/s (212MB/s), 202MiB/s-202MiB/s (212MB/s-212MB/s), io=1025MiB (1075MB), run=5076-5076msec

Disk stats (read/write):
nvme0n1: ios=0/11730, merge=0/10799, ticks=0/414, in_queue=413, util=2.31%


# 分析
✅ 你的 Kingston 磁盘当前读写表现 非常好
fio 测试总结(/dev/nvme0n1):
项目 值
读取带宽 202 MiB/s ≈ 211 MB/s
写入带宽 202 MiB/s ≈ 212 MB/s
IOPS(随机4K读/写) 51.6k / 51.7k
平均延迟(clat) 299300 µs,极低
错误(err) err=0 → 无错误
CPU 占用 usr=6.42%, sys=26.31%,IO引擎效率也正常
延迟百分位 99.95% 的 IO 延迟 < 700µs,说明磁盘反应非常稳定
fio命令 使用 --direct=1 直写模式,绕过缓存,测试真实磁盘

查看开关机的journalctl历史日志

筛选出优先级为 错误级别(priority 3)及以上 的日志

sudo journalctl -p 3 -r

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
`sudo journalctl -p 3 -r` 是一个命令,用于从系统日志中筛选出优先级为 **错误级别(priority 3)及以上** 的日志,并按 **时间倒序(-r)** 显示,即显示最新的错误日志。
### 具体说明:
- **`journalctl`**:是用于查看和查询系统日志的工具,基于 `systemd` 日志系统。
- **`-p 3`**:表示筛选出 **优先级为 3(错误级别,Error)及更高** 的日志。`-p` 后面的数字代表日志的优先级,常见的优先级如下:
- **0**:紧急(emergency)
- **1**:警报(alert)
- **2**:严重(critical)
- **3**:错误(error)
- **4**:警告(warning)
- **5**:通知(notice)
- **6**:信息(info)
- **7**:调试(debug)
使用 `-p 3` 后,意味着只会显示错误级别及更高的日志(错误、严重、警报、紧急)。
- **`-r`**:表示按 **倒序**(reverse)显示日志,即显示最新的日志。
### 例子:
运行 `sudo journalctl -p 3 -r` 后,你会看到系统中所有错误级别及更高优先级的日志,按时间从最新到最旧排列。通常这些日志涉及到严重的系统问题,如崩溃、驱动错误、硬件问题等。

### 使用场景:
- 用于快速查看系统中是否存在较为严重的错误或问题。
- 排查系统崩溃或服务故障时,通过筛选高优先级日志,可以更容易定位问题。
如果你看到很多错误日志,可能意味着有硬件问题、软件故障或配置错误等。

查看上次启动的日志

sudo journalctl -b -1

查看关机日志

sudo journalctl -b -1 -u systemd-shutdownd

导出每次开关机的单独日志

sudo journalctl -b -1 > /path/to/logs/boot-$(date --date='yesterday' +%Y-%m-%d).log

Debian12 中 WPS Linux 导出PDF过程中出现错误

在arch wiki中有相关的解决方法:wps 的与pdf文档相关的功能都是由wpspdf完成的,而wpspdf依赖 libtiff5.so.5 。所以安装libtiff5aur包即可解决。

sudo apt install libtiff5

如果没有的:

1
2
3
4
5
6
7
8
cd /usr/lib/x86_64-linux-gnu

ll |grep tiff
lrwxrwxrwx 1 root root 16 20231123日 libtiff.so.6 -> libtiff.so.6.0.0
-rw-r--r-- 1 root root 555K 20231123日 libtiff.so.6.0.0

# 修复
sudo ln -s libtiff.so.6.0.0 libtiff.so.5

银河麒麟WPS卸载出错已安装wps-office 软件包pre- removal脚本子进程返回错误状态2

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sudo apt remove Wps-office
正在读取软件包列表...完成
正在分析软件包的依赖关系树
正在读取状态信息...完成
下列软件包将被[卸载] :
wps-office
升级了0个软件包,新安装了0个软件包,要卸载1个软件包,有0个软件包未被升级。
解压缩后将会空出1,945 MB的空间。
您希望继续执行吗?[Y/n]
(正在读取数据库
系统当前共安装有527592 个文件和目录。)
正在卸载wps-office (11.8.2.12219. AK. preload . Sw)
python3: can't open file ' /opt/kingsoft/wps-office/INSTALL/delmime_ python3.py': [Errno 2] No such file or directorydpkg: 处理软件包wps-office (-- remove)时出错:
已安装wps-office 软件包pre- removal脚本子进程返回错误状态2
dpkg: 出现过多错误,正在停止
在处理时有错误发生:
wps-office
由于出现了太多错误,处理过程被中止了。
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决:强行卸载。

sudo mv /var/lib/dpkg/info/wps-office.prerm /var/lib/dpkg/info/wps-office.prerm.bak

随后:

sudo dpkg --remove --force-remove-reinstreq wps-office

1
2
3
4
5
6
7
8
原理:
/var/lib/dpkg/info/wps-office.prerm:这个是 WPS Office 的 prerm 脚本(pre-removal script),它在软件卸载前运行。
/var/lib/dpkg/info/wps-office.prerm.bak:将原 prerm 脚本重命名为 .bak,相当于备份并防止它被执行。
目的:如果 prerm 脚本有错误,可能会导致 dpkg --remove 失败,所以手动禁用它。
dpkg --remove wps-office:尝试卸载 WPS Office,但不会删除其配置文件。
--force-remove-reinstreq:强制删除“需要重新安装”的软件包(即那些处于损坏状态的软件)。
sudo apt update
sudo apt --fix-broken install

银河麒麟WPS安装出错python3: can't open file ' /opt/kingsoft/wps -office/INSTALL/delmime_ python3.py': [Errno 2] No such file or directory

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
sudo apt install . /wps-office 12.8.2.20327. AK. preload. sW arm64. deb
正在读取软件包列表...完成
正在分析软件包的依赖关系树
正在读取状态信息.... 完成
注意,选中'wps-office' 而非' ./wps-office_ 12.8.2.20327.AK. preload. sw_ _arm64. deb '
下列[新]软件包将被安装:
wps-office
升级了θ个软件包,新安装了1个软件包,要卸载日个软件包,有0个软件包未被升级。
需要下载0 B/793 MB的归档。
解压缩后会消耗3,330 MB的额外空间。
获取:1 /home/ ryan/下载/wps-office_ 12.8.2.20327.AK. preload. SW_ arm64.deb wps-office arm64 12.8.2.20327.AK. preload.sw [793 MB]
(正在读取数据库...系统当前共安装有522289 个文件和目录。)
准备解压.../wps-office_ 12.8.2.20327. AK. preload . sW_ _arm64. deb
python3: can't open file ' /opt/kingsoft/wps -office/INSTALL/delmime_ python3.py': [Errno 2] No such file or directory
dpkg: 处理归档/home/ ryan/下载/wps -office_ 12.8.2.20327.AK. preload. SW_ _arm64. deb (--unpack)时出错:
新的wps-office 软件包pre- installation脚本子进程返回错误状态2
在处理时有错误发生:
/home/ryan/下载/wps-office_ 12.8.2. 20327.AK. preload. sw_ arm64. deb
N: 由于文件'/home/ ryan/下载/wps -office_ 12.8.2.20327.AK.preload. sw_ _arm64.deb'无法被用户'_ apt'访问, 已脱离沙盒并提权为根用户来进行下载。pkgAcquire: :Run (13: 权限不够)
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt install -f
正在读取软件包列表...完成
正在分析软件包的依赖关系树
正在读取状态信息...完成
升级了0个软件包,新安装了0个软件包,要卸载0个软件包,有0个软件包未被升级。

解决:解压DEB包,找到delmime_ python3.py复制到/opt/kingsoft/wps -office/INSTALL/delmime_ python3.py,重新运行apt安装即可。

WPS:dlopen /opt/kingsoft/wps-office/office6/libkprometheus.so failed , error: libcrypto.so.1.1: 无法打开共享对象文件: 没有那个文件或目录

https://askubuntu.com/questions/1403055/error-libcrypto-so-1-1-could-not-open-while-try-run-wps-office-on-ubuntu-22-04

解决:进入WPS Linux安装目录执行:sudo chmod 755 libcrypto.so.1.1sudo chmod 755 libssl.so.1.1即可。

国产系统(华为ARM芯片+UOS统信或者银河麒麟)

以下是在华为鲲鹏920(8)+UOS(ARM)下测试的结果

https://www.kancloud.cn/desktop/lv100/2735643

更换桌面环境

目前UOS下,GNOME我用不了,KDE和fluxbox可以用。讲真的,DDE很不稳定。

安装KDE:sudo apt install kde-plasma-desktop

窗口管理器请保持原来的lightdm

银河麒麟换桌面也是可以,但是不能注销登陆,也就是说要设置开机自动登陆

解决银河麒麟v10 sp1更换桌面环境后无法登陆的问题

原理:修改lightdm的gteeter即可(自己摸索的办法)

1
2
3
4
5
6
7
8
9
10
11
12
首先:
sudo apt install lightdm-gtk-greeter
然后:
sudo nano /etc/lightdm/lightdm.conf
[SeatDefaults]
autologin-user=user
# 修改下面这一行
greeter-session=lightdm-gtk-greeter
# 重启搞定

# 更换锁屏(比如使用i3):
i3lock -f -i /图片/BGP/1080.png

Linux微信

1
2
【国产系统】史诗级更新Linux 微信wechat-beta_1.0.0.150(快来还热乎)
https://www.52pojie.cn/thread-1896902-1-1.html

KDE桌面下无法使用DDE Wine微信的问题

启动gnome-settings-daemon即可(sudo apt install gnome-settings-daemon)。在~/.config/autostart新建org.gnome.SettingsDaemon.XSettings.desktop写入:

1
2
3
4
5
6
7
8
9
10
[Desktop Entry]
Type=Application
Name=GNOME XSettings
Exec=/usr/libexec/gsd-xsettings
# OnlyShowIn=GNOME;
NoDisplay=true
# X-GNOME-Autostart-Phase=Initialization
# X-GNOME-Autostart-Notify=true
# X-GNOME-AutoRestart=true
# X-GNOME-HiddenUnderSystemd=true

最后在KDE设置中的系统设置>开机和关机>自动启动选项中允许自启动即可。

KDE桌面下刚开机总是出现dde-preload的终端

解决原理:找到dde-preload开机启动文件(/etc/xdg/autostart),末尾加&即可。

1
2
3
4
5
6
7
[Desktop Entry]
Name=dde-preload
# Exec=/usr/bin/dde-preload
Exec=/usr/bin/dde-preload&
NoDisplay=true
Terminal=flase
Type=Application

银河麒麟:E: 软件包 kylin-activation 需要重新安装,但是我无法找到相应的安装文件。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
正在读取状态信息... 完成       
E: 软件包 kylin-activation 需要重新安装,但是我无法找到相应的安装文件。

┌──(admin㉿kylin-pc)-[~]
└─$ sudo dpkg --remove --force-remove-reinstreq 127
dpkg: 错误: --remove 需要至少一个软件包名作为参数

输入 dpkg --help 可获得安装和卸载软件包的有关帮助 [*];
使用 apt 或是 aptitude 就能在友好的界面下管理软件包;
输入 dpkg -Dhelp 可看到 dpkg 除错标志的值的列表;
输入 dpkg --force-help 可获得所有强制操作选项的列表;
输入 dpkg-deb --help 可获得有关操作 *.deb 文件的帮助;

带有 [*] 的选项将会输出较大篇幅的文字 - 可使用管道将其输出连接到 less 或 more !

┌──(admin㉿kylin-pc)-[~]
└─$ sudo dpkg --remove --force-remove-reinstreq kylin-activation 2
dpkg: 警告: 由于开启了 --force 选项,以下问题被忽略:
dpkg: 警告: 该软件包现在的状态极为不妥;
建议您在卸载它之前再重新安装一次
(正在读取数据库 ... 系统当前共安装有 257654 个文件和目录。)
正在卸载 kylin-activation (1.3.11.1-0k1.3) ...

UOS文件管理器nautilus添加模板文件

放到~/.Templates文件夹中即可。

银河麒麟火狐浏览器打不开Github搜索框

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
33
原因:火狐浏览器版本太久
参考:https://github.com/orgs/community/discussions/103255
解决:安装新版本火狐:
https://support.mozilla.org/zh-CN/kb/install-firefox-linux?_gl=1*1rkkl6i*_ga*MTk2NjcwNjQ1Ni4xNzAzNDY5OTY1*_ga_MQ7767QQQW*MTcwOTY5MDM5Ni4yLjEuMTcwOTY5MTY1OC4wLjAuMA..#w_install-firefox-deb-package-for-debian-based-distributions

以华为麒麟990 arm64为例:
https://www.mozilla.org/firefox/linux/?utm_medium=referral&utm_source=support.mozilla.org
或者
https://www.mozilla.org/zh-CN/firefox/all/#product-desktop-release
下载压缩包

tar xjf firefox-*.tar.bz2
sudo mv firefox /opt
sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox
sudo wget https://raw.githubusercontent.com/mozilla/sumo-kb/main/install-firefox-linux/firefox.desktop -P /usr/local/share/applications

或者自己写Desktop文件:
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true

排除故障:https://support.mozilla.org/zh-CN/kb/%E4%BD%BF%E7%94%A8%E6%95%85%E9%9A%9C%E6%8E%92%E9%99%A4%E4%BF%A1%E6%81%AF%E9%A1%B5%E9%9D%A2%E6%9D%A5%E5%B8%AE%E5%8A%A9%E8%A7%A3%E5%86%B3Firefox%E7%9A%84%E9%97%AE%E9%A2%98

UOS打开Bitlocker

1
2
3
4
5
6
7
UOS的APT仓库中的dislocker版本过低,需要:v0.7.3
git clone https://github.com/Aorimn/dislocker
sudo apt install gcc cmake make libfuse-dev libmbedtls-dev ruby-dev
cd dislocker
cmake .
make
sudo make install

自动寻找bitlocker磁盘挂载(示例代码)

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
# 关闭执行控制功能状态:
# sudo setstatus -f exectl off
# setstatus -p softmode
# 开机自动挂载需要修改fstab(修改前记得备份!)
# <partition> /media/bitlocker fuse.dislocker user-password=<password>,nofail 0 0
# /media/bitlocker/dislocker-file /media/bitlockermount auto nofail 0 0

## 检查命令是否安装dislocker、fuse
cmdToCheck="dislocker"
if ! [ -x "$(command -v "$cmdToCheck")" ]; then
echo "Error: "$cmdToCheck" is not installed." >&2
sudo apt install "$cmdToCheck" -y
else
echo "Command found! : "$cmdToCheck"" >&1
fi
cmdToCheck="fusermount"
if ! [ -x "$(command -v "$cmdToCheck")" ]; then
echo "Error: "$cmdToCheck" is not installed." >&2
sudo apt install "$cmdToCheck" -y
else
echo "Command found! : "$cmdToCheck"" >&1
fi
## 获取Bitlocker加密分区
puid="4463e4a8-296b-4db9-aa4d-7c83c762665e"
# /dev/sdb4: TYPE="BitLocker" PARTUUID="4463e4a8-296b-4db9-aa4d-7c83c762665e"
pinfo=`sudo blkid | grep "$puid"`
tempArgs=($pinfo)
# /dev/sdb4:
tempArgs=${tempArgs[0]}
# /dev/sdb4
pdev=${tempArgs::-1}
echo "Get Bitlocker Part: "$pdev"."
## 新建文件夹(挂载文件夹)
dislockMount="/home/bitlocker"
if [ ! -d "$dislockMount" ];then
sudo mkdir -p "$dislockMount"
fi
# 可访问的挂载点
readMount="/media/bitlockermount"
if [ ! -d "$readMount" ];then
sudo mkdir -p "$readMount"
fi
## 开始挂载
sudo dislocker "$pdev" -u -- "$dislockMount"
# 下一个命令是把解密好的分区挂在到bitlockermount loop:用来把一个文件当成硬盘分区挂接上系统
sudo mount -o loop "$dislockMount"/dislocker-file "$readMount"
echo "Launched."
echo "Use below to unmount."
echo ""
echo "sudo umount "$dislockMount""
echo ""

卸载:

1
2
3
4
5
#!/bin/bash
# 取消挂载/home/bitlocker
sudo umount /media/bitlockermount
sleep 1
sudo umount /home/bitlocker

银河麒麟命令行调整屏幕亮度

https://wiki.archlinuxcn.org/wiki/%E8%83%8C%E5%85%89
https://ubuntukylin.com/news/1763-cn.html

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
如果用xrandr调整亮度无效的话,试着用ddcutil
需要注意的是:
ddcutil不支持笔记本显示器,因为笔记本显示设备是通过特殊的API进行控制的,并非I2C。
一般来说,ddcutil可以在虚拟机中构建,但不会在虚拟机中运行,这是因为虚拟视频驱动中没有实现I2C。当然,如果虚拟机连接到一个单独的视频卡,并且在passthru模式下运行该视频卡的非虚拟化驱动程序,那么ddcutil将可以正常工作。
Nvidia的专有视频驱动程序可能需要特殊配置才可正常运行ddcutil。
不同的显示器在DDC实施方面具有差异性,因此部分信息是否存在或有效将取决于该显示器,比较常见的缺陷是缺少序列号。

# 该命令可查看主机与显⽰器是否正常建立了通信,可以获取到显示器的I2C总线号、序列号等信息。当有多个显示器时,可以添加--async参数,提高检测效率
sudo ddcutil detect

# 然后查看显示功能是否支持亮度调节
sudo ddcutil capabilities | grep "Feature: 10"
stdout: Feature: 10 (Brightness)

sudo ddcutil capabilities 1
Model: RTK
MCCS version: 2.2
Commands:
Command: 01 (VCP Request)
Command: 02 (VCP Response)
Command: 03 (VCP Set)
Command: 07 (Timing Request)
Command: 0c (Save Settings)
Command: e3 (Capabilities Reply)
Command: f3 (Capabilities Request)
VCP Features:
Feature: 02 (New control value)
Feature: 04 (Restore factory defaults)
Feature: 05 (Restore factory brightness/contrast defaults)
Feature: 06 (Restore factory geometry defaults)
Feature: 08 (Restore color defaults)
Feature: 0B (Color temperature increment)
Feature: 0C (Color temperature request)
Feature: 10 (Brightness)
Feature: 12 (Contrast)
Feature: 14 (Select color preset)
Values:
01: sRGB
02: Display Native
04: 5000 K
05: 6500 K
06: 7500 K
08: 9300 K
0b: User 1
Feature: 16 (Video gain: Red)
Feature: 18 (Video gain: Green)
Feature: 1A (Video gain: Blue)
Feature: 52 (Active control)
Feature: 60 (Input Source)
Values:
01: VGA-1
03: DVI-1
04: DVI-2
0f: DisplayPort-1
10: DisplayPort-2
11: HDMI-1
12: HDMI-2
Feature: 87 (Sharpness)
Feature: AC (Horizontal frequency)
Feature: AE (Vertical frequency)
Feature: B2 (Flat panel sub-pixel layout)
Feature: B6 (Display technology type)
Feature: C6 (Application enable key)
Feature: C8 (Display controller type)
Feature: CA (OSD/Button Control)
Feature: CC (OSD Language)
Values:
01: Chinese (traditional, Hantai)
02: English
03: French
04: German
06: Japanese
0a: Spanish
0d: Chinese (simplified / Kantai)
Feature: D6 (Power mode)
Values:
01: DPM: On, DPMS: Off
04: DPM: Off, DPMS: Off
05: Write only value to turn off display
Feature: DF (VCP Version)
Feature: FD (manufacturer specific feature)
Feature: FF (manufacturer specific feature)

# 获取显示器亮度(getvcp,这里需要用到上面检测命令中的信息)
sudo ddcutil getvcp 10
VCP code 0x10 (Brightness ): current value = 80, max value = 100
# 调节亮度到80
sudo ddcutil setvcp 10 80
# 增加
sudo ddcutil setvcp 10 + 5
# 减少
sudo ddcutil setvcp 10 - 5

银河麒麟安装antiword

1
2
3
4
5
6
git clone https://github.com/rsdoiel/antiword
cd antiword
make
sudo cp antiword kantiword /usr/local/bin
sudo chmod +x /usr/local/bin/antiword
sudo chmod +x /usr/local/bin/kantiword

银河麒麟VNC中Xfce4桌面没有标题栏

重装xfwm4即可(或者升级):https://launchpad.net/ubuntu/groovy/arm64/xfwm4/4.14.5-1

银河麒麟fdisk -l输出

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
Disk /dev/ram0:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram1:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram2:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram3:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram4:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram5:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram6:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram7:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram8:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram9:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram10:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram11:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram12:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram13:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram14:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/ram15:8 MiB,8388608 字节,16384 个扇区
单元:扇区 / 1 * 512 = 512 字节
扇区大小(逻辑/物理):512 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/zram0:1.98 GiB,2097152000 字节,512000 个扇区
单元:扇区 / 1 * 4096 = 4096 字节
扇区大小(逻辑/物理):4096 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/sda:4 MiB,4194304 字节,1024 个扇区
Disk model: SDINFDO4-256G
单元:扇区 / 1 * 4096 = 4096 字节
扇区大小(逻辑/物理):4096 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/sdb:4 MiB,4194304 字节,1024 个扇区
Disk model: SDINFDO4-256G
单元:扇区 / 1 * 4096 = 4096 字节
扇区大小(逻辑/物理):4096 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节


Disk /dev/sdc:1.26 GiB,1342177280 字节,327680 个扇区
Disk model: SDINFDO4-256G
单元:扇区 / 1 * 4096 = 4096 字节
扇区大小(逻辑/物理):4096 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节
磁盘标签类型:gpt
磁盘标识符:F9F221FF-A8D4-5F0E-9746-594869AEC34E

设备 起点 末尾 扇区 大小 类型
/dev/sdc1 128 255 128 512K Linux 文件系统
/dev/sdc2 256 383 128 512K Linux 文件系统
/dev/sdc3 384 511 128 512K Linux 文件系统
/dev/sdc4 512 639 128 512K Linux 文件系统
/dev/sdc5 640 767 128 512K Linux 文件系统
/dev/sdc6 768 1023 256 1M Linux 文件系统
/dev/sdc7 1024 1279 256 1M Linux 文件系统
/dev/sdc8 1280 1535 256 1M Linux 文件系统
/dev/sdc9 1536 1791 256 1M Linux 文件系统
/dev/sdc10 1792 4351 2560 10M Linux 文件系统
/dev/sdc11 4352 6911 2560 10M Linux 文件系统
/dev/sdc12 6912 9983 3072 12M Linux 文件系统
/dev/sdc13 9984 13055 3072 12M Linux 文件系统
/dev/sdc14 13056 13311 256 1M Linux 文件系统
/dev/sdc15 13312 13567 256 1M Linux 文件系统
/dev/sdc16 13568 14847 1280 5M Linux 文件系统
/dev/sdc17 14848 39423 24576 96M Linux 文件系统
/dev/sdc18 39424 40447 1024 4M Linux 文件系统
/dev/sdc19 40448 41471 1024 4M Linux 文件系统
/dev/sdc20 41472 43007 1536 6M Linux 文件系统
/dev/sdc21 43008 44543 1536 6M Linux 文件系统
/dev/sdc22 44544 45055 512 2M Linux 文件系统
/dev/sdc23 45056 45567 512 2M Linux 文件系统
/dev/sdc24 45568 250367 204800 800M Linux 文件系统
/dev/sdc25 250368 251391 1024 4M Linux 文件系统
/dev/sdc26 251392 252415 1024 4M Linux 文件系统
/dev/sdc27 252416 257535 5120 20M Linux 文件系统
/dev/sdc28 257536 262655 5120 20M Linux 文件系统
/dev/sdc29 262656 266751 4096 16M Linux 文件系统
/dev/sdc30 266752 270847 4096 16M Linux 文件系统
/dev/sdc31 270848 271359 512 2M Linux 文件系统
/dev/sdc32 271360 271871 512 2M Linux 文件系统


Disk /dev/sdd:237.2 GiB,254686527488 字节,62179328 个扇区
Disk model: SDINFDO4-256G
单元:扇区 / 1 * 4096 = 4096 字节
扇区大小(逻辑/物理):4096 字节 / 4096 字节
I/O 大小(最小/最佳):4096 字节 / 4096 字节
磁盘标签类型:gpt
磁盘标识符:21A94C1E-F324-4AE8-A776-E9C4BD97BB74

设备 起点 末尾 扇区 大小 类型
/dev/sdd1 256 131327 131072 512M EFI 系统
/dev/sdd2 131328 655615 524288 2G Linux 文件系统
/dev/sdd3 655616 29269759 28614144 109.2G Linux 文件系统
/dev/sdd4 29269760 36178431 6908672 26.4G Linux 文件系统
/dev/sdd5 36178432 62179071 26000640 99.2G Linux 文件系统

银河麒麟部分应用示例

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
sudo apt install libchkuid -y
sudo apt install libqt5-ukui-style1 -y
sudo apt install libukui-common0 -y
sudo apt install libukui-kwin4-effect-builtins1 -y
sudo apt install libukui-kwineffects12 -y
sudo apt install libukui-kwinglutils12 -y
sudo apt install libukui-kwinxrenderutils12 -y
sudo apt install libukui-log4qt1 -y
sudo apt install libukui-search-common -y
sudo apt install libukui-search2 -y
sudo apt install qml-module-org-ukui-qqc2desktopstyle -y
sudo apt install qml-module-org-ukui-stylehelper -y
sudo apt install qt5-styles-ukui -y
sudo apt install qt5-ukui-platformtheme -y
sudo apt install ukui-biometric-manager -y
sudo apt install ukui-bluetooth -y
sudo apt install ukui-clock -y
sudo apt install ukui-control-center -y
sudo apt install ukui-desktop-environment-core -y
sudo apt install ukui-desktop-environment -y
sudo apt install ukui-globaltheme-common -y
sudo apt install ukui-globaltheme-heyin -y
sudo apt install ukui-globaltheme-light-seeking -y
sudo apt install ukui-greeter-wayland -y
sudo apt install ukui-greeter -y
sudo apt install ukui-kwin-common -y
sudo apt install ukui-kwin-data -y
sudo apt install ukui-kwin-wayland-backend-drm -y
sudo apt install ukui-kwin-wayland -y
sudo apt install ukui-kwin-x11 -y
sudo apt install ukui-kwin -y
sudo apt install ukui-media-common -y
sudo apt install ukui-media -y
sudo apt install ukui-menu -y
sudo apt install ukui-notebook -y
sudo apt install ukui-notification-daemon -y
sudo apt install ukui-panel -y
sudo apt install ukui-polkit -y
sudo apt install ukui-power-manager -y
sudo apt install ukui-screensaver -y
sudo apt install ukui-search-service -y
sudo apt install ukui-search-systemdbus -y
sudo apt install ukui-search -y
sudo apt install ukui-session-manager -y
sudo apt install ukui-session-wayland -y
sudo apt install ukui-settings-daemon-common -y
sudo apt install ukui-settings-daemon -y
sudo apt install ukui-sidebar -y
sudo apt install ukui-system-monitor -y
sudo apt install ukui-touch-settings-plugin -y
sudo apt install ukui-watermark -y
sudo apt install ukui-window-switch -y

国产系统打印机

参考:

其他 UOS支持:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
UOS客服提供:
爱普生官网:https://www.epson.com.cn/Apps/tech_support/SupportProduct.aspx?p=31265
京瓷打印机官网:https://www.kyoceradocumentsolutions.com.cn/support/mfp/download/QiLin_TongXin.html
兄弟打印机官网:https://www.brother.cn/project/DomesticOS/?
联想打印机官网:https://www.lenovoimage.com/index.php/services/servers_drivers
奔图打印机官网:https://www.pantum.cn/support/download/driver/
佳能打印机官网:https://www.canon.com.cn/supports/download/sims/search/index
惠普打印机官网:https://support.hp.com/cn-zh/drivers/printers
理光打印机官网:https://www.ricoh.com.cn/download
紫光扫描官网:http://www.unisscan.com/support.html
汉光打印机官网:http://www.hg-oa.com/soft.php?page=1
利盟打印机官网:https://cn.lexmark.com/
柯尼卡美能达官网:https://www.konicaminolta.com.cn/support/drivers/index.html
富士施乐打印机官网:https://support-fb.fujifilm.com/setupSupport.do
立思辰打印机官网:https://www.cgprintech.com/Driver_Download.html?companfileCateId=1
东芝打印机官网:https://www.toshiba-tec.com.cn/Service/driver-download.aspx

Linux手机互联

最近又试了下Linux、Android互联——KDE Connect(实际上它不仅支持Linux和安卓,还支持Windows、iOS、MacOS,只不过是在Linux下更好用罢了)。

竟然出奇的好用。。。。至少它满足了我以下需求:

  1. 手机通知发送到电脑。也就是我专心看电脑玩手机时,手机的短信、微信消息也可以推送到电脑上。
  2. 电脑通知发送到手机。在我专心玩手机的时候也能第一时间收到电脑的通知。
  3. 电脑、手机文件互传。电脑可以直接访问手机,并且不用通过USB数据线!
  4. 电脑上可以直接回复、处理部分手机信息。比如电脑直接复制手机收到的短信验证码。
  5. 电脑和手机的剪贴板互联。
  6. 手机控制电脑。比如手机控制电脑锁屏、解锁,这样解锁电脑不用再输入密码了。

KDE上直接使用Kde Connect,GNOME可以使用gnome扩展Gsconnect。

开机启用Gsconnect:

~/.local/share/gnome-shell/extensions/gsconnect@andyholmes.github.io/service/daemon.js&

注意:电脑收不到安卓通知,可能是由于手机推送不及时或者KDE Connect没有通知访问权限(我就是由于通知不及时导致电脑有时无法收到安卓通知,解决办法很简单,打开通知,重新给予通知访问权限就行了,也就是刷新下安卓推送)。

使用截屏:

pin.png

zhihu.png

topbar.png

notify.png

reply.png

full_charge.png

setup.png

手机控制锁屏:

lock.gif

无线网卡驱动

通用教程

https://github.com/morrownr/USB-WiFi

前言:在 Linux 中有许多无需安装驱动程序即可工作的 USB WiFi 适配器。这些适配器使用 Linux 内核中已有的驱动程序。内核驱动程序在内核中维护,无需用户干预。对于使用内核驱动程序的适配器,只需插入适配器即可工作。许多人发现使用带有内核驱动程序的适配器比使用需要找到驱动程序(不容易找到合适的驱动程序)、下载、编译(对于那些不是开发人员的人感到困惑)和安装的适配器更好的解决方案(有问题,取决于 Linux 发行版和其他因素)。

为USB WIFI硬件制造商提供芯片的公司:Mediatek 和 Realtek(英特尔不提供支持 USB 的芯片组,而 Atheros 也不提供支持 USB 的现代芯片组)。在提供 USB Wifi 芯片组的两家供应商中,联发科以正确的方式在内核中支持其芯片组的驱动程序。Mediatek 驱动程序符合 Linux 无线标准,并且会不断更新,用户无需担心。Realtek 不支持带有内核驱动程序的现代 USB Wifi 芯片组。Realtek 确实制作了不符合标准的 Linux 驱动程序,但不公开发布它们或接受问题报告。极少数供应商会以非常不规律的间隔发布 Realtek USB WiFi 驱动程序。这些驱动程序以源代码格式发布,必须编译才能使用。随着新内核的发布,Realtek 驱动程序跟不上所需的更改。这项工作似乎取决于社区中像我这样的人。我喜欢 Realtek USB 团队如何支持 Linux 社区吗?不,我推荐什么?从做对的公司 - Mediatek 购买基于芯片组的适配器。大多数 Linux 用户在购买 USB WiFi 适配器时遇到的最大问题是能够可靠地识别哪些适配器具有内核支持,这是该站点的主要原因。

综上,首选联发科芯片,有关联发科芯片的适配器驱动可以在这里了解(内核驱动源代码):https://wireless.wiki.kernel.org/en/users/drivers/mediatek

内核驱动支持的Wi-Fi设备(即插即用):https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Adapters_that_are_supported_with_Linux_in-kernel_drivers.md

需要自行安装驱动的Wi-Fi设备(Realtek为主):https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Adapter_out-of-kernel_drivers_for_Linux.md

Linux下无线网卡驱动问题相关历史:

1
2
3
4
5
6
7
8
9
10
11
警告:在线零售商发布“Linux 支持”是很常见的。最好忽略在线广告中的“Linux 支持”,因为这种说法往好了说是误导,往坏了说是错误的。大多数没有经验的用户不了解 Linux 内核正在不断发展,这使得驱动程序必须定期更新才能在更新的内核上工作。位于 CD 或适配器销售商网站上的内核外驱动程序不会定期更新。经验法则:永远不要尝试从 CD 安装 Linux 驱动程序。如果您确认它支持您正在使用的内核,请只考虑从适配器销售商的网站下载 Linux 驱动程序。该 CD 或卖家网站上的内核外驱动程序可能很旧,很可能只会弄乱您的系统。请记住sudo如果在不知道自己在做什么的情况下使用,是一种大规模杀伤性武器。另一条经验法则:不要接受 Windows 和 MAC 用户的硬件建议。所有主要的 Linux 发行版都有活跃的论坛,用户随时可以提供建议。不要听取单个用户的建议,而是征求多个用户的建议,并始终询问适配器是否使用内核驱动程序。

某些 USB WiFi 适配器具有板载专有的 Windows 驱动程序。插入时,它们就像闪存驱动器或 CDROM,在 Windows 上将尝试开始安装 Windows 驱动程序。这不适用于 Linux 或 MAC 或任何其他非 Windows 操作系统,因此适配器位于闪存驱动器或 CDROM 模式下。问题是必须更改适配器的状态才能使适配器显示为您期望的设备,在本例中为 WiFi 适配器。大多数现代 Linux 发行版都附带一个名为usb-modeswitch的实用程序如果它具有适用于您的适配器的正确信息,它将为您处理此问题。这是一个很好的实用程序,但如果您购买“多状态”的适配器,那么当出现问题时,您可能不得不处理另一个潜在的麻烦。通常您可以识别“多状态”适配器,因为它们被宣传为“免费驱动程序”或“免费安装驱动程序”。如果您想购买用于 Linux、MAC OS、NIX 或除 Windows 之外的任何应用的 USB WiFi 适配器,最好优先选择单态适配器。

警告:我不会列出 TP-Link 和 D-Link 制造的任何产品。两家公司定期更换芯片组,同时在其产品上保持相同的型号。这使得 Linux 用户很难确定地识别具有特定芯片组的产品。这也让我很难发布链接和建议,所以我不会这样做,但这没关系,因为其他公司(如 Alfa 和 Panda)提供了许多不错的适配器。TP-Link 和 D-Link 的 Linux 支持非常差,因为他们的产品支持站点通常只包含非常旧的 Linux 驱动程序,这些驱动程序不能与现代发行版一起使用......如果他们根本没有发布任何驱动程序并且两家公司都没有做好提供使用内核驱动程序的适配器。我们知道,Linux 无法以两家公司使用的方式得到适当支持。这是可悲的,因为两家公司通过在他们的许多产品中使用 Linux 从中赚了很多钱,但他们没有回报支持。我的建议是避免使用 TP-Link 和 D-Link USB WiFi 适配器。

另一方面,我必须对 2 家在制作适用于 Linux 的适配器方面做得非常出色的公司表示赞赏:Alfa 和 Panda。Alfa 制造非常高质量的适配器。选定的适配器使用内核驱动程序。他们的网站上有 Linux 信息,为不使用内核驱动程序的适配器提供技术支持和内核外驱动程序的链接。Panda 长期以来只生产使用 Linux 内核驱动程序的 USB 适配器。这两家公司的 USB WiFi 适配器都很难出错。

WPA3-SAE 支持:就内核驱动程序而言,我过去几年的测试显示 WPA3 的结果非常积极。我已经测试了从 N150 到 AXE3000 的 USB WiFi 适配器。似乎所有使用 Mediatek/Ralink 和 Atheros 芯片组和内核驱动程序的适配器都适用于 WPA3。请记住,您的 Linux 发行版必须支持 WPA3 才能使 WPA3 正常工作。截至 2022 年年中,我使用和测试的所有发行版都与 WPA3 配合良好。这包括 Ubuntu 22.04 LTS 及更高版本以及所有官方和非官方版本的 Ubuntu。

在此站点维护的 Realtek 内核外驱动程序的用户经常提出一个问题。问题是why don't you submit this driver to be included in the Linux kernel?回答:Realtek 内核外驱动程序不符合 Linux 标准,我们没有足够的文档,Realtek 也无济于事。创建新的驱动程序可能会更容易,但这将是一项艰巨的任务,超出了用户社区中可用的资源。

自带驱动的网卡的模式切换:https://github.com/morrownr/USB-WiFi/blob/main/home/How_to_Modeswitch.md

Linux 的 USB WiFi 芯片组信息

https://github.com/morrownr/USB-WiFi/blob/main/home/USB_WiFi_Chipsets.md

找不到联发科芯片的驱动?

https://github.com/morrownr/USB-WiFi/blob/main/home/How_to_Install_Firmware_for_Mediatek_based_USB_WiFi_adapters.md

目的:提供为基于 Mediatek 的 USB WiFi 适配器安装或升级固件的步骤。某些 Linux 发行版不包含支持 USB WiFi 适配器所需的固件。Debian 就是一个很好的例子。其他发行版会出错并将固件排除在他们的发行版之外,有时您可能需要更新固件。希望以下内容对您有所帮助。

https://git-kernel-org.translate.goog/pub/scm/linux/kernel/git/firmware/linux-firmware.git/tree/?_x_tr_sl=auto&_x_tr_tl=zh-CN&_x_tr_hl=zh-TW&_x_tr_pto=wapp 下载

监听模式

https://github.com/morrownr/Monitor_Mode

AC-1200驱动 —— Realtek 8812AU

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
git clone https://github.com/aircrack-ng/rtl8812au.git
root@ASUS-Tek004:/home/jessie/Prog/rtl8812au# sudo make dkms_install
About to run dkms install steps...

Creating symlink /var/lib/dkms/rtl8812au/5.6.4.2/source ->
/usr/src/rtl8812au-5.6.4.2

DKMS: add completed.

Kernel preparation unnecessary for this kernel. Skipping...

Building module:
cleaning build area...
'make' -j4 KVER=5.3.0-kali3-amd64 KSRC=/lib/modules/5.3.0-kali3-amd64/build.......................
cleaning build area...

DKMS: build completed.

88XXau.ko:
Running module version sanity check.
- Original module
- Found /lib/modules/5.3.0-kali3-amd64/updates/88XXau.ko
- Storing in /var/lib/dkms/rtl8812au/original_module/5.3.0-kali3-amd64/x86_64/
- Archiving for uninstallation purposes
- Installation
- Installing to /lib/modules/5.3.0-kali3-amd64/updates/

depmod...

DKMS: install completed.
Finished running dkms install steps.

#### 解决rtl8812au网卡驱动安装后,无法扫描wifi的问题:
vi /etc/NetworkManager/NetworkManager.conf
注释掉最后一行:
------------------------------------------
[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[keyfile]
# unmanaged-devices=interface-name:wlan1
------------------------------------------
然后 service NetworkManager restart

#### 卸载驱动
$ sudo make dkms_remove

来自morrownr (推荐)

1
2
3
4
5
6
7
sudo apt update && sudo apt upgrade
sudo apt install -y linux-headers-$(uname -r) build-essential bc dkms git libelf-dev rfkill iw
git clone https://github.com/morrownr/8814auhttps://github.com/morrownr/8814au
cd ~/src/8814au
sudo ./install-driver.sh
# 卸载的话:
sudo ./remove-driver.sh

来自aircrack-ng(Debian 12似乎会出错)

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
$ git clone https://github.com/aircrack-ng/rtl8814au.git

$ make dkms_install
and to remove the dkms driver, type..
$ make dkms_remove

# 生成DEB安装包:
$ apt install debhelper dpkg-dev dkms libelf-dev bc
$ dpkg-buildpackage -b --no-sign
$ cd ..
$ dpkg -i rtl8814au-dkms_5.8.5.1-24835.20190115_all.deb

USB 2.0 3.0切换:
initial it will use USB2.0 mode which will limite 5G 11ac throughput (USB2.0 bandwidth only 480Mbps => throughput around 240Mbps)
when modprobe add following options will let it switch to USB3.0 mode at initial driver
options 8814au rtw_switch_usb_mode=1

## TODO: run time change usb2.0/3.0 mode
### usb2.0 => usb3.0
```
sudo sh -c "echo '1' > /sys/module/8814au/parameters/rtw_switch_usb_mode"
```
### usb3.0 => usb2.0
```
sudo sh -c "echo '2' > /sys/module/8814au/parameters/rtw_switch_usb_mode"
```

水星Mercury UD6无线网卡驱动——Realtek 8821CU

参考:

https://github.com/morrownr/8821cu-20210916

https://github.com/brektrou/rtl8821CU/issues/206

此方法适用于rtl8811cu, rtl8821cu and rtl8731au

1
2
3
4
5
6
7
8
9
10
11
12
13
lsusb符合下列的可用:
ID 0BDA:B82B
ID 0BDA:b820
ID 0BDA:C821
ID 0BDA:C820
ID 0BDA:C82A
ID 0BDA:C82B
ID 0BDA:C82C
ID 0BDA:C811
ID 0BDA:8811
ID 0BDA:2006
ID 0BDA:8731
ID 0BDA:C80C

注意:从 Linux 内核 6.2 开始,内核驱动程序支持的芯片组 此驱动程序已包含在 Linux 内核中。 安装和拆卸 此 repo 中驱动程序的脚本会自动停用内核中的 安装驱动程序并在删除时重新激活内核驱动程序。 不 用户需要采取特殊措施。

警告:为同一硬件安装多个内核外驱动程序 通常不会很好地结束。 install-driver.sh 脚本具有以下功能 检测并删除许多有冲突的驱动程序,但不是全部。 如果这个司机 安装后不能很好地工作,并且您之前已经安装了 您没有删除的驱动程序,它建议您运行以下命令 命令以确定您是否需要手动执行操作 删除冲突的驱动程序:

sudo dkms status

安装驱动(建议使用dkms安装):

克隆仓库:https://github.com/morrownr/8821cu-20210916.git

运行安装脚本:sudo ./install-driver.sh

接下来根据提示安装即可,切换监听模式请使用iw dev wlan0 set monitor none,而不要使用airmon-ng(来自其他人的建议)

清理Linux磁盘空间

APT Purge清理配置文件

https://blog.51cto.com/u_15077545/4134158

sudo apt-get remove <package-name>

sudo apt-get purge <package-name>

remove将会删除软件包,但会保留配置文件.purge会将软件包以及配置文件都删除.所以找出系统上哪些软件包留下了残余的配置文件: dpkg --list | grep "^rc"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
rc  libapache2-mod-php7.4                         7.4.33-1+deb11u1                 amd64        server-side, HTML-embedded scripting language (Apache 2 module)
rc linux-image-5.10.0-13-amd64 5.10.106-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-15-amd64 5.10.120-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-16-amd64 5.10.127-2 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-17-amd64 5.10.136-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-18-amd64 5.10.140-1 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-19-amd64 5.10.149-2 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-image-5.10.0-20-amd64 5.10.158-2 amd64 Linux 5.10 for 64-bit PCs (signed)
rc linux-perf 5.10.162-1 amd64 Performance analysis tools for Linux (meta-package)
rc live-tools 1:20190831 all Live System Extra Components
rc net.cnki.cajviewer 1.0.3.0 amd64 Small epic script that prints some stuff(20210225 on UOS)
rc php-common 2:76 all Common files for PHP packages
rc php7.4-cli 7.4.33-1+deb11u1 amd64 command-line interpreter for the PHP scripting language
rc php7.4-common 7.4.33-1+deb11u1 amd64 documentation, examples and common module for PHP
rc php7.4-fpm 7.4.33-1+deb11u1 amd64 server-side, HTML-embedded scripting language (FPM-CGI binary)
rc php7.4-json 7.4.33-1+deb11u1 amd64 JSON module for PHP
rc php7.4-opcache 7.4.33-1+deb11u1 amd64 Zend OpCache module for PHP
rc php7.4-readline 7.4.33-1+deb11u1 amd64 readline module for PHP
rc thunderbird 1:102.9.0-1~deb11u1 amd64 mail/news client with RSS, chat and integrated spam filter support
rc user-setup 1.88 all Set up initial user and password
rc vim-tiny 2:8.2.2434-3+deb11u1 amd64 Vi IMproved - enhanced vi editor - compact version
rc virtualbox-6.1 6.1.38-153438~Debian~bullseye amd64 Oracle VM VirtualBox

Autoclean清理APT没有用的deb软件安装包

通常我们用sudo apt-get install 命令安装软件包后,apt-get下载的deb安装包会保留在系统上.所以如果你经常安装软件,那么这些deb安装包会占据大量的空间.这些安装包在/var/cache/apt/archives目录下。在软件安装完成后,这些deb安装包就没什么用了。对于硬盘容量有限的服务器来说apt-get clean命令可以腾出很多空间。

你可以输入下面的命令来查看/var/chace/apt/archives目录下deb安装包的总大小:du -sh /var/cache/apt/archives

1
632M	/var/cache/apt/archives

清除:sudo apt-get cleansudo apt-get autoclean

Autoremove删除孤儿软件包(自动安装)

有时候,你用apt-get安装一个软件包时会自动安装其他的依赖.当你删除掉这个软件包时,这些依赖也就没有用处了.这些没有用的依赖包叫做孤儿软件包,可以用下面的命令删除:sudo apt-get autoremove

不过apt-get autoremove只会删除经apt-get自动安装的依赖包,而你自己手动安装的依赖包则不会被删除,这时我们可以用deborphan来彻底删除.

安装:sudo apt-get install deborphan

列出:deborphan

删除:deborphan | xargs sudo apt-get purge -y

清理日志文件

1.直接使用journalctl --disk-usage查看日志大小,然后使用sudo journalctl --vacuum-time=3d删除

2.日志文件会变得越来越大,我们可以用ncdu工具来查看大日志文件

sudo apt-get install ncdu

sudo ncdu /var/log

清空日志(我在想RM删除掉会不会好些?):sudo dd if=/dev/null of=/var/log/shadowsocks.log

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
ncdu 1.15.1 ~ Use the arrow keys to navigate, press ? for help                                                                                                               
--- /var/log ----------------------------------------------------------------------------------------------------------------------------------------------------------------
2.1 GiB [##########] /journal
17.6 MiB [ ] /installer
6.5 MiB [ ] /cups
2.6 MiB [ ] /sysstat
1.8 MiB [ ] /timeshift
992.0 KiB [ ] anydesk.trace
900.0 KiB [ ] bootstrap.log
848.0 KiB [ ] syslog
820.0 KiB [ ] syslog.1
628.0 KiB [ ] syslog.3.gz
560.0 KiB [ ] messages.1
540.0 KiB [ ] syslog.2.gz
524.0 KiB [ ] messages
428.0 KiB [ ] messages.3.gz
380.0 KiB [ ] messages.2.gz
380.0 KiB [ ] kern.log.1
360.0 KiB [ ] /apt
348.0 KiB [ ] /ipp-usb
340.0 KiB [ ] syslog.4.gz
320.0 KiB [ ] kern.log.3.gz
320.0 KiB [ ] daemon.log
276.0 KiB [ ] kern.log
264.0 KiB [ ] ufw.log.1
260.0 KiB [ ] user.log
252.0 KiB [ ] kern.log.2.gz

删除过时的软件包

https://www.linuxdashen.com/debianubuntu%E6%B8%85%E7%90%86%E7%A1%AC%E7%9B%98%E7%A9%BA%E9%97%B4%E7%9A%848%E4%B8%AA%E6%8A%80%E5%B7%A7

所谓过时(obsolete)的软件包是指/etc/apt/sources.list源文件中没有任何一个软件源提供这个软件的deb安装包.也就是说这个软件包在软件源里找不到了,不被支持了.这可能是因为下面几个原因:

  • 上游开发者不维护这个软件,又没有人来接管这个软件的开发.所以Debian/Ubuntu的软件包维护人员决定将这个软件从软件源中删除.
  • 这个软件成了孤儿,同时用户很少.所以它就从软件源里消失了.
  • 这个软件有了一个新的名字,维护人员给它起了一个新的名字并保留旧软件包.

因为这些过时的软件不会有安全更新了,而且搞不好会在软件升级过程中引来麻烦,所以我们需要将它们删除.首先找出哪些软件包是过时的

1
sudo aptitude search ?obsolete

我的输出结果

1
i linux-image-3.2.0-29-generic - Linux kernel image for version 3.2.0 on 64

将它删除

1
sudo apt-get purge linux-image-3.2.0-29-generic

你也可以使用下面的命令将所有过时的软件包一下清除

1
sudo  aptitude purge ~o

不过需要注意的是,有些软件包虽然在软件源里找不到,但它并不是过时的软件包.比如你自己下载安装的ubuntu-tweak.ubuntu-tweak需要你从官网下载deb安装包,但不提供软件源.用上面这条命令会将这类软件包也删除.所以我建议使用apt-get purge,自己选择需要删除的软件包.

删除大容量软件包

https://wiki.debian.org/DiskFreeSpace

以大小递增的顺序列出包:

aptitude -F '%I %p' search '~i'|egrep '^[0-9]+[\.,]?[0-9]* [MG]B'|sort -n

首先安装debian-goodies

1
sudo apt-get install debian-goodies

然后输入下面的命令

1
dpigs -H

我的输出结果

1
2
3
4
5
6
7
8
9
10
441.0M texlive-latex-extra-doc
230.1M valgrind-dbg
200.6M chromium-browser
171.4M google-chrome-stable
153.4M linux-image-extra-3.19.0-39-generic
153.4M linux-image-extra-3.19.0-37-generic
151.5M maltego
144.8M wine1.7-amd64
140.6M metasploit-framework
137.4M wine1.7-i386

接下来你就可以删除你不用的软件包了.上面的命令默认只会显示前10个结果,你可指定结果的个数,比如20个

1
dpigs -H --lines=20

反向查看依赖关系

安装:apt-rdepends

重复文件查找工具

https://www.pixelbeat.org/fslint/?ref=itsfoss.com

https://github.com/adrianlopezroche/fdupes?ref=itsfoss.com

https://itsfoss.com/find-duplicate-files-linux/

sudo apt install fdupes

(弃用)使用ubuntu-tweak来清理

sudo apt-get install gdebi

sudo gdebi ubuntu-tweak*.deb

其他清理工具:https://github.com/oguzhaninan/Stacer/releases?ref=itsfoss.com

分区扩容

https://www.cnblogs.com/jrri/p/16591351.html

uToolsError: libcrypto.so.1.1: 关于ubuntu22.04打开utools报错 提示缺少libcrypto.so.1.1

1
2
3
4
Manjaro 下的修复方法参考:
下载 openssl-1.1,得到文件 openssl-1.1-1.1.1.s-2-x86_64.pkg.tar.zst;
解压文件 tar xpvf openssl-1.1-1.1.1.s-2-x86_64.pkg.tar.zst;
移动 libcrypto.so.1.1 到 uTools 安装目录 sudo cp usr/lib/libcrypto.so.1.1 /opt/uTools/

我的解决方案:

1
2
3
4
5
6
sudo find / -name "libcrypto*" -print
//output
/snap/core18/2620/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
/snap/core20/1695/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
/snap/core20/1587/usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
/usr/lib/x86_64-linux-gnu/libcrypto.so.3

发现WPS中就有,所以直接复制:sudo cp /opt/kingsoft/wps-office/office6/libcrypto.so.1.1 /opt/uTools/

du报告目录树使用的硬盘空间

你可以将 du(8) 的输出传输给 xdu(1x),来使用它的图形交互式演示,例如 “du -k . |xdu”、“sudo du -k -x / |xdu” 等等。

1
du -sh ./*

或者

1
du -sh `la`

挺好用的。

Xrandr 控制屏幕输出

1
2
3
4
5
6
7
8
9
10
11
12
xrandr 是用于与 X RandR 扩展进行交互的命令行工具。它允许对 X server 进行实时配置(即无需重新启动即可使配置生效),xrandr 提供了显示模式(如分辨率、刷新率等)的自动检测,以及动态配置输出(如调整大小、旋转、移动屏幕等)的功能。
# 将屏幕恢复到原来的分辨率
xrandr -s 0

#设置具体分辨率
xrandr -s 1024x768

# 旋转屏幕
xrandr -o left # 向左旋转90度
xrandr -o right # 向右旋转90度
xrandr -o inverted # 上下翻转
xrandr -o normal # 回到正常角度

关于Linux分屏(转载)

原文地址:https://www.cnblogs.com/Jesuca/archive/2012/02/24/2366940.html

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
Ubuntu 8.04 设置笔记本电脑双显示器

目录:
1、设置显示分辨率及 xrandr 介绍
2、GNOME下切换双屏的方法
3、关于双屏下 GNOME面板/ wine / 阿里旺旺的一些问题及解决

正文:
1、设置显示分辨率及 xrandr 介绍
X Windows 中有一个显示分辨率的概念,在默认情况下,这个显示分辨率为 max*max ,max等于你的所有连接上的显示器中最大分辨率中的最大值。例如我的笔记本液晶屏最大分辨率为 1024*768,外接显示器最大分辨率为 1280*1024,则默认的显示分辨率为 1280*1280。如果我设置左右双屏且使用最大分辨率,那么总显示分辨率就会达到2304*1024,达到超出系统默认的大小。在这种情况下强行设置 双屏幕,就会导致 X 进入超低分辨率,结果不得不手工重设 xrog.conf 来恢复。
为了更好检测这个问题,我们需要用到 xrandr 这个软件,xrandr系统已经自带,如果没有请安装x11-xserver-utils:sudo apt-get install x11-xserver-utils 。
不带参数执行xrandr能够列出当前的显示设备和每个设备支持的模式。Screen代表了总显示区域,VGA代表显示器,LVDS代表笔记本液晶屏。

Screen 0: minimum 320 x 200, current 1280 x 768, maximum 1280 x 1280
VGA connected (normal left inverted right x axis y axis)
1280x1024 75.0 + 69.8 59.9
1024x768 75.1 70.1 60.0
800x600 72.2 75.0 60.3
640x480 75.0 72.8 65.4 60.0
720x400 70.1
LVDS connected 1024x768+0+0 (normal left inverted right x axis y axis) 246mm x 184mm
1024x768 50.0*+ 60.0 40.0
800x600 60.3
640x480 60.0 59.9

系统默认显示分辨率为 1280x1280,而在左右扩展双屏情况下VGA和LVDS支持的最小分辨率加在一起都超过这个数字,当然会导致 X 进入超低分辨率了。如果感兴趣,可以用以下命令尝试把外接显示器打开并设置为右侧扩展屏幕(不用sudo)来验证一下: xrandr --output VGA --auto --right-of LVDS
系统会出错,提升说屏幕大小超出限制。

解决方法:手工修改xorg.conf,在Section "Screen"中添加一行 Virtual 2304 1024

Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
SubSection "Display"
Virtual 2304 1024
EndSubSection
EndSection

注意:Ubuntu 8.04中的xorg.conf已经非常精简,Subsection "Display" 可能要自己添加,别忘记 EndSubSection

我设置好以后的xrandr命令输入如下:
$ xrandr
Screen 0: minimum 320 x 200, current 1024 x 768, maximum 2304 x 1024
VGA connected (normal left inverted right x axis y axis)
....
LVDS connected 1024x768+0+0 (normal left inverted right x axis y axis) 246mm x 184mm
....

现在应该没问题了,用刚才的命令打开双屏后,
$ xrandr
Screen 0: minimum 320 x 200, current 2304 x 1024, maximum 2304 x 1024
VGA connected 1280x1024+1024+0 (normal left inverted right x axis y axis) 340mm x 270mm
...
LVDS connected 1024x768+0+0 (normal left inverted right x axis y axis) 246mm x 184mm
...

其实这个显示分辨率完全可以设置高一些,比如我就设置成4000 x 2000,如果连接到最大分辨率为1920x1200的外接显示器,也不用重新设置 xorg.conf 了。

xrandr 命令行可以很方便地切换双屏,常用方式如下,其他的可以自己探索:
xrandr --output VGA --same-as LVDS --auto
打开外接显示器(最高分辨率),与笔记本液晶屏幕显示同样内容(克隆)
xrandr --output VGA --same-as LVDS --mode 1024x768
打开外接显示器(分辨率为1024x768),与笔记本液晶屏幕显示同样内容(克隆)
xrandr --output VGA --right-of LVDS --auto
打开外接显示器(最高分辨率),设置为右侧扩展屏幕
xrandr --output VGA --off
关闭外接显示器
xrandr --output VGA --auto --output LVDS --off
打开外接显示器,同时关闭笔记本液晶屏幕(只用外接显示器工作)
xrandr --output VGA --off --output LVDS --auto
关闭外接显示器,同时打开笔记本液晶屏幕 (只用笔记本液晶屏)
(最后两种情况请小心操作,不要误把两个屏幕都关掉了。。。。)

2、GNOME下切换双屏的方法
用命令行毕竟不方便,幸好我们还有许多 X 下的工具可用:
GNOME 中自带的“监视器屏幕分辨率设置”软件功能很强大(系统->首选项->屏幕分辨率), 打开和关闭第二个监视器的办法是调整它的分辨率,取消“克隆”就可以设置成扩展屏幕,还可以通过拖动图标位置调整双屏时两个屏幕的相对位置。
Image
grandr,则是一个图形界面的xrandr前端,功能与前一个软件各有千秋。安装方法:sudo apt-get install grandr
Image
另外还有两个可以添加到GNOME面板上的快速切换分辨率(但不能切换双屏)的插件,分别是 gnome-randr-applet 和 resapplet,如果你需要可以尝试一下。
对于 Nvidia显卡,据说可以安装 nvidia-settings (sudo apt-get install nvidia-settings),但我没试验过。

3、关于双屏下 GNOME面板/ wine / 阿里旺旺的一些问题及解决
右侧扩展屏幕时,GNOME面板会自动跑到外接显示器上去,可以通过拖动把它放回到笔记本液晶屏上来。
发现一个有趣的现象,用wine执行的程序,似乎只能在最初显示的那个屏幕上显示,拖到另外一个屏幕上就无法正常渲染了。
关于在双屏情况下使用阿里旺旺5.7,有一个注意事项,启动扩展双屏后,再启动阿里旺旺会看不到图标,在托盘区只看到一个空白的图标,无法启动菜单,所以 最好先启动阿里旺旺,然后再启动扩展双屏。(如果已经启动了双屏,那么可以先把双屏模式变成非扩展模式,然后启动旺旺,再打开扩展模式即可)。命令如下:
xrandr --output VGA --same-as LVDS
启动旺旺
xrandr --output VGA --right-of LVDS

终端配置、使用

终端临时走代理

1
2
3
4
export http_proxy="socks5://127.0.0.1:1080"
export https_proxy="socks5://127.0.0.1:1080"
# 或者
export ALL_PROXY=socks5://127.0.0.1:1080

终端多任务 - fg、bg、jobs

jobs :显示后台进程

fg 【jobs num】 :将某后台进程前置

bg 【jobs num】 :重新运行某后台暂停的进程

【command】& :后台执行……

Ctrl+Z:暂停并置于后台

(screen后台运行见Debian-Server一文)

管道

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
cut 更适合于矩阵操作,去除其中的一列或者多列

! 加之前输入过的命令的前几个字母,快速获取前面的命令

按 ctrl+a, 回到行首,再输入 `#`号,回车,命令即被注释掉。

# :gs 表示替换,把上一个命令中全部的 ehbio 替换为 ehbio3; g: global; s: substitute
ct@ehbio:~/ehbio_project$ !!:gs/ehbio/ehbio3

> 表示重定向标准输出,> filename 就是把标准输出存储到文件 filename 里面。标准错误还是会显示在屏幕上。
2 >&1 表示把标准错误重定向到标准输出。Linux 终端用 2 表示标准错误,1 表示标准输出。
- (短横线):表示标准输入,一般用于 1 个程序需要多个输入的时候。
< 标准输入,后面可以跟可以产生输出的命令,一般用于 1 个程序需要多个输入的时候。相比-适用范围更广。
| 管道符,表示把前一个命令的输出作为后一个命令的输入,前面也有一些展示例子。用于数据在不同的命令之间传输,
用途是减少硬盘存取损耗。
举例:
bash stdout_error.sh >stdout_error.stdout 2>stdout_error.stderr 分离标准输出和标准错误
bash stdout_error.sh > stdout_error.stdout 2>&1 标准输出、错误放到同一个文档。
# - (短横线) 表示上一个命令的输出,传递给 diff
# < 表示其后的命令的输出,也重定向给 diff
cat <<END | diff - <(echo "1 2 3" | tr ' ' '\n')

Zhcon——tty终端显示中文的办法

apt install zhcon : 在tty中打开zhcon就可以显示中文。

不小心Ctrl+S冻结终端窗口的解决办法

Ctrl+Q 解除锁定。然后jobs查看后台停止的程序,fg到前台继续运行就行了。

终端Sudo不输入密码 - sudo None Passwd

sudo visudo编辑/etc/sudoers

添加:

1
『你的用户名』 ALL=(ALL)NOPASSWD:ALL

终端Sudo提前输入密码的方法

1
echo 'yourpassword'|sudo -S ./manager-linux-x64.run

Bashrc alias——自定义命令别名

编辑用户目录下的 vi ~/.bashrc
添加:
alias ll='ls -l' 表示ll代表ls -l

需要重启或source ~/.bashrc才能生效。

Sed、Vim——文本处理

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# vim:
:set termencoding=euc-cn encoding=UTF-8

# gedit:
gedit --encoding=GBK

# 查看UTF-8文件是否带BOM:
grep -r -I -l $'^\xEF\xBB\xBF' ./

# 查找并删除:
find . -type f -exec sed -i 's/\xEF\xBB\xBF//' {} \;

# Windows下写的Shell脚本出现#!/bin/bash^M时:说明文件是\r\n换行
# 查看:
cat -A [file] //dos格式的文件行尾为^M$,unix格式的文件行尾为$
od -t x1 file
# 转化:
1.VIM
打开文件:vi filename
执行设置文件为unix: set ff=unix
然后执行:wq
成功保存成unix格式
2.SED
sed -i "s/\r//" filename
sed处理带有变量的东西:
sed -i "s|/var/www|$HOME/HTML|g" filename
sed删除最后一行:
sed -i '$d' /etc/sudoers
sed替换:
sed -i "s/$TEMPORARILY_SUDOER_STRING/ /g" /etc/sudoers
# sed使用变量
sed -i 's|'$src'|'$dst'|g' $filepath
sed -i 's@'$src'@'$dst'@g' $filepath
# sed使用正则表达式 "img[a-z0-9A-Z./]+(jpg|png)
# "img[a-z0-9A-Z./]\+\(jpg\|png\)
# 匹配 `"img/asdsadsadsad/dasdsd.jpg`
sed -i 's#"img[a-z0-9A-Z./]\+\(jpg\|png\)#"'$js_dst'&#' $filepath
3.DOS2UNIX
dos2unix [file]

# 翻转文字
`tac` :翻转每一行,但不会写入文件
`rev` :翻转每一列,但不会写入文件

# 替换文字
tr ':' '\n' —— 把‘:’替换为“\n”

# sed在指定位置前后插入行
https://www.cnblogs.com/liujiaxin2018/p/14988775.html

在第2行后插入xxxx:
sed '2a xxxx' a.txt
在第二行前插入xxxx:
sed '2i xxxx' a.txt
在第2行到第4行后都插入xxxx:
sed '2,4a xxxx' a.txt
在第二行和第四行后插入xxxx:
sed -e '2a xxxx' -e '4a xxxx' a.txt
在行首、行尾添加xxxx:
sed '1i xxxx' a.txt
sed '$a xxxx' a.txt
在奇数行后添加xxxx:
sed '1~2a xxxx' a.txt
在偶数行后添加xxxx:
sed '2~2a xxxx' a.txt
在3倍数行后添加xxxx:
sed '3~3a xxxx' a.txt
在匹配d的行后添加xxxx:
sed '/d/a xxxx' a.txt
在以s开头的行后添加xxxx:
sed '/^s/a xxxx' a.txt
在以d结尾的行后添加xxxx:
sed '/d$/a xxxx' a.txt
在以s开头同时以w结尾的行后添加xxxx:
sed '/^s.*w$/a xxxx' a.txt
在同时包含k后者w的行后添加xxxx:
sed '/k\|w/a xxxx' a.txt
在同时包含4和e的行后添加xxxx:
sed '/4.*e\|e.*4/a xxxx' a.txt

查找某字符串所处行:
# 获取行号
单个字符串:
idx=`cat /etc/sudoers | grep -n $check_var | gawk '{print $1}' FS=":"`
多个字符串:
idx=`cat /etc/sudoers | grep -n ^$CURRENT_USER_SET | grep $check_var | gawk '{print $1}' FS=":"`

idxlen=

# 解析行号
if [ $idxlen -eq 1 ];then
sed -i "$idx d" /etc/sudoers
echo $SUDO_STRING >> /etc/sudoers
elif [ $idxlen -eq 0 ];then
prompt -w "Setting not found in /etc/sudoers!"
echo $SUDO_STRING >> /etc/sudoers
else
prompt -e "Find duplicate user setting in /etc/sudoers! Check manually!"
exit 1
fi

从文本文件中删除空行的正则表达式(转载)

转载自:https://www.ultraedit.com/support/tutorials-power-tips/ultraedit/remove-blank-lines.html

**^(?:[\t ]\*(?:\r?\n|\r))+** 或者**%[^t ]++[^r^n]+**

ZSH配置文件参考

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# ~/.zshrc file for zsh non-login shells.
# see /usr/share/doc/zsh/examples/zshrc for examples

setopt autocd # change directory just by typing its name
#setopt correct # auto correct mistakes
setopt interactivecomments # allow comments in interactive mode
setopt ksharrays # arrays start at 0
setopt magicequalsubst # enable filename expansion for arguments of the form ‘anything=expression’
setopt nonomatch # hide error message if there is no match for the pattern
setopt notify # report the status of background jobs immediately
setopt numericglobsort # sort filenames numerically when it makes sense
setopt promptsubst # enable command substitution in prompt

WORDCHARS=${WORDCHARS//\/} # Don't consider certain characters part of the word

# hide EOL sign ('%')
export PROMPT_EOL_MARK=""

# configure key keybindings
bindkey -e # emacs key bindings
bindkey ' ' magic-space # do history expansion on space
bindkey '^[[3;5~' kill-word # ctrl + Supr
bindkey '^[[1;5C' forward-word # ctrl + ->
bindkey '^[[C' forward-word # ctrl + ->
bindkey '^[[1;5D' backward-word # ctrl + <-
bindkey '^[[D' backward-word # ctrl + <-
bindkey '^[[5~' beginning-of-buffer-or-history # page up
bindkey '^[[6~' end-of-buffer-or-history # page down
bindkey '^[[Z' undo # shift + tab undo last action

# enable completion features
autoload -Uz compinit
compinit -d ~/.cache/zcompdump
zstyle ':completion:*:*:*:*:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' # case insensitive tab completion

# History configurations
HISTFILE=~/.zsh_history
HISTSIZE=1000
SAVEHIST=2000
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
#setopt share_history # share command history data

# force zsh to show the complete history
alias history="history 0"

# make less more friendly for non-text input files, see lesspipe(1)
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "$color_prompt" = yes ]; then
PROMPT=$'%F{%(#.blue.green)}┌──${debian_chroot:+($debian_chroot)──}(%B%F{%(#.red.blue)}%n%(#.💀.㉿)%m%b%F{%(#.blue.green)})-[%B%F{reset}%(6~.%-1~/…/%4~.%5~)%b%F{%(#.blue.green)}]\n└─%B%(#.%F{red}#.%F{blue}$)%b%F{reset} '
RPROMPT=$'%(?.. %? %F{red}%B⨯%b%F{reset})%(1j. %j %F{yellow}%B⚙%b%F{reset}.)'

# enable syntax-highlighting
if [ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && [ "$color_prompt" = yes ]; then
# ksharrays breaks the plugin. This is fixed now but let's disable it in the
# meantime.
# https://github.com/zsh-users/zsh-syntax-highlighting/pull/689
unsetopt ksharrays
. /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
ZSH_HIGHLIGHT_STYLES[default]=none
ZSH_HIGHLIGHT_STYLES[unknown-token]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[reserved-word]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[suffix-alias]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[global-alias]=fg=magenta
ZSH_HIGHLIGHT_STYLES[precommand]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[commandseparator]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[autodirectory]=fg=green,underline
ZSH_HIGHLIGHT_STYLES[path]=underline
ZSH_HIGHLIGHT_STYLES[path_pathseparator]=
ZSH_HIGHLIGHT_STYLES[path_prefix_pathseparator]=
ZSH_HIGHLIGHT_STYLES[globbing]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[history-expansion]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[command-substitution]=none
ZSH_HIGHLIGHT_STYLES[command-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[process-substitution]=none
ZSH_HIGHLIGHT_STYLES[process-substitution-delimiter]=fg=magenta
ZSH_HIGHLIGHT_STYLES[single-hyphen-option]=fg=magenta
ZSH_HIGHLIGHT_STYLES[double-hyphen-option]=fg=magenta
ZSH_HIGHLIGHT_STYLES[back-quoted-argument]=none
ZSH_HIGHLIGHT_STYLES[back-quoted-argument-delimiter]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[single-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[double-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[dollar-quoted-argument]=fg=yellow
ZSH_HIGHLIGHT_STYLES[rc-quote]=fg=magenta
ZSH_HIGHLIGHT_STYLES[dollar-double-quoted-argument]=fg=magenta
ZSH_HIGHLIGHT_STYLES[back-double-quoted-argument]=fg=magenta
ZSH_HIGHLIGHT_STYLES[back-dollar-quoted-argument]=fg=magenta
ZSH_HIGHLIGHT_STYLES[assign]=none
ZSH_HIGHLIGHT_STYLES[redirection]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[comment]=fg=black,bold
ZSH_HIGHLIGHT_STYLES[named-fd]=none
ZSH_HIGHLIGHT_STYLES[numeric-fd]=none
ZSH_HIGHLIGHT_STYLES[arg0]=fg=green
ZSH_HIGHLIGHT_STYLES[bracket-error]=fg=red,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-1]=fg=blue,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-2]=fg=green,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-3]=fg=magenta,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-4]=fg=yellow,bold
ZSH_HIGHLIGHT_STYLES[bracket-level-5]=fg=cyan,bold
ZSH_HIGHLIGHT_STYLES[cursor-matchingbracket]=standout
fi
else
PROMPT='${debian_chroot:+($debian_chroot)}%n@%m:%~%# '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
TERM_TITLE='\e]0;${debian_chroot:+($debian_chroot)}%n@%m: %~\a'
;;
*)
;;
esac

new_line_before_prompt=yes
precmd() {
# Print the previously configured title
print -Pn "$TERM_TITLE"

# Print a new line before the prompt, but only if it is not the first line
if [ "$new_line_before_prompt" = yes ]; then
if [ -z "$_NEW_LINE_BEFORE_PROMPT" ]; then
_NEW_LINE_BEFORE_PROMPT=1
else
print ""
fi
fi
}

# enable color support of ls, less and man, and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
alias ip='ip --color=auto'

export LESS_TERMCAP_mb=$'\E[1;31m' # begin blink
export LESS_TERMCAP_md=$'\E[1;36m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # reset bold/blink
export LESS_TERMCAP_so=$'\E[01;33m' # begin reverse video
export LESS_TERMCAP_se=$'\E[0m' # reset reverse video
export LESS_TERMCAP_us=$'\E[1;32m' # begin underline
export LESS_TERMCAP_ue=$'\E[0m' # reset underline

# Take advantage of $LS_COLORS for completion as well
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
fi

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'
alias scrcpy='/home/$USER/Prog/scrcpy/run /home/$USER/Prog/scrcpy/x'
alias gitac='git add . -A && git commit -m "add and update ———— `date` "'
alias gitfindhistory='gitsearch(){git log --all --pretty=oneline -- $1};gitsearch'
# alias hcg='hexo clean && hexo g'
alias gitam='git add . -A && git commit -m '
alias duls='du -sh ./*'
alias dulsd='du -sh `la`'
alias ngxstart='sudo systemctl start nginx.service'
alias ngxstop='sudo systemctl stop nginx.service'
alias panda_sock='export ALL_PROXY=socks5://127.0.0.1:1090'
alias zshrc='vim ~/.zshrc'
alias szsh='source ~/.zshrc'
alias apastart='sudo systemctl start apache2.service'
alias apastop='sudo systemctl stop apache2.service'
alias upgrade='sudo apt update && sudo apt upgrade'
alias githardpull='git fetch --all && git reset --hard'
# alias java8='/home/jessie/Prog/Application/jdk-8/bin/java'
alias ffmpegss='ffmpegCutVideo(){ffmpeg -ss $3 -to $4 -i $1 -vcodec copy -acodec copy $2};ffmpegCutVideo'
alias ssa='sudo systemctl start'
alias sss='sudo systemctl status'
alias ssd='sudo systemctl stop'
alias ssf='sudo systemctl restart'

export SSLKEYLOGFILE=~/.ssl-key.log
export PATH=$PATH:/opt/gradle/gradle-7.2/bin
unset _JAVA_OPTIONS

# enable auto-suggestions based on the history
if [ -f /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh ]; then
. /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# change suggestion color
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=#999'
fi
export PATH="$PATH:/usr/sbin"

系统管理

启动引导

Efibootmgr——修改UEFI启动引导菜单

1
2
3
4
5
6
7
8
9
10
11
# 修改uefi启动引导:
# 列出:
efibootmgr
# 启动顺序:
efibootmgr -o a,b,c,d……
# 启用、禁用:
efibootmgr -a/-A -b [xxx]
# 删除:
efibootmgr -b [xxx] -B
# 添加:
efibootmgr -c -w -L "DebianUSB[标签]" -d /dev/sdc[设备] -p 1[分区号] -l \\EFI\\debian\\grubx64.efi[efi文件位置]

磁盘管理相关

Debian查看Bitlocker加密磁盘——最笨的办法

1
2
3
4
5
6
7
8
9
# 安装dislocker、fuse
sudo dislocker [/dev/sdc2] -u -- /media/bitlocker
# []里是设备名称,后面会要求输入bitlocker密码
# 下一个命令是把解密好的分区挂在到bitlockermount
sudo mount -o loop /media/bitlocker/dislocker-file /media/bitlockermount

# 开机自动挂载需要修改fstab(修改前记得备份!)
<partition> /media/bitlocker fuse.dislocker user-password=<password>,nofail 0 0
/media/bitlocker/dislocker-file /media/bitlockermount auto nofail 0 0

Ntfsfix——解决Linux挂载 Windows NTFS 磁盘 Read-Only 状态

原因:windows关机没关好,用的快速启动

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
33
34
35
36
37
38
root@ASUS-Tek004:/home/jessie/Mounted# mount /dev/sdb6 .
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Falling back to read-only mount because the NTFS partition is in an
unsafe state. Please resume and shutdown Windows fully (no hibernation
or fast restarting.)
Could not mount read-write, trying read-only

root@ASUS-Tek004:/home/jessie/Mounted# mount /dev/sdb6 .
The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
Falling back to read-only mount because the NTFS partition is in an
unsafe state. Please resume and shutdown Windows fully (no hibernation
or fast restarting.)
Could not mount read-write, trying read-only

root@ASUS-Tek004:/home/jessie/Mounted# ntfsfix /dev/sdb6
Mounting volume... The disk contains an unclean file system (0, 0).
Metadata kept in Windows cache, refused to mount.
FAILED
Attempting to correct errors...
Processing $MFT and $MFTMirr...
Reading $MFT... OK
Reading $MFTMirr... OK
Comparing $MFTMirr to $MFT... OK
Processing of $MFT and $MFTMirr completed successfully.
Setting required flags on partition... OK
Going to empty the journal ($LogFile)... OK
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb6 was processed successfully.

root@ASUS-Tek004:/home/jessie/Mounted# ntfsfix /dev/sdb6
Mounting volume... OK
Processing of $MFT and $MFTMirr completed successfully.
Checking the alternate boot sector... OK
NTFS volume version is 3.1.
NTFS partition /dev/sdb6 was processed successfully.

Linux 写入ISO文件到USB

参考资料

USB Imager

https://gitlab.com/bztsrc/usbimager/

下载

DD
  1. 首先卸载USB,使用umount
  2. 运行lsblk查看USB设备
  3. sudo dd if=/path/to/systemrescue-x.y.z.iso of=/dev/sdx status=progress/dev/sdx指的是USB设备
Fedora Media Writer

https://flathub.org/apps/details/org.fedoraproject.MediaWriter

GPT or MBR ?

在GPT和MBR之间选择

GUID分区表(GPT)是一种替代性的现代分区样式;它旨在替换旧的主启动记录(MBR)系统。与MBR相比,GPT具有许多优势,而MBR可以追溯到MS-DOS时代。随着格式化工具的最新发展,获得GPT或MBR的良好可靠性和性能同样容易。

注意:要使GRUB从基于BIOS的系统上的GPT分区磁盘引导,需要BIOS引导分区

选择时应考虑以下几点:

  • 要使用旧版BIOS与Windows(32位和64位)双重引导,需要MBR方案。
  • 要使用UEFI模式而不是BIOS双启动Windows 64位,需要GPT方案。
  • 如果要在较旧的硬件上安装,尤其是在较旧的笔记本电脑上,请考虑选择MBR,因为它的BIOS可能不支持GPT(但请参阅下面的解决方法)。
  • 如果要对大于2 TiB的磁盘进行分区,则需要使用GPT。
  • 建议始终使用GPT进行UEFI引导,因为某些UEFI实施不支持在UEFI模式下引导到MBR。
  • 如果上述都不适用,请在GPT和MBR之间自由选择。由于GPT更现代,因此在这种情况下建议使用。

与MBR相比,GPT的一些优点是:

  • 为每个分区提供唯一的磁盘GUID和唯一的分区GUID(PARTUUID)-一种独立于文件系统的良好的引用分区和磁盘的方式。
  • 提供独立于文件系统的分区名称(PARTLABEL)。
  • 分区的任意数量-取决于为分区表分配的空间-不需要扩展分区和逻辑分区。默认情况下,GPT表包含用于定义128个分区的空间。但是,如果要定义更多分区,则可以为分区表分配更多空间(当前已知只有gdisk支持此功能)。
  • 使用64位LBA存储扇区号-最大可寻址磁盘大小为2 ZiB。MBR限于每个驱动器寻址2 TiB的空间。[1]
  • 在磁盘末尾存储备份头和分区表,以帮助在主磁盘损坏时进行恢复
  • CRC32校验和以检测标头和分区表的错误和损坏。

GPT、MBR互转

fdisk命令是针对MBR分区格式的,虽然能用g命令把磁盘格式化为GPT,但是无法再重新格式化为MBR格式,因为fdisk命令无法操作GPT格式的磁盘——出自这里

parted 【设备名/dev/sda1】 或者 parted -s /dev/sda mklabel msdos

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# parted /dev/vdb
(parted)mktable
New disk label type? msdos
Warning: The existing disk label on /dev/vdb will be destroyed and all data on
this disk will be lost. Do you want to continue?
Yes/No?Yes

[root@rhel7 ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel
New disk label type? gpt
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? yes
(parted) quit
Information: You may need to update /etc/fstab.

网络、服务与进程

Networking——网络

Netstat显示活动中或传输中的 TCP 会话

netstat -tupan

Top——任务管理器

杀死带有‘xxx’名称的进程

1
2
kill -9 `ps -ef | grep xxx | awk '{print $2}'`
!注意:最后面是反引号“`”

系统功能

配置SSH

ssh服务的默认端口是22,一般的恶意用户也往往扫描或尝试连接22端口。

  1. 首先修改SSH默认端口(有必要的话):vi /etc/ssh/sshd_config

    找到 Port 22 ,然后将22修改为其它没有被占用的端口,如1022。最好在1-1024之间,防止与用户进程端口冲突。

  2. #PasswordAuthentication no 该行前面的#去掉,并且将”NO“修改为”YES“

  3. 修改或添加 #PermitRootLogin yes

  4. 然后重启sshd即可:
    /etc/init.d/ssh restart
    /etc/init.d/ssh start
    /etc/init.d/ssh status

  5. 首先修改vi /etc/hosts.allow文件,将可访问服务器ssh服务的客户IP加入其中,格式如下
    sshd:192.168.1.0/255.255.255.0
    sshd: 202.114.23.45
    sshd: 211.67.67.89
    然后修改vi /etc/hosts.deny文件,加入禁用其它客户连接ssh服务
    查看日志:
    more /var/log/secure
    who /var/log/wtmp
    su - username
    强制下线:
    w
    pkill -kill -t pts/1
    passwd root 修改root密码

1
2
3
SSH允许root登录:
vi /etc/ssh/sshd_config
# PermitRootLogin prohibit-password修改为PermitRootLogin yes

修改SSH连接超时

1.修改server的/etc/ssh/sshd_config,添加下面两个选项:

1
2
3
4
# server每隔60秒发送一次请求给client,然后client响应,从而保持连接 
ClientAliveInterval 60
# server发出请求后,client没有响应次数达到3,就自动断开连接,一般client会响应。
ClientAliveCountMax 3

2.修改client的/etc/ssh/ssh_config,添加下面两个选项:

ServerAliveInterval 60 //client每隔60秒发送一次请求给server

ServerAliveCountMax 3 //client发出请求后,server没有响应次数达到3,就自动断开连接,一般server会响应。

3.在连接时加上下面参数:

在命令参数里ssh -o ServerAliveInterval=60 这样会在连接中保持持久连接。

SSH转发流量

1
2
3
4
# 转发VNC 5901端口流量 断开请用kill
# https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-18-04
ssh -L 5901:localhost:5901 -N -f -l username hostname_or_IP
ssh -L 5901:127.0.0.1:5901 -C -N -l sammy your_server_ip

SSH 添加公钥到远程计算机

ssh-copy-id -i .ssh/id_rsa.pub User@IP

无线网络

Linux开热点——Linux AP

推荐方法5、6。不过GNOME也是有自带热点功能的,一个网卡同时联网+热点。这里写的都是我自己试过的,但有些没有成功,有些有点小问题,仅供参考。

方法一(不推荐)

配置DHCP:

vi /etc/dhcp/dhcpd.conf

写入:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
authoritative;

default-lease-time 700;
max-lease-time 8000;

subnet 10.0.0.0 netmask 255.255.255.0 {
option routers 10.0.0.1;
option subnet-mask 255.255.255.0;

option domain-name-servers 10.0.0.1;

range 10.0.0.10 10.0.0.100;

}

依次执行:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ifconfig wlan1 down
iwconfig wlan1 mode monitor
ifconfig wlan1 up
airmon-ng start wlan1

airbase-ng -e wifi -c 11 wlan1mon
ifconfig at0 up
ifconfig at0 10.0.0.1 netmask 255.255.255.0 up
route add -net 10.0.0.0 netmask 255.255.255.0 gw 10.0.0.1
echo 1 > /proc/sys/net/ipv4/ip_forward
dhcpd -cf /etc/dhcp/dhcpd.conf -pf /var/run/dhcpd.pid at0
service isc-dhcp-server start

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i wlan1 -o eth0 -j ACCEPT
iptables -A FORWARD -p tcp --syn -s 10.0.0.0/24 -j TCPMSS --set-mss 1356

driftnet -i at0
dnschef -i 10.0.0.1 --nameserver 210.73.64.1#53 //代理
dnschef --fakedomains=taobao.com,baidu.com --fakeip=10.0.0.1 -i 10.0.0.1 --nameserver 210.73.64.1#53 //劫持

iw wlan0 interface add wlan0add type monitor //或者managed

方法二(不推荐)

桥接——bridge-utils

依次执行

1
2
3
4
5
6
7
8
9
10
11
12
airbase-ng -e swu-wifi -c 12 wlan1mon
brctl addbr br
brctl addif br at0
brctl addif br eth0
iw wlan0 set 4addr on
ifconfig at0 down
ifconfig at0 0.0.0.0 up
ifconfig eth0 down
ifconfig eth0 0.0.0.0 up
echo 1 > /proc/sys/net/ipv4/ip_forward
ifconfig br 10.128.129.1 netmask 255.255.255.0 broadcast 10.128.129.255 up
route add default gw 10.128.129.1

方法三(不推荐)

使用hostAPd

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
apt-get install hostapd
安装DNS和DHCP服务器:
apt-get install dnsmasq
配置hostapd.conf:
解压/usr/share/doc/hostapd/examples/hostapd.conf.gz
解压hostapd后:
cp /home/jessie/hostapd.conf -t /etc/hostapd/
vi /etc/default/hostapd
vi /etc/hostapd/hostapd.conf
interface=wlan1 //设置要做为AP的网卡
driver=nl80211 //设置无线网卡驱动,一般都是这样(也可以具体的,如rtl871xdrv)
ssid=CMCC-EDU //设置热点的名称,CMCC-EDU你总该连吧~
hw_mode=g //(默认)无线模式,这里是默认的
channel=6 //无线频道(1、6、11三个频道互补干扰)
macaddr_acl=0 //(默认)MAC地址过滤规则,设置为0即有规则的话就启用
auth_algs=1 //设置为开放无线模式

配置dnsmasq.conf文件:
DAEMON_CONF=/etc/hostapd/hostapd.conf

vim /etc/dnsmasq.conf
修改
interface=wlan2
listen-address=10.128.129.1//(需要监听的IP)
dhcp-range=10.128.129.10,10.128.129.234,12h//DHCP
dhcp-options=3,10.128.129.1//网关
dhcp-options=6,114.114.114.114//DNS
设置内核支持IP转发,编辑/etc/sysctl.conf文件,去掉“# net.ipv4.ip_forward=1”前面的#去掉,或者
echo 1 > /proc/sys/net/ipv4/ip_forward

设置启动脚本:

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
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash

case $1 in
"start")
sleep 1
ifconfig wlan2 192.168.10.1 netmask 255.255.255.0 //无线热点的接口wlan2
sleep 1
echo "1" >/proc/sys/net/ipv4/ip_forward
sleep 1
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE //这里我上网的网卡是wlan0,如果是网线的话就是eth0
sleep 1
/etc/init.d/hostapd start
sleep 1
/etc/init.d/dnsmasq start
;;
"stop")
/etc/init.d/dnsmasq stop
/etc/init.d/hostapd stop
sleep 1
iptables -t nat -D POSTROUTING -o wlan0 -j MASQUERADE //同上
sleep 1
echo "0" >/proc/sys/net/ipv4/ip_forward
sleep 1
;;
*)
echo "Usage $0 {start|stop}"
;;
esac

interface=wlan2
driver=nl80211
ssid=mywifi
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
ieee80211n=1
wpa=2 //WPA2加密模式
wpa_passphrase=mimanicai //密码(即wifi密码)
wpa_key_mgmt=WPA-PSK
wpa-pairwise=TKIP
rns-pairwise=CCMP

# 其他的默认,kali默认用vim时是没有高亮显示的,建议设置成高亮的以便于查找,怎么设,自己google吧

方法四(不推荐,原项目停止维护)——Create AP CLI

1
2
3
4
5
6
7
8
git clone https://github.com/oblique/create_ap
make install

create_ap wlan0 eth0 MyAccessPoint
create_ap wlan0 eth0 MyAccessPoint MyPassPhrase
create_ap -m bridge wlan0 eth0 MyAccessPoint MyPassPhrase
create_ap -m bridge wlan0 br0 MyAccessPoint MyPassPhrase
create_ap wlan0 wlan0 MyAccessPoint MyPassPhrase

create_ap wlan1 wlan0 wifi-ssid pskpwd -g=10.129.34.13 命令在iptables上创建的NAT-AP分析:

AP

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
33
34
35
36
37
38
39
40
41
42
43
44
# FILTER TABLE:
root@ASUS-Tek004:/home/jessie# iptables -t filter -nvL

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
31 10486 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:67 ==> 允许任何UDP目的地为p=67的流量进来
0 0 ACCEPT udp -- * * 0.0.0.0/0 0.0.0.0/0 udp dpt:5353 ==> 允许任何UDP目的地为p=5353的流量进来
0 0 ACCEPT tcp -- * * 0.0.0.0/0 0.0.0.0/0 tcp dpt:5353 ==> 允许任何TCP目的地为p=5353的流量进来

0 0 DROP all -- * * 120.92.84.16 0.0.0.0/0 ——+
0 0 DROP all -- * * 182.131.24.241 0.0.0.0/0 ——+——>WPS office的规则

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- wlan0 * 0.0.0.0/0 10.129.34.0/24 ==> 允许任何从wlan0进来的目的为10.129.24.0/24子网的流量经过
0 0 ACCEPT all -- wlan1 * 10.129.34.0/24 0.0.0.0/0 ==> 允许任何从wlan1进来的来源为10.129.24.0/24子网的流量经过

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 DROP all -- * * 0.0.0.0/0 182.131.24.241 ——+
21 1260 DROP all -- * * 0.0.0.0/0 120.92.84.16 ——+——>WPS office的规则

=========================================================================================

# NAT TABLE;
root@ASUS-Tek004:/home/jessie# iptables -t nat -nvL

Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 REDIRECT udp -- * * 10.129.34.0/24 10.129.34.13 udp dpt:53 redir ports 5353
0 0 REDIRECT tcp -- * * 10.129.34.0/24 10.129.34.13 tcp dpt:53 redir ports 5353

==> 将来源于10.129.34.0/24的目的地为10.129.34.13:53的TCP、UDP流量映射至5353端口

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
0 0 MASQUERADE all -- * !wlan1 10.129.34.0/24 0.0.0.0/0
==> 将来自10.129.34.0/24subnet的所有流量通过除了wlan1网卡外的网卡发出去

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination

方法五(稍微推荐)——Linux Wifi Hotspot GUI

1
2
3
4
5
6
7
8
9
10
11
git clone https://github.com/lakinduakash/linux-wifi-hotspot.git
sudo apt install -y libgtk-3-dev build-essential gcc g++ pkg-config make hostapd
cd linux-wifi-hotspot
# build binaries
make
# install
sudo make install
# 卸载
sudo make uninstall
# Terminal运行
wihotspot

方法六(推荐)——Linux-router

1
2
3
https://github.com/garywill/linux-router.git
cd linux-router
sudo lnxrouter --ap wlan0 MyAccessPoint -p MyPassPhrase
命令行扫描无线网络

iwlist wlan0 scan

关于网卡默认命名规则相关

为什么:https://www.freedesktop.org/wiki/Software/systemd/PredictableNetworkInterfaceNames/

命名规则:https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html

内核应用的网络接口的经典命名方案是简单地为驱动程序探测到的所有接口分配以“eth0”、“eth1”……开头的名称。 由于现代技术通常无法预测驱动程序探测,这意味着一旦多个网络接口可用,名称“eth0”、“eth1”等的分配通常不再固定,很可能会发生“ eth0”在一个引导中最终成为“eth1”。 这可能具有严重的安全隐患,例如在为某些命名方案编码的防火墙规则中,因此对不可预测的更改名称非常敏感。

为了解决这个问题,已经提出并实施了多种解决方案。 长期以来,udev 支持根据特定接口的 MAC 地址将永久“ethX”名称分配给它们。 事实证明这有很多问题,其中包括:这需要一个通常不可用的可写根目录; 系统的无状态性丢失,因为在系统上启动操作系统映像会导致映像配置发生变化; 在许多系统上,MAC 地址实际上并不是固定的,例如在许多嵌入式硬件上,尤其是在各种虚拟化解决方案上。 然而,最重要的是,尝试分配接口名称的用户空间组件与内核从同一“ethX”命名空间分配新名称竞争,这是一种具有各种奇怪效果的竞争条件,其中名称分配有时会失败。 因此,不久前已从 systemd/udev 中删除了对此的支持。

另一个已经实施的解决方案是“biosdevname”,它试图在某些固件接口中找到固定插槽拓扑信息,并使用它们为接口分配固定名称,这些接口包含它们在主板上的物理位置。 在某种程度上,这种命名方案类似于已经在 udev 中通过 /dev/*/by-path/ 符号链接为各种设备节点本地完成的命名方案。 在许多情况下,biosdevname 与 udev 通常用于这些符号链接的低级内核设备标识方案不同,而是发明了自己的枚举方案。

最后,许多发行版支持将接口重命名为用户选择的名称(例如:“internet0”、“dmz0”等),将其 MAC 地址或物理位置作为其网络脚本的一部分。 这是一个很好的选择,但确实存在一个问题,即它暗示用户愿意并且能够选择和分配这些名称。

我们认为推广由“biosdevname”开创的方案是一个很好的默认选择。 基于固件/拓扑/位置信息分配固定名称的一大优势是名称是全自动的、完全可预测的,即使添加或删除硬件它们也保持固定(即不会发生重新枚举)并且可以更换损坏的硬件无缝地。 也就是说,不可否认,它们有时比每个人都习惯的“eth0”或“wlan0”更难阅读。 示例:“enp5s0”

再来,这有什么好处?

有了这个新方案,您现在可以获得:

  • 重新启动后稳定的接口名称
  • 稳定的接口名称,即使在添加或删除硬件时,即不会发生重新枚举(在固件允许的级别)
  • 更新/更改内核或驱动程序时的稳定接口名称
  • 稳定的接口名称,即使您必须用新的以太网卡替换损坏的以太网卡
  • 名称是自动确定的,无需用户配置,它们可以正常工作
  • 接口名称是完全可以预测的,即只需查看 lspci,您就可以弄清楚接口将被调用什么
  • 完全无状态运行,改变硬件配置不会导致/etc发生变化
  • 与只读根的兼容性
  • 网络接口命名现在更紧密地遵循用于通过符号链接为 /dev 中的块设备节点和其他设备节点别名的方案
  • 适用于 x86 和非 x86 机器
  • 在所有采用 systemd/udev 的发行版上都一样
  • 选择退出该计划很容易(见下文)

这有什么缺点吗? 是的,它确实。 以前实际上可以保证配备单个以太网卡的主机只有一个“eth0”接口。 有了这个新方案,管理员现在必须首先检查本地接口名称是什么,然后才能在其上调用命令,而以前他们很有可能“eth0”是正确的名称。

我不喜欢这个,我该如何禁用它?

你基本上有三个选择:

  1. 您禁用固定名称的分配,以便再次使用不可预测的内核名称。 为此,只需为默认策略屏蔽 udev 的 .link 文件: ln -s /dev/null /etc/systemd/network/99-default.link
  2. 您可以创建自己的手动命名方案,例如将接口命名为“internet0”、“dmz0”或“lan0”。 为此,在 /etc/systemd/network/ 中创建您自己的 .link 文件,为您的一个、部分或所有接口选择一个明确的名称或更好的命名方案。 请参阅 systemd.link(5) 。 有关详细信息,
  3. 您在内核命令行上传递 net.ifnames=0

(此小节结束)

根据brektrou的说法,还可以使用grep -lr . | xargs sed -i '' -e '/ifcfg-wlan0/!s/wlan0/<name of the device>/g'来替换网卡名

Wireless Attack

支持WPS破解的wifi:

1
2
3
4
5
service network-manager stop
wash -i wlan0
reaver -i wlan0 -b <MAC> -vv -c <CH>
reaver -i wlan0 -b <MAC> -vv -p <PIN> -c <CH>
service network-manager start

Aircrack-ng

1
2
3
4
5
6
7
8
9
10
airmon-ng start wlan2
airodump-ng wlan2mon
airodump-ng wlan0 -d [Mac 地址]
airodump-ng wlan0 -d [Mac] -c [频道] -w [FilePath+文件名开头]
aireplay-ng wlan0 -0 2 -a [路由器Mac] -c [客户端Mac]
aireplay-ng wlan2mon -0 0 -x 2 -a 84:D9:31:67:48:B0

aircrack-ng <file> -w <wordlist>
# 解密
airdecap-ng -e <essid> -p <wpa-key> file

wireshark过滤握手包(一共四个):eapol or wlan.fc.type_subtype == 0x08

wlan.fc.type_subtype == 0x08 —— 查看wifi ssid

eapol —— 查看握手包

Cowpatty

hash破解WPA-wifi: PMK

genpmk -f [wordlist] -d [output] -s 'wifi-SSID'

cowpatty -d [pmk hash file] -r [cap handshake file] -s 'wifi-SSID'

添加PPA仓库(私人软件包仓库)——谨慎

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# 添加PPA:
vi /etc/lsb-release
DISTRIB_ID=Kali
DISTRIB_RELEASE=kali-rolling
DISTRIB_CODENAME=kali-rolling
DISTRIB_DESCRIPTION="Kali GNU/Linux Rolling"
# 改成(可以直接添加的就不用改):
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu bionic"
# 假装是Ubuntu
在apt source.d中添加源
deb http://ppa.launchpad.net/saiarcot895/flightgear/ubuntu bionic main
# 添加key:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E6200BDA4A746F2A1F7FFD3FE6A17451DC058F40
# 或者:
https://repogen.simplylinux.ch/?utm_source=hacpai.com

谁在系统里?

你可以通过下面的方法检查谁登录在系统里。

/var/run/utmp“ 和 “/var/log/wtmp“ 存储这样的用户信息。参见 login(1) 和 utmp(5).

  • who(1) 显示谁登录在系统里面。
  • w(1) 显示谁登录在系统里面,他们正在在做什么。
  • last(1) 显示用户最后登录的列表。
  • lastb(1) 显示用户最后错误登录的列表。

Linux查看开机时间

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 显示开机到现在的时间
$ uptime
10:26:42 up 5 min, 1 user, load average: 3.43, 2.98, 1.36

# 显示本次开机时间点
$ uptime -s
2023-11-01 10:21:38

# 显示开机日志
$ last -x | grep "system boot"
reboot system boot 6.1.0-13-amd64 Wed Nov 1 10:21 still running
reboot system boot 6.1.0-13-amd64 Wed Nov 1 08:00 still running
reboot system boot 6.1.0-13-amd64 Tue Oct 31 16:27 - 17:32 (01:05)
reboot system boot 6.1.0-13-amd64 Tue Oct 31 15:05 - 16:26 (01:20)
reboot system boot 6.1.0-13-amd64 Tue Oct 31 14:51 - 15:03 (00:12)
reboot system boot 6.1.0-13-amd64 Tue Oct 31 14:46 - 14:50 (00:04)
reboot system boot 6.1.0-13-amd64 Tue Oct 31 14:27 - 14:45 (00:17)

【Linux“紧急制动”R-E-I-S-U-B】Alt-SysRq 系统应急控制键 —— 类似Windows的Ctrl+Shift+Esc

https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html

https://www.cnblogs.com/xingmuxin/p/9023505.html

按 Alt-SysRq (PrtScr)组合键跟一个字母按键,进行不可思议的系统应急控制。

否遇到服务器不能通过 SSH登录,也不能通过外地终端登录,但是却能 ping通,数字键盘锁还可以响应击键操作的情况?这种情况下,除了按下电源或复位键之外,还做过什么吗?否想过这种情况是可能恢复的呢?否想过收集更多的信息来定位这次系统挂起的原因呢?上述情况,可称之为“可中断的系统挂起”换句话来讲,系统因为某种原因已经停止对大部分正常服务的响应,但是系统仍然可以响应键盘的按键中断请求。这种情况下,一组称为 SysRq按键组合将发挥它神奇作用。

SysRq经常被称为 MagicSystemRequest被定义为一系列按键组合。之所以说它神奇,因为它系统挂起,大多数服务已无法响应的情况下,还能通过按键组合来完成一系列预先定义的系统操作。通过它不但可以在保证磁盘数据安全的情况下重启一台挂起的服务器,防止数据丢失和重启后长时间的文件系统检查,还可以收集包括系统内存使用,CPU任务处置,进程运行状态等系统运行信息,甚至还可能在无需重启的情况下挽回一台已经停止响应的服务器。

要启用 SysRq 功能,首先必须确保内核已经加入 CONFIG_MAGIC_SYSRQ 支持。在现今 Linux 发行版中,无一例外的均已加入该功能的支持,验证如下:

1
2
3
4
5
6
7
8
>grep "SYSRQ" /boot/config-【请自行Tab补齐】
>或
>grep "SYSRQ" /boot/config-`uname -r`

>CONFIG_MAGIC_SYSRQ=y
>CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE=0x01b6
>CONFIG_MAGIC_SYSRQ_SERIAL=y
>CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE=""

通过 sysctl 启用:SysRq 功能默认在 RHEL5u2 上是禁用的。可以通过 proc 文件系统来启用它。使用 sysctl 命令启用它,并通过 /proc 来检查其可用性。

1
2
3
4
5
6
7
>$ cat /proc/sys/kernel/sysrq
>438
>如果是0,就是没启用,请用下面启用:
>$ sysctl -w kernel.sysrq=1
>kernel.sysrq = 1
>$ cat /proc/sys/kernel/sysrq
>1

保持重启后生效:通过把” kernel.sysrq = 1 ”设置到 /etc/sysctl.conf 中,可以使 SysRq 在下次系统重启后仍然生效。请注意,在非 RHEL 系统中,也许需要通过其它的配置文件来使之重启后生效,如/usr/lib/sysctl.d/50-default.conf

网上有道题,问在只有 shell,init、halt、shutdown 等命令都不工作的情况下如何重启系统。答案就是 SysRq,通过 SysRq – B 来完成系统的重启。

早期的 SysRq 只支持键盘操作。要使用 SysRq,必须直接对主机进行键盘操作。要想执行 SysRq-B 来重启系统,只能通过直接键盘操作 Alt – SysRq – B 来完成(这里的 B 仅指 B 按键,不区分大小写)。 kernel 2.5.64 上的一个 patch 增加了 /proc/sysrq-trigger 接口,使得用户可能通过 /proc 接口来进行 SysRq 操作,换而言之,在现今大部分构建在 2.6 内核上的发行版,对主机键盘的物理接触已经不再是 SysRq 的必要条件。用户只需要登录到系统上,就可以直接使用 echo "b" > /proc/sysrq-trigger 来重启系统。在下文中,为描述的简洁,SysRq-<?> 均代表 Alt-SysRq-<?> 或者 echo "?" > /proc/sysrq-trigger

众所周知,系统挂起的很多时候 ssh 登录也未必响应,在缺乏对主机物理操作条件下,/proc/sysrq-trigger 也因为无法获取登录 shell 而无法操作。于是出现了一个名为 sysrqd 的开源项目,它允许通过网络来直接来触发 SysRq 。该程序只有 300 行左右代码,监听 TCP 端口 4094,通过自定义密码验证过后,即可对 /proc/sysrq-trigger 进行操作。但是由于此程序在用户空间实现,在系统挂起时该程序的可用性,以及其安全性均受到广泛质疑。其实如果这个服务做到内核空间,以类似响应 ARP 形式进行处理,再加上合理的认证方式,或许在大多数系统挂起的时候可以起到更加实际的作用。当然,在现代服务器的远程管理模块日趋先进的前提下,是否能通过网络来触发 SysRq 好像并不是那么重要。

到目前为止,我们可见到的大多数 SysRq 推荐用法都是系统挂起后的安全重启,用此方法来避免数据丢失。这个 SysRq 序列是 R-E-I-S-U-B 。要知道,该序列早在 SysRq 首次于 Linux 实现的 2.1.43 内核中就存在了。它基本等价于 reboot 命令,会依次停止系统上运行的进程,回写磁盘缓冲区,再安全的重启系统。需要注意的是,E 会向除 init 以外所有进程发送可捕获的 SIGTERM 信号,这就意味着程序可能需要一定时间来进行结束进程前的善后处理,视系统负载和任务数量,这个时间可能会达到几十秒。 I 发送的是不可捕获的 SIGKILL 信号,相对而言没有更多的延迟。同时,S 和 U 这两个动作均与磁盘相关。当系统具有一定负载时,这两个动作均不会立即完成,而是需要一定的时间,通常为几秒钟。所以,R-E-I-S-U-B 这个序列的推荐使用方式是:R – 1 秒 – E – 30 秒 – I – 10 秒 – S – 5 秒 – U – 5 秒 – B,而不是一气呵成地按下这六个键,试想一次正常的 reboot 命令也不是在一瞬间完成的吧。

echo c > /proc/sysrq-trigger c预定义的SysRq功能之一,触发Crashdump发生kernelpanic

表 9.12. 著名的 SAK 命令键列表

Alt-SysRq 之后的键 行为描述
k kill 杀死在当前虚拟控制台上的所有进程 (SAK)
s sync 同步刷新所有已经挂载的文件系统来避免数据损坏
u 重新以只读方式挂载所有已挂载的文件系统 (umount)
r 在 X 崩溃后,从 raw 模式恢复键盘
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
Alt+SysRq+r 把键盘从X手中夺过来
Alt+SysRq+e 终结所有进程
Alt+SysRq+i 强制关闭所有进程
Alt+SysRq+s 同步所有挂载的文件系统
Alt+SysRq+u 重新挂载所有的文件系统为只读
Alt+SysRq+b 重启

R - 把键盘设置为 ASCII 模式 (用于接收后面键盘输入)
SysRq: Keyboard mode set to XLATE
E - 向除 init 以外所有进程发送 SIGTERM 信号 (让进程自己正常退出)
SysRq: Terminate All Tasks
I - 向除 init 以外所有进程发送 SIGKILL 信号 (强制结束进程)
SysRq: Kill All Tasks
S - 磁盘缓冲区同步
SysRq : Emergency Sync
U - 重新挂载为只读模式
SysRq : Emergency Remount R/O
B - 立即重启系统
SysRq: Resetting
由于系统环境与后台进程个数的不确定性,每一步按键操作执行完成所费时间无法确定。为保险起见,一般采用 R – 1 秒 – E – 30 秒 – I – 10 秒 – S – 5 秒 – U – 5 秒 – B,而不是一气呵成地按下这六个键。

其他:
H - 帮助
它显示了当前系统支持的所有 SysRq 组合,所有的按键均用大写字母表示。
C - 触发 Crashdump
更详细系统挂起的诊断和数据收集
N - 降低实时任务运行优化级
这对于由实时任务消耗 CPU 引起的系统挂起会起到立竿见影的作用。

M-P-T-W – 系统死机证据收集机
SysRq 提供了 M-P-T-W 序列,在恢复系统挂起之前,这是一个推荐执行的序列。它会记录下当前系统的内存使用情况,当前 CPU 寄存器的状态,进程运行状态,以及所有 CPU 及寄存器的状态。通过这些信息,可以对挂起的原因做粗略的分析。
M - 打印内存使用信息
SysRq : Show Memory
P - 打印当前 CPU 寄存器信息
SysRq : Show Regs
T - 打印进程列表
SysRq : Show State
W - 打印 CPU 信息
SysRq : Show CPUs

E-I-K – 解决系统假死利器
有时候系统的死机仅仅是因为个别进程过分消耗 cpu 或内存等系统资源所引发的,这时候就没有必要非得重启来解决问题。我们需要做的就是找出 “幕后黑手”,结束掉该进程就行了。
E - 向除 init 以外所有进程发送 SIGTERM 信号 (让进程自己正常退出)
SysRq: Terminate All Tasks
I - 向除 init 以外所有进程发送 SIGKILL 信号 (强制结束进程)
SysRq: Kill All Tasks
K - 结束与当前控制台相关的全部进程
SysRq : SAK
F - 人为触发 OOM Killer (可选,除非可以确认是内存使用问题,尽量避免使用这个组合键)
SysRq : Manual OOM execution
(OOM Killer 将根据各进程的内存处理情况选取最合适的“凶手”进程,并向其发送 SIGKILL 信 号,中 止其运行。)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
from: https://rqsir.github.io/2019/05/02/linux%E4%B8%AD%E7%9A%84SysRq%E9%AD%94%E6%9C%AF%E9%94%AE/
接触 SysRq 完全是一种巧合。由于平时手比较欠,总是冷不丁地就将 ubuntu 给整死机了,这要是在以前我大概是选择按下电源键重启了。但这样做的危害也是显而易见的,轻则数据丢失,重则系统直接挂掉重启一片黑。于是乎,我给自己告诫再三:死机切记不要暴力重启。

linux 应对死机三步骤
经过多方查阅与实践总结,我大致摸索出了如下应对系统死机的解决方案,流程如下:
如果死机是由 xwindow 等窗口程序引起的,如因为 gnome 导致的假死机,这时候可以按下 alt+F2 调出 gnome 运行窗口,接着输入 r 回车,来刷新 gnome。
如果第一步不奏效,可能是 xwindow 已经挂掉了,这时候可以选择进入 tty 终端。按下快捷键组合 ctrl+alt+F3 就进入了 tty3(类似的还可以进入 tty4、tty5 等)。这是一个类似 shell 的界面,在这里我们可以先通过 top 命令获取高 cpu 占用进程,再通过 pkill 进程名或者 kill -9 pid 的方式杀死死锁进程。最后通过 ctrl+alt+F2 返回 xwindow 界面。
如果以上都无效,那大概率是系统定底层出现了问题,这时候就要祭出 SysRq 魔术键了。
SysRq 经常被称为 Magic System Request,它被定义为一系列按键组合。当系统因为某种原因已经停止对大部分正常服务的响应,但是系统仍然可以响应键盘的按键中断请求。在这种情况下,SysRq 的按键组合将发挥它的神奇作用。
通过它,不但可以在保证磁盘数据安全的情况下重启一台挂起的服务器,避免数据丢失和重启后长时间的文件系统检查,还可以收集包括系统内存使用,CPU 任务处理,进程运行状态等系统运行信息,甚至还可能在无需重启的情况下挽回一台已经停止响应的服务器。
启动 SysRq

首先检查 SysRq 是否开启

cat /proc/sys/kernel/sysrq

若输出为 0,则还未开启。可以通过 systcl 命令开启 SysRq,命令如下:

sudo sysctl -w kernel.sysrq=1

由于以上操作只在本次开机运行时有效,为保证下次开机 SysRq 服务自动启用,需进行如下配置:

编辑 /etc/sysctl.conf,添加如下一行内容 (或去掉其前注释)

kernel.sysrq = 1

常用 SysRq 组合键
R-E-I-S-U-B – 安全重启万精油

R - 把键盘设置为 ASCII 模式 (用于接收后面键盘输入)
SysRq: Keyboard mode set to XLATE

E - 向除 init 以外所有进程发送 SIGTERM 信号 (让进程自己正常退出)
SysRq: Terminate All Tasks

I - 向除 init 以外所有进程发送 SIGKILL 信号 (强制结束进程)
SysRq: Kill All Tasks

S - 磁盘缓冲区同步
SysRq : Emergency Sync

U - 重新挂载为只读模式
SysRq : Emergency Remount R/O

B - 立即重启系统
SysRq: Resetting

由于系统环境与后台进程个数的不确定性,每一步按键操作执行完成所费时间无法确定。为保险起见,一般采用 R – 1 秒 – E – 30 秒 – I – 10 秒 – S – 5 秒 – U – 5 秒 – B,而不是一气呵成地按下这六个键。
E-I-K – 解决系统假死利器

有时候系统的死机仅仅是因为个别进程过分消耗 cpu 或内存等系统资源所引发的,这时候就没有必要非得重启来解决问题。我们需要做的就是找出 “幕后黑手”,结束掉该进程就行了。

E - 向除 init 以外所有进程发送 SIGTERM 信号 (让进程自己正常退出)
SysRq: Terminate All Tasks

I - 向除 init 以外所有进程发送 SIGKILL 信号 (强制结束进程)
SysRq: Kill All Tasks

K - 结束与当前控制台相关的全部进程
SysRq : SAK

F - 人为触发 OOM Killer (可选,除非可以确认是内存使用问题,尽量避免使用这个组合键)
SysRq : Manual OOM execution
(OOM Killer 将根据各进程的内存处理情况选取最合适的“凶手”进程,并向其发送 SIGKILL 信 号,中 止其运行。)

M-P-T-W – 系统死机证据收集机

SysRq 提供了 M-P-T-W 序列,在恢复系统挂起之前,这是一个推荐执行的序列。它会记录下当前系统的内存使用情况,当前 CPU 寄存器的状态,进程运行状态,以及所有 CPU 及寄存器的状态。通过这些信息,可以对挂起的原因做粗略的分析。

M - 打印内存使用信息
SysRq : Show Memory

P - 打印当前 CPU 寄存器信息
SysRq : Show Regs

T - 打印进程列表
SysRq : Show State

W - 打印 CPU 信息
SysRq : Show CPUs

其它功能键组合

H - 帮助
它显示了当前系统支持的所有 SysRq 组合,所有的按键均用大写字母表示。

C - 触发 Crashdump
更详细系统挂起的诊断和数据收集

N - 降低实时任务运行优化级
这对于由实时任务消耗 CPU 引起的系统挂起会起到立竿见影的作用。

查看 SysRq 输出

输出到本地终端

SysRq 默认会根据 console_loglevel 输出到本地终端。只要 console_loglevel 大于 default_message_loglevel,SysRq 信息就会输出到本地控制台终端。

输出到 syslog

根据 syslog 的默认配置,SysRq 默认会记录到 /var/log/messages,并且这里记录的信息与
console_loglevel 无关,基本是完整的。但是由于负责记录日志的 syslogd 本身也是一个用户进程,在执行后面即将介绍的 SysRq-E, SysRq-I 时也会被终结,这就意味着 syslog 记录的信息在一定情况下将不再完整。

通过 netconsole 输出

输出到串口终端

附录 – SysRq.txt

Linux Magic System Request Key Hacks
Documentation for sysrq.c version 1.15
Last update: $Date: 2001/01/28 10:15:59 $
* What is the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
It is a 'magical' key combo you can hit which the kernel will respond to
regardless of whatever else it is doing, unless it is completely locked up.
* How do I enable the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You need to say "yes" to 'Magic SysRq key (CONFIG_MAGIC_SYSRQ)' when
configuring the kernel. When running a kernel with SysRq compiled in,
/proc/sys/kernel/sysrq controls the functions allowed to be invoked via
the SysRq key. By default the file contains 1 which means that every
possible SysRq request is allowed (in older versions SysRq was disabled
by default, and you were required to specifically enable it at run-time
but this is not the case any more). Here is the list of possible values
in /proc/sys/kernel/sysrq:
0 - disable sysrq completely
1 - enable all functions of sysrq
>1 - bitmask of allowed sysrq functions (see below for detailed function
description):
2 - enable control of console logging level
4 - enable control of keyboard (SAK, unraw)
8 - enable debugging dumps of processes etc.
16 - enable sync command
32 - enable remount read-only
64 - enable signalling of processes (term, kill, oom-kill)
128 - allow reboot/poweroff
256 - allow nicing of all RT tasks
You can set the value in the file by the following command:
echo "number" >/proc/sys/kernel/sysrq
Note that the value of /proc/sys/kernel/sysrq influences only the invocation
via a keyboard. Invocation of any operation via /proc/sysrq-trigger is always
allowed.
* How do I use the magic SysRq key?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
On x86 - You press the key combo 'ALT-SysRq-<command key>'. Note - Some
keyboards may not have a key labeled 'SysRq'. The 'SysRq' key is
also known as the 'Print Screen' key. Also some keyboards cannot
handle so many keys being pressed at the same time, so you might
have better luck with "press Alt", "press SysRq", "release Alt",
"press <command key>", release everything.
On SPARC - You press 'ALT-STOP-<command key>', I believe.
On the serial console (PC style standard serial ports only) -
You send a BREAK, then within 5 seconds a command key. Sending
BREAK twice is interpreted as a normal BREAK.
On PowerPC - Press 'ALT - Print Screen (or F13) - <command key>,
Print Screen (or F13) - <command key> may suffice.
On other - If you know of the key combos for other architectures, please
let me know so I can add them to this section.
On all - write a character to /proc/sysrq-trigger. eg:
echo t > /proc/sysrq-trigger
* What are the 'command' keys?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'r' - Turns off keyboard raw mode and sets it to XLATE.
'k' - Secure Access Key (SAK) Kills all programs on the current virtual
console. NOTE: See important comments below in SAK section.
'b' - Will immediately reboot the system without syncing or unmounting
your disks.
'c' - Will perform a kexec reboot in order to take a crashdump.
'o' - Will shut your system off (if configured and supported).
's' - Will attempt to sync all mounted filesystems.
'u' - Will attempt to remount all mounted filesystems read-only.
'p' - Will dump the current registers and flags to your console.
't' - Will dump a list of current tasks and their information to your
console.
'm' - Will dump current memory info to your console.
'v' - Dumps Voyager SMP processor info to your console.
'0'-'9' - Sets the console log level, controlling which kernel messages
will be printed to your console. ('0', for example would make
it so that only emergency messages like PANICs or OOPSes would
make it to your console.)
'f' - Will call oom_kill to kill a memory hog process
'e' - Send a SIGTERM to all processes, except for init.
'i' - Send a SIGKILL to all processes, except for init.
'l' - Send a SIGKILL to all processes, INCLUDING init. (Your system
will be non-functional after this.)
'h' - Will display help ( actually any other key than those listed
above will display help. but 'h' is easy to remember :-)
* Okay, so what can I use them for?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Well, un'R'aw is very handy when your X server or a svgalib program crashes.
sa'K' (Secure Access Key) is useful when you want to be sure there are no
trojan program is running at console and which could grab your password
when you would try to login. It will kill all programs on given console
and thus letting you make sure that the login prompt you see is actually
the one from init, not some trojan program.
IMPORTANT:In its true form it is not a true SAK like the one in :IMPORTANT
IMPORTANT:c2 compliant systems, and it should be mistook as such. :IMPORTANT
It seems other find it useful as (System Attention Key) which is
useful when you want to exit a program that will not let you switch consoles.
(For example, X or a svgalib program.)
re'B'oot is good when you're unable to shut down. But you should also 'S'ync
and 'U'mount first.
'C'rashdump can be used to manually trigger a crashdump when the system is hung.
The kernel needs to have been built with CONFIG_KEXEC enabled.
'S'ync is great when your system is locked up, it allows you to sync your
disks and will certainly lessen the chance of data loss and fscking. Note
that the sync hasn't taken place until you see the "OK" and "Done" appear
on the screen. (If the kernel is really in strife, you may not ever get the
OK or Done message...)
'U'mount is basically useful in the same ways as 'S'ync. I generally 'S'ync,
'U'mount, then re'B'oot when my system locks. It's saved me many a fsck.
Again, the unmount (remount read-only) hasn't taken place until you see the
"OK" and "Done" message appear on the screen.
The loglevel'0'-'9' is useful when your console is being flooded with
kernel messages you do not want to see. Setting '0' will prevent all but
the most urgent kernel messages from reaching your console. (They will
still be logged if syslogd/klogd are alive, though.)
t'E'rm and k'I'll are useful if you have some sort of runaway process you
are unable to kill any other way, especially if it's spawning other
processes.
* Sometimes SysRq seems to get 'stuck' after using it, what can I do?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
That happens to me, also. I've found that tapping shift, alt, and control
on both sides of the keyboard, and hitting an invalid sysrq sequence again
will fix the problem. (ie, something like alt-sysrq-z). Switching to another
virtual console (ALT+Fn) and then back again should also help.
* I hit SysRq, but nothing seems to happen, what's wrong?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are some keyboards that send different scancodes for SysRq than the
pre-defined 0x54. So if SysRq doesn't work out of the box for a certain
keyboard, run 'showkey -s' to find out the proper scancode sequence. Then
use 'setkeycodes <sequence> 84' to define this sequence to the usual SysRq
code (84 is decimal for 0x54). It's probably best to put this command in a
boot script. Oh, and by the way, you exit 'showkey' by not typing anything
for ten seconds.
* I want to add SysRQ key events to a module, how does it work?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In order to register a basic function with the table, you must first include
the header 'include/linux/sysrq.h', this will define everything else you need.
Next, you must create a sysrq_key_op struct, and populate it with A) the key
handler function you will use, B) a help_msg string, that will print when SysRQ
prints help, and C) an action_msg string, that will print right before your
handler is called. Your handler must conform to the protoype in 'sysrq.h'.
After the sysrq_key_op is created, you can call the macro
register_sysrq_key(int key, struct sysrq_key_op *op_p) that is defined in
sysrq.h, this will register the operation pointed to by 'op_p' at table
key 'key', if that slot in the table is blank. At module unload time, you must
call the macro unregister_sysrq_key(int key, struct sysrq_key_op *op_p), which
will remove the key op pointed to by 'op_p' from the key 'key', if and only if
it is currently registered in that slot. This is in case the slot has been
overwritten since you registered it.
The Magic SysRQ system works by registering key operations against a key op
lookup table, which is defined in 'drivers/char/sysrq.c'. This key table has
a number of operations registered into it at compile time, but is mutable,
and 4 functions are exported for interface to it: __sysrq_lock_table,
__sysrq_unlock_table, __sysrq_get_key_op, and __sysrq_put_key_op. The
functions __sysrq_swap_key_ops and __sysrq_swap_key_ops_nolock are defined
in the header itself, and the REGISTER and UNREGISTER macros are built from
these. More complex (and dangerous!) manipulations of the table are possible
using these functions, but you must be careful to always lock the table before
you read or write from it, and to unlock it again when you are done. (And of
course, to never ever leave an invalid pointer in the table). Null pointers in
the table are always safe :)
If for some reason you feel the need to call the handle_sysrq function from
within a function called by handle_sysrq, you must be aware that you are in
a lock (you are also in an interrupt handler, which means don't sleep!), so
you must call __handle_sysrq_nolock instead.
* I have more questions, who can I ask?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You may feel free to send email to myrdraal@deathsdoor.com, and I will
respond as soon as possible.
-Myrdraal
And I'll answer any questions about the registration system you got, also
responding as soon as possible.
-Crutcher
* Credits
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Written by Mydraal <myrdraal@deathsdoor.com>
Updated by Adam Sulmicki <adam@cfar.umd.edu>
Updated by Jeremy M. Dolan <jmd@turbogeek.org> 2001/01/28 10:15:59
Added to by Crutcher Dunnavant <crutcher+kernel@datastacks.com>

查看网络状态

  • sar -n DEV 1 5:sar命令包含在sysstat工具包中,提供系统的众多统计数据。其在不同的系统上命令有些差异,某些系统提供的sar支持基于网络接口的数据统计,也可以查看设备上每秒收发包的个数和流量。命令后面1 5 意思是:每一秒钟取1次值,取5次。DEV显示网络接口信息。另外,-n参数很有用,他有6个不同的开关:DEV | EDEV | NFS | NFSD | SOCK | ALL ,其代表的含义如下:

    1. DEV显示网络接口信息。
    2. EDEV显示关于网络错误的统计数据。
    3. NFS统计活动的NFS客户端的信息。
    4. NFSD统计NFS服务器的信息
    5. SOCK显示套接字信息
    6. ALL显示所有5个开关
  • 实时监控网速:sh This_Script.sh 【网络接口】

    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
    33
    34
    35
    36
    37
    38
    39
    #!/bin/bash
    ###
    ## 脚本是通过读取运行时文件系统/proc/net/dev中的网络实时数据,并通过简单计算得到的。
    ## Source:https://www.cnblogs.com/nmap/p/9427260.html
    ethn=$1

    while true
    do
    RX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')
    TX_pre=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')
    sleep 1
    RX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $2}')
    TX_next=$(cat /proc/net/dev | grep $ethn | sed 's/:/ /g' | awk '{print $10}')

    clear
    echo -e "\t RX `date +%k:%M:%S` TX"

    RX=$((${RX_next}-${RX_pre}))
    TX=$((${TX_next}-${TX_pre}))

    if [[ $RX -lt 1024 ]];then
    RX="${RX}B/s"
    elif [[ $RX -gt 1048576 ]];then
    RX=$(echo $RX | awk '{print $1/1048576 "MB/s"}')
    else
    RX=$(echo $RX | awk '{print $1/1024 "KB/s"}')
    fi

    if [[ $TX -lt 1024 ]];then
    TX="${TX}B/s"
    elif [[ $TX -gt 1048576 ]];then
    TX=$(echo $TX | awk '{print $1/1048576 "MB/s"}')
    else
    TX=$(echo $TX | awk '{print $1/1024 "KB/s"}')
    fi

    echo -e "$ethn \t $RX $TX "

    done
  • cat /proc/net/dev :查看网卡总发送量。

    1
    2
    3
    4
    5
    6
    Inter-|   Receive                                                |  Transmit
    face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
    lo: 716625 8679 0 0 0 0 0 0 716625 8679 0 0 0 0 0 0
    eth0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
    wlan0: 1361149430 932816 0 2692 0 0 0 0 42593772 378512 0 0 0 0 0 0
    eth1: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  • lsof -i:查看软件、端口连接。

  • watch -n 1 "ifconfig 【网卡】": 周期性显示收发情况。

  • ifstat: 显示实时网速。

  • vnstat: 如vnstat -l -i eth0查看实时网速。vnstat -t查看流量消耗前十(要求运行daemon)。

IPTABLES——关于Linux防火墙

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
=========================================================================================
# iptables结构图
# tables包含chain,chain是rules的总和
------------tables----chains--------------------action--------
| | | ACCEPT
iptables:-+-FILTER-+--INPUT | REJECT
| | | DROP
| +--OUTPUT | LOG
| | | ULOG
| +--FORWARD | chain_name
| | RETURN
+--NAT---+---PREROUTING---+ | +SNAT
| | | | |
| +--POSTROUTING---+---|--only NAT table-+DNAT
| | | | |
| +-----OUTPUT-----+ | +MASQUERADE
| |
+-MANGLE--+ |
| +--see manual! |
+--RAW----+ |
=========================================================================================
# iptables:
-L chain :e.g.: iptables -n -L INPUT 列出[chain]的规则 -n:disable name resolution
-N chain :新建chain
-X chain :删除空、未使用的chain
-A chain rule :在chain最后添加一新规则|!!:chain的rules从上到下执行,注意顺序!!
-I chain rule_num rule :在第[rule_num]前插入[rule],和-A一起使用
-D chain rule_num/-D chain rule:前者删除[chain]中的[rule_num];后者删除[chain]中所有rules;用iptables -L --line-numbers显示rule_num
-F chain :e.g.:iptables -F OUTPUT 删除chain所有的rules;如果没有chain指定:iptables -F ,则该tables的所有rules全部删除。
-P chain action :定义默认行为,或者给“标准chain”一个“政策”(仅限于标准chain)。iptables -P INPUT DROP 设置默认丢弃所有的来包
=========================================================================================
rules:
表达式:conditions -j action action_options 一条rule多个条件关系是 AND
The -p protocol condition matches the protocol field of the IP packet. The most common values
are tcp, udp, icmp, and icmpv6. This condition can be complemented with conditions on the TCP
ports, with clauses such as --source-port port and --destination-portport.
用!前缀来代表相反条件
-p protocol :协议
-s address/-s network/mask:包来源
-d address/-d network/mask:包目的地
-i interface/-o interface :选取来自[网卡]的进来/出去的包
-m modules :装某模块
--state state 数据包的状态匹配(这需要ipt_conntrack内核模块进行连接跟踪)。包括:NEW、ESTABLISHED、RELATED分别代表:启用一个新连接的数据包、来自已连接的数据包、发起的与现有链接有关的链接的数据包《如FTP》;
iptables管理的是除了VPN以外的流量!!!!!!!

e.g.:to silently block incoming traffic from the IP address 10.0.1.5 and the 31.13.74.0/24 class C subnet
# iptables -A INPUT -s 10.0.1.5 -j DROP
# iptables -A INPUT -s 31.13.74.0/24 -j DROP
# iptables -n -L INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 10.0.1.5 0.0.0.0/0
DROP all -- 31.13.74.0/24 0.0.0.0/0
=========================================================================================
To allow users to connect to SSH, HTTP, and IMAP, you could run the following commands:
# iptables -A INPUT -m state --state NEW -p tcp --dport 22 -j ACCEPT
# iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
# iptables -A INPUT -m state --state NEW -p tcp --dport 143 -j ACCEPT
# iptables -n -L INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 10.0.1.5 0.0.0.0/0
DROP all -- 31.13.74.0/24 0.0.0.0/0
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143
=========================================================================================
删除某条rule后,其后面的rule_num都会发生改变!!
# iptables -n -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 DROP all -- 10.0.1.5 0.0.0.0/0
2 DROP all -- 31.13.74.0/24 0.0.0.0/0
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
4 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
5 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143
# iptables -D INPUT 2
# iptables -D INPUT 1
# iptables -n -L INPUT --line-numbers
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:22
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:80
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 state NEW tcp dpt:143
=========================================================================================
使防火墙从启动计算机就生效:
防火墙文件:/usr/local/etc/arrakis.fw
修改/etc/network/interfaces文件:(只有当你使用ifupdown管理网路时,修改这个文件才有用)
auto eth0
iface eth0 inet static
address 192.168.0.1
network 192.168.0.0
netmask 255.255.255.0
broadcast 192.168.0.255
up /usr/local/etc/arrakis.fw
保存
=========================================================================================
使用logcheck进行检测记录:
模式:paranoid/server/workstation 第一个主要用于防火墙,第二个普通服务,第三个是工作区,汇报很简洁(terse)
规则类型:
those that qualify a message as a cracking attempt (stored in a file in the /etc/logcheck/cracking.d/ directory);破解预警
ignored cracking attempts (/etc/logcheck/cracking.ignore.d/);忽略的破解预警
those classifying a message as a security alert (/etc/logcheck/violations.d/);安全警告
ignored security alerts (/etc/logcheck/violations.ignore.d/);忽略的安全警告
finally, those applying to the remaining messages (considered as system events).其他事件被当做系统事件
=========================================================================================
# 使用示例
iptables 防止DDoS:
#防止SYN攻击 轻量级预防
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -I syn-flood -p tcp -m limit --limit 3/s --limit-burst 6 -j RETURN
iptables -A syn-flood -j REJECT

#防止DOS太多连接进来,可以允许外网网卡每个IP最多15个初始连接,超过的丢弃
iptables -A INPUT -i eth0 -p tcp --syn -m connlimit --connlimit-above 15 -j DROP
iptables -A INPUT -p tcp -m state --state ESTABLISHED,RELATED -j ACCEPT

#用Iptables抵御DDOS (参数与上相同)
iptables -A INPUT -p tcp --syn -m limit --limit 12/s --limit-burst 24 -j ACCEPT
iptables -A FORWARD -p tcp --syn -m limit --limit 1/s -j ACCEPT

iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --update --seconds 60 --hitcount 30 -j REJECT iptables -A INPUT -p tcp --dport 80 -m recent --name BAD_HTTP_ACCESS --set -j ACCEPT
#单个IP在60秒内只允许最多新建30个连接

iptables INPUT/OUTPUT:
1、限制本地主机的web服务器在周一不允许访问,且新增请求的速率不允许超过100个每秒,web字符包含admin字符的页面不允许访问,
web服务仅允许响应报文离开本机
iptables -I INPUT 1 -m state --state ESTABLISHED,RELATED, -j ACCEPT
iptables -A INPUT -d 172.16.100.1 -p tcp --dport 80 -m time --weekdays Tue,Wed,Thu,Fri,Sat,Sun -m --limit 100/sec -m string --algo kmp ! --string "admin" -m state --state NEW -j ACCEPT
iptables -I OUTPUT 1 -m state --state ESTABLISHED,RELATED, -j ACCEPT

2、在工作时间,即周一到周五的8:30-17:30,开放本机的ftp服务给172.16.0.0的网络中主机访问数据下载请求次数每秒钟不超过5个
iptables -I INPUT 1 -m state --state ESTABLISHED, -j ACCEPT
iptables -A INPUT -s 172.16.0.0/16 -d 172.16.100.1 -p tcp --dport 21 -m time --weekdays Mon,Tue,Wed,Thu,Fri --timestart 08:30:00 --timestop 17:30:00 -j ACCEPT
iptables -A INPUT -s 172.16.0.0/16 -d 172.16.100.1 -p tcp -m state --state RELATED -m limit 5/min -j ACCEPT
iptables -I OUTPUT 1 -m state --state ESTABLISHED -j ACCEPT

3、开放本机的ssh服务给172.16.x.1-172.16.x.100网络中的主机,新请求速率每分钟不得超过2个,仅允许响应报文通过其服务端口离开本机
iptables -A INPUT -m iprange --src-range 172.16.100.1-172.16.100.100 -m limit --limit 2/min -p tcp --dport 22 -d 172.16.100.1 -i eth0 -m state --state NEW -j ACCEPT

4、拒绝tcp状态标志位为1及全部为0的报文访问本机
iptables -N clean_in
iptables -A clean_in -p tcp --tcp-flags ALL ALL -j DROP
iptables -A clean_in -p tcp --tcp-flags ALL NONE -j DROP
iptables -A clean_in -f 172.16.100.1 -j RETURN
iptables -I INPUT 1 -D 172.16.100.1 -j clean_in

5、允许本地请求本地
iptables -A INPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -s 127.0.0.1 -d 127.0.0.1 -j ACCEPT iptables -A OUTPUT -o lo -j ACCEPT

6、允许本地主机ping别的主机,别的主机不允许ping本地主机
iptables -A INPUT -m state --state ESTABLISHED, -j ACCEPT
iptables -A OUTPUT -s 172.16.100.1 -p icmp --icmp-type 8 -j ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
=========================================================================================
关于NAT表:
prerouting :用于目标地址转换(DNAT)
input :处理输入数据包,如果数据包的目的地址是本机,则系统将数据包送往Input链。如果通过规则检查,则该包被发给相应的本地进程处理;如果没有通过规则检查,系
统就会将这个包丢掉。
forward :处理转发数据包,如果数据包的目的地址不是本机,也就是说,这个包将被转发,则系统将数据包送往Forward链。如果通过规则检查,则该包被发给相应的本地进程
处理; 如果没有通过规则检查,系统就会将这个包丢掉。
output :处理输出数据包,如果数据包是由本地系统进程产生的,则系统将其送往Output链。如果通过规则检查,则该包被发给相应的本地进程处理;如果没有通过规则检查,
系统就会将这包丢掉。
postrouting:用于源地址转换(SNAT)

按照类型分,NAT分为静态NAT(staticNAT)、NAT池(pooledNAT)和端口NAT(PAT)。
RFC 1918 为私有网络预留出了三个IP 地址块,如下:
A 类: 10.0.0.0~10.255.255.255
B 类: 172.16.0.0~172.31.255.255
C 类: 192.168.0.0~192.168.255.255
NAPT:网络地址端口转换NAPT(Network Address Port Translation)
NAT :NAT(Network Address Translation,网络地址转换)
# 上面二者不同,但是NAPT可说是NAT的一种流行的变体。NAPT也被称为“一对多”的NAT,或者叫PAT(Port Address Translations,端口地址转换)、地址超载(address overloading)。

如果在地址转换的时候,加上端口号来区分是哪个私有IP,就可以解决上面的多台内部计算机和外界通信的问题了。这就是NAPT。
NAT :一个全局IP对应一个私有IP(即一台计算机)
NAPT:一个全局IP+不同的端口号对应多个私有IP(即多台计算机)

NAT

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
NAPT:
SNAT:内网访问外网
本地IP 路由器(公网IP) 目的地址
10.1.1.1 <=========> 201.0.0.1 <=========> +--201.0.0.11
10.1.1.2 <=========> 201.0.0.2 <=========> |

DNAT:外网访问内网
公网IP 路由器(公网IP) 目的地址
201.0.0.11 <=========> 201.0.0.1:6666 <=========> 10.1.1.1:22

iptables添加SNAT:iptables -t nat(nat表) -A POSTROUTING(链) -s LocalNET!(希望通过SNAT出去,连接互联网的IP地址范围。) ! -d LocalNet(目标IP地址,写不写都行。“!”号是取反的意思。) -j SNAT(指的是NAT的SNAT) --to source-ExtIP(公有地址:企业外网的IP地址。IP地址必须固定)
设置公司内网10.0.1.0/24网段的电脑,且目标地址不是10.0.1.0/24网段,即可通过公司外网101.200.168.1-168.200.168.9中的IP地址访问互联网:
iptables -t nat -A POSTROUTING -s 10.0.1.0/24! –d 10.0.1.1/24 -j SNAT --to-source 101.200.168.1-168.200.168.9(必须是外网固定IP地址)
来自10.0.1.0/24! --> 目的地10.0.1.1/24

MASQUERADE:动态IP 是SNAT的特例
iptables -t nat -A POSTROUTING -s LocalNET ! -d LocalNet -j MASQUERADE(伪装。即伪装成,“当时动态IP地址” 或 “当时拨号上网的IP地址”;或者可以用专线)
设置公司内网10.0.1.0网段的电脑,可以同过公司外网,访问互联网:
iptables -t nat -A POSTROUTING -s 10.0.1.0/24! –d 10.0.1.0/24 -j MASQUERADE
来自10.0.1.0/24 --> 目的地10.0.1.0/24

e.g.:iptables -t nat -A POSTROUTING -s 10.8.0.0/255.255.255.0 -o eth0 -j MASQUERADE
不管现在eth0的出口获得了怎样的动态ip,MASQUERADE会自动读取eth0现在的ip地址然后做SNAT出去

设置NAT服务器:
iptables -t nat -A POSTROUTING -s 192.168.238.0/24 ! -d 192.168.238.0/24 -j SNAT --to-source 172.22.142.211
查看:
[root@centos7nat ~]# iptables -vnL -t nat
Chain PREROUTING (policy ACCEPT 20 packets, 3295 bytes)
pkts bytes target prot opt in out source destination
0 0 SNAT all -- * * 192.168.238.0/24 !192.168.238.0/24 to:172.22.142.211

SNAT是指在数据包从网卡发送出去的时候,把数据包中的源地址部分替换为指定的IP,这样,接收方就认为数据包的来源是被替换的那个IP的主机;

MASQUERADE是用发送数据的网卡上的IP来替换源IP,因此,对于那些IP不固定的场合,比如拨号网络或者通过dhcp分配IP的情况下,就得用MASQUERADE;

DNAT,就是指数据包从网卡发送出去的时候,修改数据包中的目的IP,表现为如果你想访问A,可是因为网关做了DNAT,把所有访问A的数据包的目的IP全部修改为B,那么,你实际上访问的是B;因为,路由是按照目的地址来选择的,因此,DNAT是在PREROUTING链上来进行的,而SNAT是在数据包发送出去的时候才进行,因此是在POSTROUTING链上进行的。

iptables NAT:
SNAT:代理内部客户端访问外部网络。在iptables上的POSTROUTING
-j SNAT --to-source IP
-j MASGUEGRADE
服务器地址为192.168.10.10(模拟内网地址)
nat服务器,两块网卡,一个网卡地址为192.168.10.11(模拟内网地址),一个网卡地址为172.16.100.1 (模拟外网地址)
web服务器的地址为172.16.100.17(模拟外网地址)
一、如何通过192.168.10.10(模拟内网地址)服务器访问172.16.100.17(模拟外网地址)
方法一
1、开启ip_forward为1
2、iptables -P FORWARD ACCEPT
3、iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -j SNAT --to-source 172.16.100.1
方法二
分别在192.168.10.10上、172.16.100.17写路由
二、仅允许192.168.10.10服务器访问172.16.100.17的web服务
iptables -P FORWARD DROP
iptables -A FORWARD -s 192.168.10.0/24 -p tcp --dport 80 -j ACCEPT
iptables -A FORWARD -d 192.168.10.0/24 -p tcp --sport 80 -j ACCEPT

DNAT:将内部服务器发布至外部网络(外部访问内部服务应用,此场景下ftp比较麻烦) 在iptable上的PREROUTING
-j DNAT --to-destination IP
外部通过访问192.168.10.254(模拟外网地址)的80取代 直接访问172.16.100.17(模拟内网地址)的80
即在192.168.10.25480172.16.100.1780做映射关系
iptables -P FORWARD ACCEPT
iptables -t nat -A PREROUTING -d 192.168.10.254 -p tcp --dport 80 -j DNAT --to-destination 172.16.100.17

iptables -P FORWARD DROP
iptables -t nat -A PREROUTING -d 192.168.10.254 -p tcp --dport 80 -j DNAT --to-destination 172.16.100.17
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -d 172.16.100.17 -p tcp --dport 80 -m state --state NEW -j ACCEPT

系统配置

同步NTP服务器时间

1
2
3
4
5
6
7
8
显示当前时间
date
同步NTP
ntpdate time.windows.com
显示硬件时间:
hwclock --show
同步到硬件时间:
hwclock --systohc

xserver允许显示多个用户的界面

比如root用户的窗口和普通用户窗口显示同一桌面

xhost +

反之:

xhost -

尝试提升音质

1
2
3
4
5
6
7
sudo apt install jackd
sudo apt install pulseaudio-module-jack
sudo apt install caps
均衡器(弃用):
sudo apt-get install pulseaudio-equalizer
其他:
apt install pulseeffects

修改环境变量

1
2
3
4
5
修改$PATH 环境变量:
export PATH="$PATH:/usr/local/bin/python"
更好的建议:
直接修改~/.bashrc里面的Path
重启才有用,或者source ~/.bashrc

常见问题 FAQ & HOWS

HOWS

Linux下如何效验下载的文件?

使用sha256sumWindows版本

sha256sum --check systemrescue-x.y.z.iso.sha256

sha512sum --check systemrescue-x.y.z.iso.sha512

使用gpg

gpg --import gnupg-pubkey.txt

gpg --verify systemrescue-x.y.z.iso.asc systemrescue-x.y.z.iso

Linux如何给大文件分块(大文件分块后在Windows平台组合)?

From:

https://blueheart0621.github.io/2020/11/16/Linux/Shell/LinuxShell%E4%B8%8B%E5%88%86%E5%8D%B7%E5%8E%8B%E7%BC%A9%E4%B8%8E%E8%A7%A3%E5%8E%8B/

http://williamsun.cn/2019/08/20/Linux%E5%88%86%E5%8D%B7%E5%8E%8B%E7%BC%A9%E5%91%BD%E4%BB%A4/

https://ourss.cn/1847

  1. 传统的压缩命令:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ## rar/7z:
    压缩:
    rar/7z a -v<size>[b,k,m,g,...] <压缩卷名> <被压缩文件/文件夹名>
    其中,参数 a 表示添加卷,<size> 指定每卷压缩包最大不超过的大小;<size> 后可以跟数值单位 b,k,m,g,...,依次为字节、千字节、兆字节、吉字节……(不指定数值单位时默认为字节)。
    解压:
    rar/7z x <压缩卷名>

    ## zip
    压缩:
    zip -s<size>[b,k,m,g,...] -r <压缩卷名> <被压缩文件/文件夹名>
    其中,参数 -r 表示递归处理文件夹下的文件(如果只是压缩单个文件可以省略)。
    解压:
    zip 分卷压缩后会形成若干个 .zxx 文件和一个 .zip 文件,解压时需要根据该 .zip 文件来合并其他所有分卷为单个分卷,然后在利用 unzip 解压即可恢复原文件:
    zip -s0 <压缩卷名>.zip --out <合并压缩卷名>
    unzip <合并压缩卷名>

    ## tar
    压缩:
    tar cvzf - filedir | split -d -b 50m - filename
    解压:
    cat x* > myzip.tar.gz && tar xzvf myzip.tar.gz
  2. 非传统压缩命令:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    ## 使用split & cat
    大文件分块:
    split -b<size>[b,k,m,g,...] <压缩卷名>
    e.g.:
    split -d -b 1M ./xxx.zip
    合并分块:
    cat x* > <压缩卷名>

    ## 在Windows平台合并分块:
    copy /B file.zip.zip.001 + file.zip.zip.002 + file.zip.zip.003 file.zip

生成RSA密钥

1
2
3
4
5
6
7
8
# 生成私钥
openssl genrsa -out rsa_private_key.pem 4096
# 公钥
openssl rsa -in ryan_4096.pem -pubout -out ryan_4096_pub.pem
# 生成和pyrsa兼容的公钥
pyrsa-priv2pub -i ryan_4096.pem -o ryan_4096_pyrsa_pub.pem
# 生成pkcs8格式密钥
openssl pkcs8 -topk8 -inform PEM -in rsa_private_key.pem -outform PEM -nocrypt > rsa_private_key_pkcs8.pem

Linux远程桌面

第三方软件有Anydesk、Teamviwer;其中个人开发有Dayon、Rust Desktop等。

传统协议有VNC和RDP。前者似乎传输不加密,后者对带宽要求好像比较高。

平时跨平台远程桌面,我个人使用的Anydesk,teamviewer整天升级很烦人。但Anydesk不是很稳定,会掉线。Dayon需要自己搭建内网穿透,Rust似乎鼠标键盘这边不是很好用。

接下来聊一聊VNC,平时局域网我倒是用得VNC。GNOME桌面下直接在设置里开启屏幕共享,原先GNOME是用得vino,现在用的是gnome-remote-desktop,使用APT安装一下就有了。另外VNC服务还有TightVNC(Windows支持好)、TigerVNC(Linux支持好)、Krfb(KDE社区开发的)。

我正在运行混合系统。我如何找出哪个包来自哪个发行版?

如果您走了这么远,您肯定喜欢玩火,但无法回答 这个简单的问题。OK,光顾了:),尝试apt-show-versions

You definitely like to play with fire if you got this far, but can’t answer this simple question. OK, enough patronizing :) , try apt-show-versions.

Linux误删除资料(RM -RF ?),数据恢复

参考:https://www.bbsmax.com/A/l1dyaPOnde/

https://www.bbsmax.com/A/6pdDvZ0RJw/

https://blog.csdn.net/EbowTang/article/details/123348652

如果磁盘是EXT4,请使用extundelete,如果是NTFS磁盘,请使用ntfsundelete。这里演示的是ntfsundelete

安装:sudo apt-get install ntfs-3g

查找被删除的文件:(获取所有要恢复的文件的inode值,然后使用vi编辑使inode组成”881,2341,234,…”文本。
3m表示3个月以内生成并删除的,而不3个月内删除的意思)

sudo ntfsundelete 【这里是磁盘名/dev/sda3】 -f -t 3m

导出inode:sudo ntfsundelete 【这里是磁盘名/dev/sda3】 -f -t 3m | grep 【关键词,grep可以忽略】 | awk '{print $1}' > ntfsundelete.txt

恢复文件:sudo ntfsundelete 【这里是磁盘名/dev/sda3】 -d 【恢复到/home/wilson/tmp/】 -u -i 【inode数值,881,2341,234,....】

Windows的免驱无线网卡插Linux系统显示U盘怎么办?

https://github.com/brektrou/rtl8821CU

https://blog.csdn.net/qq_20677327/article/details/107950948

原因:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
 USB_ModeSwitch是一种模式切换工具,用于控制具有“多种模式”的USB设备。

越来越多的USB设备(特别是高速WAN上网卡,它基于一些手机芯片,能够改变它们的USB连接模式)都会板载它们自己的MS Windows驱动程序,当首次插入电脑时,它们会被识别为一个闪存设备,然后开始安装存储于其中的驱动程序。在安装完驱动程序之后(后面还需要再插拔一次),驱动程序就会再内部切换USB设备的连接模式,存储设备会消失(大多数情况下),然后会出现一个新的设备(例如,一个USB调制解调器)。调制解调器制造商会“可选地”调用“ZeroCD (TM)”特性,因为它会消除对用于承载一个独立驱动程序载体的需求。

起初,这方面的东西没有任何形式的文档记录,而且也几乎没有任何Linux支持可用。
从好的方面来看,大多数已知的设备在两种模式下都可以工作,使用诸如“usb-storage”或“option”(一种经过优化的串行驱动程序,高速3G调制解调器的Linux标准)的Linux驱动程序。
那么唯一的问题便是如何从存储设备切换至调制解调器设备,或者其他应该做的事情。

幸运的是,我们还有人类的理性、USB嗅探程序和“libusb”。MS Windows的驱动程序存在通信被窃听的可能性,但是,在Linux或BSD变种系统的规则之下,可以隔离触发模式切换的命令或动作,并且可以复制相同的东西。

在“libusb”的有力帮助之下,USB_ModeSwitch可以从一个配置文件中获取重要的参数,然后完成全部的初始化和通信工作,这样便使得用户可以轻松地处理这个过程。
它主要是自动使用的 — 通过udev事件和规则 — 不需要任何用户操作便能完成模式切换。但是它还可以作为一个命令行工具来运行,通常会在尝试使用某种未知设备时使用这种方式。

这个工具是大多数主流发型版的部件之一,你应当不用从源码包进行编译安装,除非运行时遇到问题,或者想要使用最新的版本。

解决办法

如果可以检测到网卡,恭喜。 如果没有,也许您需要通过终端中的以下步骤切换设备的 USB 模式:

通过类型找到你的 usb-wifi-adapter 设备 ID,比如“0bda:1a2b”:

1
lsusb

需要安装 usb_modeswitch(Arch Linux: sudo pacman -S usb_modeswitch)

1
2
sudo usb_modeswitch -KW -v 0bda -p 1a2b
systemctl start bluetooth.service - starting Bluetooth service if it's in inactive state

上面应该就能解决,但每次重启都要这样吗?不,可以持久化

  1. 编辑 usb_modeswitch 规则:

    1
    sudo nano /lib/udev/rules.d/40-usb_modeswitch.rules
  2. LABEL="modeswitch_rules_end"之前加上:(【】内的参数请自行修改)

    1
    2
    # Realtek 8211CU Wifi AC USB
    ATTR{idVendor}==【"0bda"】, ATTR{idProduct}==【"1a2b"】, RUN+="/usr/sbin/usb_modeswitch -K -v 【0bda】 -p 【1a2b】"

Make sure to set your ATTR{idVendor} and the -v argument to the left portion of the output of lsusb device ID, and your ATTR{idProduct} and -p argument to the right portion of the lsusb device ID. For example (for the Cudy AC600 usb wifi adapter) the output from lsusb command looks like this:

1
Bus 001 Device 016: ID 0bda:c811 Realtek Semiconductor Corp. 802.11ac NIC

then your configuration in /lib/udev/rules.d/40-usb_modeswitch.rules should be

1
2
# Realtek 8211CU Wifi AC USB
ATTR{idVendor}=="0bda", ATTR{idProduct}=="c811", RUN+="/usr/sbin/usb_modeswitch -K -v 0bda -p c811"

Debian开机很慢,卡在raising up network这一步

通常来说,这个情况是这样的:有有线网路时启动很快。没有有线网络时就会卡个三五分钟。有三种解决四思路(方法一亲测有效,其他对我来说没用):

  1. 编辑/etc/network/interfaces.d/setup (注意不是 /etc/network/interfaces !!)文件中的auto eth0,设置为允许热拔插即可allow-hotplug eth0。注意,eth0请根据实际情况修改。

  2. 编辑/etc/dhcp/dhclient.conf,设置timeout值。

  3. 新建/etc/systemd/system/networking.service.d/override.conf文件,覆盖原服务配置:

    1
    2
    [Service]
    TimeoutStartSec=30sec

Android Studio: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations$ReflectSdkVersion found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.internal.jdk8.JDK8PlatformImplementations$ReflectSdkVersion found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.io.path.ExperimentalPathApi found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.io.path.PathRelativizer found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.io.path.PathsKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.io.path.PathsKt__PathReadWriteKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.io.path.PathsKt__PathUtilsKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.jdk7.AutoCloseableKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
Duplicate class kotlin.jvm.jdk8.JvmRepeatableKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.random.jdk8.PlatformThreadLocalRandom found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.streams.jdk8.StreamsKt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$1 found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$2 found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$3 found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.streams.jdk8.StreamsKt$asSequence$$inlined$Sequence$4 found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules kotlin-stdlib-1.8.10 (org.jetbrains.kotlin:kotlin-stdlib:1.8.10) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

解决:https://youtrack.jetbrains.com/issue/KT-54136/Duplicated-classes-cause-build-failure-if-a-dependency-to-kotlin-stdlib-specified-in-an-android-project

添加:

1
2
3
4
5
6
7
8
9
10
dependencies {
modules {
module("org.jetbrains.kotlin:kotlin-stdlib-jdk7") {
replacedBy("org.jetbrains.kotlin:kotlin-stdlib", "kotlin-stdlib-jdk7 is now part of kotlin-stdlib")
}
module("org.jetbrains.kotlin:kotlin-stdlib-jdk8") {
replacedBy("org.jetbrains.kotlin:kotlin-stdlib", "kotlin-stdlib-jdk8 is now part of kotlin-stdlib")
}
}
}

或者(我添加了上面的解决):

1
2
3
4
5
6
7
8
9
10
dependencies {
constraints {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
}
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
}
}
}

Linux设置开机启动的方法

一、构建systemd服务

同时可参考:这一节

/lib/systemd/system/文件夹中放入自定义的*.service文件

1
2
3
4
5
6
7
8
9
[Unit]
Description="描述"
After=network.target
[Service]
ExecStart=/home/$USER/.$USER/services/autorun.sh
Type=forking
User=xxx
[Install]
WantedBy=multi-user.target

sudo systemctl daemon-reload后enable一下即可。

二、rc.dprofile.d

rc.local是Linux系统中一个特殊的脚本文件,它会在系统启动时自动执行。如果我们希望某个应用程序或服务在系统启动时自动运行,可以将其添加到rc.local脚本文件中。

编辑/etc/rc.local或者/etc/rc.d/rc.local,在文件最后一行添加要执行程序的全路径。

注意:

  • 你的命令应该添加在:exit 0 之前
  • 要输入绝对路径
  • 需要给rc.local加执行权限

也可以通过/etc/profile.d/

创建 /etc/profile.d/ 目录(如果该目录不存在):(如果已经存在这个目录文件就不要创建了直接跳过这一步)

sudo mkdir -p /etc/profile.d/

创建一个新的脚本文件,添加您要启动的进程命令,授予脚本文件可执行权限。每次用户登录时, /etc/profile.d/【你的脚本】.sh 脚本中添加的命令都会自动运行,您的进程也应该会自动启动。

其他:

1
2
3
4
5
6
7
8
https://zhuanlan.zhihu.com/p/648558571?utm_id=0
/etc/inittab 是一个配置文件,程序 /sbin/init 根据该文件的内容对系统进行操作,比如设置系统的运行级别(runlevel),运行各级别下所需启动的程序等等。
/sbin/init 会首先执行 /etc/init.d/rcS,然后执行 /etc/init.d/rc5

/etc/rcX.d/ 目录下的文件名可以分为 3 部分——S序号 文件名称。S:start,表示需要开机运行的程序,与之对应的是 K——kill,表示开机需要停止的程序;
序号:一个两位的数字,范围为 01~99,表示启动的顺序,数值小的优先启动;
文件名称:英文名称(我没见过中文的),也表示启动顺序,按照 a~z 的顺序启动。如果两个文件有相同的序号,那么就按照文件名称中字母的顺序进行启动;
比如,在 /etc/rc5.d/ 目录下有两个文件,分别为 S99atest 和 S99btest。那么,系统启动时会优先执行 S99atest。
三、/etc/init.d

Linux在/etc/rc.d/init.d下有很多的文件,每个文件都是可以看到内容的,其实都是一些shell脚本或者可执行二进制文件。Linux开机的时候,会加载运行/etc/init.d目录下的程序,因此我们可以把想要自动运行的脚本放到这个目录下即可。系统服务的启动就是通过这种方式实现的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/sh
#
# my-service: Start/stop My Service.
#
case "$1" in
start)
/usr/bin/my-service &
;;
stop)
killall my-service
;;
*)
echo "Usage:$0{start|stop}"
exit 1
esac
exit 0
四、使用autostart文件夹

Linux桌面环境中,我们可以使用autostart文件夹来管理自启动应用程序。autostart文件夹位于~/.config/autostart目录下,我们只需要将应用程序的.desktop文件复制到该目录下即可实现开机自启动。

1
2
3
4
[Desktop Entry]
Type=Application
Name=My Application
Exec=/usr/bin/my-application

常见的文件夹有:

  • /etc/xdg/autostart
  • ~/.config/autostart
五、其他
  • 使用chkconfig管理服务
  • crontab
  • upstart

修改EXT硬盘分区的UUID

tune2fs /dev/sdb1 -U [uuid]

生成新的UUID并修改:

uuidgen | xargs tune2fs /dev/sdb1 -U

Ffpmeg concat合并视频时:[mp4 @ 00000249e9f01480] Non-monotonous DTS in output stream 0:1; previous: 36963852, current: 36597661; changing to 36963853. This may result in incorrect timestamps in the output file.

[mp4 @ 0x561705221940] Non-monotonous DTS in output stream 0:0; previous: 360023995, current: 308168863; changing to 360023996. This may result in incorrect timestamps in the output file.

如果各个视频文件中的音频采样率不一致导致,于是将这些视频文件的音频按指定采样率重新采样

ffmpeg.exe -i a.mp4 -ac 1 -ar 44100 -vcodec copy a_re.mp4

如果仍不能解决,请尝试:

https://video.stackexchange.com/questions/15468/non-monotonous-dts-on-concat-ffmpeg

https://trac.ffmpeg.org/wiki/Concatenate

  1. 全部转换为MTS:

    1
    2
    ffmpeg -i clip-1.MOV -q 0 clip-1.MTS
    ffmpeg -i clip-2.MOV -q 0 clip-2.MTS
  2. 修改合并文件列表

    1
    2
    file clip-1.MTS
    file clip-2.MTS
  3. 合并:ffmpeg -f concat -i mylist.txt -c copy output.MTS

GRUB——启动引导问题

使用 GRUB 命令行——grub>grub rescue>

MBR 太小,不足以存储所有的 GRUB 模组,所以 MBR 里面只有启动目录和一些很基本的命令。GRUB 的主要功能通过 /boot/grub 里的模组实现,按需加载。出现错误时,GRUB 可能不能引导启动(比如磁盘分区发生了变化)。这时候,一般会出现命令行界面。

GRUB 不止提供一个 shell,如果 GRUB 不能读取到启动目录配置,但是能找到磁盘,你很可能会进入 “正常” shell:

1
grub>

如果有更严重的问题(比如 GRUB 找不到必须的文件了),GRUB 就可能会让你进入 “救急” shell:

1
grub rescue>
GRUB > SHELL
使用命令行引导操作系统
1
grub>

可以使用 GRUB 命令行引导操作系统,一个典型的应用场景是通过“chainloading”来引导储存在一个驱动器或者分区中的 Windows 或 Linux 系统。

ChainLoading 的意思是用当前的启动加载器去载入另一个启动加载器,所以叫做链式加载。

要被加载的另一个启动加载器可能嵌入在一个有分区表的磁盘的头部 (MBR),或在一个未分区磁盘或者一个分区的头部 (VBR),也可能在使用 UEFI 的情形下是一个 EFI 可执行文件。

  1. 链式加载一个分区的 VBR

    1
    2
    3
    set root=(hdX,Y)
    chainloader +1
    boot

    X=0,1,2… Y=1,2,3…

    比如链式加载一个位于首磁盘,首分区上的 Windows:

    1
    2
    3
    set root=(hd0,1)
    chainloader +1
    boot

    同样也可以使用 GRUB 链式加载另一个分区引导扇区上的 GRUB。

  2. 链式加载磁盘的 MBR 或未分区磁盘的 VBR

    1
    2
    3
    set root=hdX
    chainloader +1
    boot
  3. 链式加载 UEFI 模式下安装的 Windows/Linux

    1
    2
    3
    4
    insmod fat
    set root=(hd0,gpt4)
    chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
    boot

    insmod fat 用来加载 FAT 文件系统模块,以访问 EFI 系统分区上的 Windows 启动加载器。 (hd0,gpt4)/dev/sda4 是该示例中的 EFI 系统分区。 chainloader 一行中的条目用来指定需要被链式加载的 .efi 文件。

分页支持

GRUB 支持对长输出进行分页(比如运行 help 的输出)。不过只能在正常 shell 中支持,在救急 shell 中则不支持。开启分页支持需要在 GRUB 命令行中键入:

1
sh:grub> set pager=1
GRUB RESCUE > SHELL
GRUB 救急与加密启动

在使用加密启动,而你没法键入正确的密码的时候,就会进入 GRUB 救急命令行。

这个救急命令行只有有限的功能,可以使用下面的命令来完成启动:

1
2
3
grub rescue> cryptomount <分区>
grub rescue> insmod normal
grub rescue> normal
开机进入GRUB

如果 GRUB 直接就启动到了救急控制台下,而且没报错,这可能是因为如下两种原因:

  • 可能是因为 grub.cfg 丢失或者位置不对。如果 GRUB UEFI 安装时设定了 --boot-directory 参数,而 grub.cfg 文件却不在那里,就会发生这样的问题。
  • 如果启动分区的分区号发生了变化(这个分区号会被直接编码到 grubx64.efi 文件中),也会出现这个问题。

救急模式下的 shell 是正常 shell 的一个严格的子集,其支持的功能更少。如果不幸进入了救急模式的 shell 里,首先尝试加载 normal 模块,然后启动正常 shell:

1
2
3
4
5
6
7
8
9
10
11
12
13
grub rescue> set prefix=(hdX,Y)/boot/grub
grub rescue> insmod (hdX,Y)/boot/grub/i386-pc/normal.mod
rescue:grub> normal

举例子:
# grub rescue>
ls
# 不停ls磁盘,直到读取到需要的grub,然后启动。
ls (hd0,gpt1)/boot/grub
set root=(hd0,gpt1)/boot/grub
set prefix=(hd0,gpt1)/boot/grub
insmod normal
normal

GRUB 应急控制台里可用的命令有 insmodlssetunset。这个例子里用了 setinsmodset 用来修改变量,insmod 用来载入模组以添加功能。

首先,用户必须知道启动分区 (/boot) 所在位置(是一个独立的分区或者是根目录下的子目录),然后设置:

1
grub rescue> set prefix=(hdX,Y)/boot/grub

其中 X 是物理驱动器的编号,而 Y 是分区的编号。

注意: 如果启动分区是个独立的分区,要在路径中省略 /boot(例如键入 set prefix=(hdX,Y)/grub)。

通过加载 linux 模组来扩展命令行的功能:

1
grub rescue> insmod i386-pc/linux.mod

或者直接

1
grub rescue> insmod linux

这个模组会启动对我们熟悉的 linuxinitrd 命令的支持。

比如要启动 Arch Linux:

1
2
3
4
set root=(hd0,5)
linux /boot/vmlinuz-linux root=/dev/sda5
initrd /boot/initramfs-linux.img
boot

如果 /boot 在单独分区上(例如在用 UEFI 的时候),适当地进行修改:

注意: 因为 boot 是一个单独的分区而不是根分区的一部分,你得手动把它的地址写清楚,格式和前面的 prefix 一样。

1
2
3
4
set root=(hd0,5)
linux (hdX,Y)/vmlinuz-linux root=/dev/sda6
initrd (hdX,Y)/initramfs-linux.img
boot

注意: 如果你在执行 linux 命令的时候遇到了 error: premature end of file /YOUR_KERNEL_NAME,你可以尝试用 linux16 来替代。

成功启动 Arch Linux 后,用户可以修正 grub.cfg 然后重新安装 GRUB。

为了完全修正错误和重新安装 GRUB,可能需要修改 /dev/sda。详情请参考#安装#安装)章节。

安装GRUB后再安装Windows8——\boot\bcd 报错(错误代码为 0xc000000f

在某些情况下,可能在安装 Windows 8 之前就已经安装了GRUB。启动 Windows 时可能会出现\boot\bcd 报错(错误代码为 0xc000000f)。要修复这个问题,可以进入 Wondows Recovery Console(安装磁盘中的 cmd.exe)然后运行:

1
2
X:\> bootrec.exe /fixboot
X:\> bootrec.exe /RebuildBcd

不要 使用 bootrec.exe /Fixmbr,因为那会将 GRUB 清除掉。或者你可以用 Troubleshooting 菜单里的 Boot Repair 函数,它不会清除 GRUB 而且可以修复大部分错误。而且最好是保证连接电脑的介质 只有 目标硬盘和你的可启动介质,如果你连接了其他的设备,Windows 很可能会没法修复启动信息。

Device /dev/xxx not initialized in udev database even after waiting 10000000 microseconds

如果 grub-mkconfig 卡住然后显示如下错误信息:

1
WARNING: Device /dev/*xxx* not initialized in udev database even after waiting 10000000 microseconds

你需要使用下列命令为 chroot 环境提供 /run/lvm/ 访问支持:

1
2
3
4
# mkdir /mnt/hostlvm
# mount --bind /run/lvm /mnt/hostlvm
# arch-chroot /mnt
# ln -s /hostlvm /run/lvm

软件包、依赖、桌面环境问题

Debian 12 bookworm: raspi-firmware: missing /boot/firmware, did you forget to mount it?

1
2
3
4
5
6
7
8
9
10
11
12
13
dpkg: error processing package linux-image-amd64 (--configure):
dependency problems - leaving unconfigured
Processing triggers for initramfs-tools (0.142) ...
update-initramfs: Generating /boot/initrd.img-6.1.0-9-amd64
raspi-firmware: missing /boot/firmware, did you forget to mount it?
run-parts: /etc/initramfs/post-update.d//z50-raspi-firmware exited with return code 1
dpkg: error processing package initramfs-tools (--configure):
installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-6.1.0-9-amd64
linux-image-amd64
initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决:https://forums.debian.net/viewtopic.php?t=154857

更新linux-image-6.1.10-amd64的时候,apt报错,这个是raspi-firmware的bug。卸载即可:sudo rm /etc/kernel/postinst.d/z50-raspi-firmwaresudo rm /etc/kernel/postrm.d/z50-raspi-firmware

VirtualBox、WPS Office等QT应用显示不正常(qt5ct提示:QT_QPA_PLATFORMTHEME变量未设置)

参考:

https://forums.virtualbox.org/viewtopic.php?f=7&t=97886

https://forum.manjaro.org/t/text-in-apps-renders-as-white-on-white/48500

https://wiki.archlinux.org/title/Uniform_look_for_Qt_and_GTK_applications_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)

解决:安装qt5ct。或者VirtualBox可以:VirtualBox -style Fusion

/etc/environment文件中写入QT_QPA_PLATFORMTHEME=qt5ct

新装的Debian 11 Inte i5-10400(UHD630)开机黑屏

  1. Debian Sid可以正常进入图形界面,但Debian Stable版本在GRUB引导界面后即黑屏(显示器:无信号)、鼠标键盘灭灯、tty终端无法切换。
  2. 网上查询,i5-10400自带UHD630集成显卡,使用i915驱动。
  3. Debian 11 在GRUB界面按“e”进入编辑界面,在linux一行最后添加nomodeset即可进入图形界面(根据网上,尝试过i915.modeset=0i915.alpha_support=1均无效)。
  4. 经检查,存在i915驱动,且已加载。考虑到可能是内核版本太低,Debian 11 是5.10.0-16-amd64,而Sid是5.18,所以开始着手更新内核。
  5. backports 拉取5.14内核后解决UHD630开机黑屏问题(sudo apt install -t bullseye-backports linux-image-5.14.0-0.bpo.2-amd64)。

解决”apt -f install“失效,dpkg错误的方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
apt -f install出现类似以下的错误:
-----------------------------------------------------------------------------------------
(Reading database ... 226243 files and directories currently installed.)
Unpacking libjline-java (from .../libjline-java_1.0-1_all.deb) ...
dpkg: error processing /var/cache/apt/archives/libjline-java_1.0-1_all.deb (--unpack):
trying to overwrite '/usr/share/java/jline.jar', which is also in package scala 2.9.2-400
Errors were encountered while processing:
/var/cache/apt/archives/libjline-java_1.0-1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
-----------------------------------------------------------------------------------------
# 除了apt update能用,其他均无效。解决:
sudo dpkg -i --force-overwrite path-to-the-deb-file
或者:sudo dpkg -i --force-overwrite-all path-to-the-deb-file
例如:上面的情况应该:
sudo dpkg -i --force-overwrite /var/cache/apt/archives/libjline-java_1.0-1_all.deb
然后用apt和dpkg卸载软件包。

Warning: apt-key is deprecated (SOLVED)

参考来源: https://suay.site/?p=526

使用apt-key add时爆出警告 Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)). 怎么解决呢?

apt-key 程序现在已被弃用。 现在我们应该使用trusted.gpg.d 来管理密钥文件。 翻译成人类语言,现在我们必须自己将文件添加到 /etc/apt/trusted.gpg.d/ 文件 夹中。Debian称,Debian11 是最后支持apt-ket add的发行版了。

命令代替:

wget -qO - https://keys.anydesk.com/repos/DEB-GPG-KEY | apt-key add - -> curl https://keys.anydesk.com/repos/DEB-GPG-KEY | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/anydesk.gpg --import | sudo chmod 644 /etc/apt/trusted.gpg.d/anydesk.gpg

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
添加远程密钥:
# 注意,没设置密钥644权限无法读取
# curl 【URL】 | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/【密钥名】.gpg --import | sudo chmod 644 /etc/apt/trusted.gpg.d/【密钥名】.gpg

添加本地密钥:
# cat 【URL.pub】 | sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/【密钥名】.gpg --import
# sudo chmod 644 /etc/apt/trusted.gpg.d/【密钥名】.gpg

从Key Server添加:
# sudo gpg --no-default-keyring --keyring gnupg-ring:/etc/apt/trusted.gpg.d/【rabbit】.gpg --keyserver 【keyserver.ubuntu.com】 --recv 【6B73A36E6026DFCA】
# sudo chmod 644 /etc/apt/trusted.gpg.d/【rabbit】.gpg

查看已安装密钥信息:
# gpg --list-keys --keyring /etc/apt/trusted.gpg.d/【FILE】.gpg
等效于:
# apt-key list

移除密钥:
# cd /etc/apt/trusted.gpg.d/
# sudo rm 【NAME】.gpg
等效于:
# sudo apt-key del 7D8D08F6
移除apt-key添加的密钥:
# sudo apt-key del KEY_ID
移除所有apt-key添加的密钥:
# sudo rm /etc/apt/trusted.gpg

Debian GNOME显示网卡未托管

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Linux里面有两套管理网络连接的方案:
1. /etc/network/interfaces(/etc/init.d/networking)
2. Network-Manager

# 两套方案是冲突的,不能同时共存。
1. 第一个方案适用于没有X的环境,如:服务器;或者那些完全不需要改动连接的场合。
2. 第二套方案使用于有桌面的环境,特别是笔记本,搬来搬去,网络连接情况随时会变的。

# 他们两个为了避免冲突,又能共享配置,就有了下面的解决方案:
1. 当Network-Manager发现/etc/network/interfaces被改动的时候,则关闭自己(显示为未托管),除非managed设置成真。
2. 当managed设置成真时,/etc/network/interfaces,则不生效。

# 在终端下执行
sudo vi /etc/NetworkManager/NetworkManager.conf
# 把里面的false改为true,然后重启问题即可解决。

GNOME共享设置中没有屏幕共享

VINO已经弃用。使用APT安装gnome-remote-desktop即可。

GNOME设置打不开——gnome-control-center:3592

GNOME更新后打不开设置(gnome-control-center)

1
2
报错:(gnome-control-center:3592): GLib-GIO-ERROR **: 14:22:30.138: Settings schema 'org.gnome.settings-daemon.plugins.power' does not contain a key named 'power-saver-profile-on-low-battery'
zsh: trace trap gnome-control-center

安装gnome-settings-daemon即可

解决GNOME Wayland下fcitx不运行的办法

1
2
3
4
5
6
7
8
vi /etc/environment
# 添加:
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx

但是,一般情况下我建议:
使用fcitx请使用GNOME on xorg模式。

GNOME锁屏无效、丢失锁屏按钮

1
2
3
4
检查锁屏属性:
gsettings get org.gnome.desktop.lockdown disable-lock-screen
如果是True,改为False
gsettings set org.gnome.desktop.lockdown disable-lock-screen false

解决bash-completion安装后,终端仍无法自动补齐

1
2
3
4
5
6
# Linux终端命令行补齐:
apt-get install bash-completion
# bashrc中添加:
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi

解决Virtual Box安装扩展包后无法访问USB

vi /etc/group 在vbox哪一行后面加上当前用户,重启。

关于 VBox安装扩展包(不是增强包)

下载地址:https://www.virtualbox.org/wiki/Downloads 下载Oracle VM VirtualBox Extension Pack,vbox-extpack。

解决Vbox Linux虚拟机共享文件夹没访问权限

虚拟机中 :sudo usermod -a -G vboxsf [Your user name]

Virtual Box 6.1.34在Debian 11(Bullseye)启动虚拟机后频繁崩溃

解决: 升级6.1.35版本即可。

Vbox升级到6.1.34后,Windows虚拟机直接卡死重启、Linux主机延时注销。查询官网的邮件列表中的BugTracker,搜索列表,然后找到了Ticket #20914。原来是Vbox6.1.34的问题,在6.1.35版本已修复。6.1.35版本在Test Build页面可以下载 | Extension Pack | Guest Addition

系统软件包依赖大故障恢复——dpkg --configure & dpkg-reconfigure

dpkg --configure -a :Will configure all unpacked but unconfigured packages.配置所有解压的、但未配置的软件包。

dpkg-reconfigure -phigh -a :Will reconfigure all installed packages that use debconf with high priority.将会重新配置经过debconf高优先级配置的已安装的软件包。

SSH密钥迁移后提示sign_and_send_pubkey: signing failed for RSA "/home/xxx/.ssh/id_rsa" from...| sign_and_send_pubkey: signing failed: agent refused operation

参考: https://www.cnblogs.com/qianyuliang/p/10032074.html

运行:eval "$(ssh-agent -s)"ssh-add即可,注意ssh密钥权限是600

Git仓库体积过大,如何减小?

参考: https://gitee.com/help/articles/4232#article-header0

Gitee说明的办法

查看存储库中的大文件

1
git rev-list --objects --all | grep -E `git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -10 | awk '{print$1}' | sed ':a;N;$!ba;s/\n/|/g'`

1
git rev-list --objects --all | grep "$(git verify-pack -v .git/objects/pack/*.idx | sort -k 3 -n | tail -15 | awk '{print$1}')"

改写历史,去除大文件

注意:下方命令中的 path/to/large/files 是大文件所在的路径,千万不要弄错!

1
2
3
git filter-branch --tree-filter 'rm -f path/to/large/files' --tag-name-filter cat -- --all
git push origin --tags --force
git push origin --all --force

如果在 git filter-branch 操作过程中遇到如下提示,需要在 git filter-branch 后面加上参数 -f

1
2
3
Cannot create a new backup.
A previous backup already exists in refs/original/
Force overwriting the backup with -f

并告知所有组员,push 代码前需要 pull rebase,而不是 merge,否则会从该组员的本地仓库再次引入到远程库中,导致仓库在此被 Gitee 系统屏蔽。

更加具体的操作可以点击文章 改写历史,永久删除git库的物理文件 查看

一些工具
https://github.com/newren/git-filter-repo
https://rtyley.github.io/bfg-repo-cleaner/
https://git-scm.com/docs/git-filter-branch

我采用的方法

下载 BFG Repo Cleaner

假设有个名为dir的git项目仓库需要清理,首先克隆:

git clone --mirror git://example.com/some-big-repo.git

开始清理:

java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git

清理结束后:

cd some-big-repo.git & git reflog expire --expire=now --all && git gc --prune=now --aggressive

最后,一旦您对仓库的更新状态感到满意,就将其备份 (请注意,因为您的clone命令使用了 --mirror标志,此推送将更新 所有 您的远程服务器上的 引用)git push

注意:您已经准备好让每个人都放弃他们的仓库的旧副本,并复制新的原始数据。 这是最好的删除所有旧的克隆,因为他们将有肮脏的历史,你 希望风险推回你的新清洁回购。

也就是说,你清理完后,其他clone这个仓库的人都要强制拉取新的内容(Master分支):

git fetch --all && git reset --hard origin/master && git pull

BFG其他功能:

删除所有名为“ id_rsa”或“ id_dsa”的文件:

1
$ bfg --delete-files id_{dsa,rsa}  my-repo.git

删除所有大于50 MB的Blob:

1
$ bfg --strip-blobs-bigger-than 50M  my-repo.git

将文件中列出的所有密码 在 (如果需要 前缀行’regex:’或’glob:’处) , 替换为 ***REMOVED***无论它们出现在您的存储库中的何处:

1
$ bfg --replace-text passwords.txt  my-repo.git

删除所有名为’.git’的文件夹或文件-Git中的 保留文件名 。 这些经常 成为问题 迁移到时 来自其他源代码控制系统(如Mercurial)的Git:

1
$ bfg --delete-folders .git --delete-files .git  --no-blob-protection  my-repo.git

笔记:

  • 清理Git仓库是 彻底 消除历史上的坏东西。如果出现“不良”情况(例如10MB的文件,则当您指定 --strip-blobs-bigger-than 5M)是在受保护的承诺,它 不会 是已删除-它将保留在您的存储库中,甚至如果BFG从较早的提交中删除了 。 如果您要删除BFG什么 ,你需要确保你目前的提交是 *干净的*
  • 请注意,尽管不会更改这些受保护的提交中的文件,但是当这些提交从较早的脏提交继续进行时,它们的提交id 更改,以反映更改后的历史记录-只有文件系统树的SHA-1 id会保持不变。

如果您想关闭保护功能(通常不建议这样做),则可以 使用 --no-blob-protection旗帜:

1
$ bfg --strip-biggest-blobs 100 --no-blob-protection repo.git

BFG帮助:

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
bfg 1.14.0
Usage: bfg [options] [<repo>]

-b, --strip-blobs-bigger-than <size>
strip blobs bigger than X (eg '128K', '1M', etc)
-B, --strip-biggest-blobs NUM
strip the top NUM biggest blobs
-bi, --strip-blobs-with-ids <blob-ids-file>
strip blobs with the specified Git object ids
-D, --delete-files <glob>
delete files with the specified names (eg '*.class', '*.{txt,log}' - matches on file name, not path within repo)
--delete-folders <glob> delete folders with the specified names (eg '.svn', '*-tmp' - matches on folder name, not path within repo)
--convert-to-git-lfs <value>
extract files with the specified names (eg '*.zip' or '*.mp4') into Git LFS
-rt, --replace-text <expressions-file>
filter content of files, replacing matched text. Match expressions should be listed in the file, one expression per line - by default, each expression is treated as a literal, but 'regex:' & 'glob:' prefixes are supported, with '==>' to specify a replacement string other than the default of '***REMOVED***'.
-fi, --filter-content-including <glob>
do file-content filtering on files that match the specified expression (eg '*.{txt,properties}')
-fe, --filter-content-excluding <glob>
don't do file-content filtering on files that match the specified expression (eg '*.{xml,pdf}')
-fs, --filter-content-size-threshold <size>
only do file-content filtering on files smaller than <size> (default is 1048576 bytes)
-p, --protect-blobs-from <refs>
protect blobs that appear in the most recent versions of the specified refs (default is 'HEAD')
--no-blob-protection allow the BFG to modify even your *latest* commit. Not recommended: you should have already ensured your latest commit is clean.
--private treat this repo-rewrite as removing private data (for example: omit old commit ids from commit messages)
--massive-non-file-objects-sized-up-to <size>
increase memory usage to handle over-size Commits, Tags, and Trees that are up to X in size (eg '10M')
<repo> file path for Git repository to clean

未归类——杂记

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
=========================================================================================
git clone https://github.com/chetan31295/pentmenu.git
git clone https://github.com/thelinuxchoice/ddostor.git
git clone https://github.com/zanyarjamal/zambie.git
git clone https://github.com/Yukinoshita47/Yuki-Chan-The-Auto-Pentest.git
git clone https://github.com/zanyarjamal/xerxes.git
=========================================================================================
# Linux 密码加盐
python3 -c 'import crypt; print(crypt.crypt("password123", crypt.mksalt(crypt.METHOD_SHA256)))
=========================================================================================
# 查看显示类型为X11或者Wayland:
loginctl
loginctl show-session 1 | grep Type
# 或者
echo $XDG_SESSION_TYPE
=========================================================================================
# 制作Debian安装盘,在U盘未挂载的情况下:
# cp debian.iso /dev/sdX
# sync
注意事项:/dev/sdb 而不是 /dev/sdb1
The hybrid image on the stick does not occupy all the storage space, so it may be worth considering using the free space to hold firmware files or packages or any other files of your choice. This could be useful if you have only one stick or just want to keep everything you need on one device.
Create a second, FAT partition on the stick, mount the partition and copy or unpack the firmware onto it. For example:
# mount /dev/sdX2 /mnt
# cd /mnt
# tar zxvf /path/to/firmware.tar.gz
# cd /
# umount /mnt
You might have written the mini.iso to the USB stick. In this case the second partition doesn't have to be created as, very nicely, it will already be present. Unplugging and replugging the USB stick should make the two partitions visible.
=========================================================================================
# 用tar备份与还原(不好用,系统备份建议用Clonezilla)
备份:`tar cvpzf backup.tgz[文件名] --exclude=proc[除外的目录] --exclude=lost+found --exclude=backup.tgz --exclude=mnt --exclude=sys --exclude=media /`

还原:`tar xvpfz backup.tgz -C / && mkdir proc && mkdir lost+found && mkdir mnt && mkdir sys`
=========================================================================================
# 蓝牙攻击
service bluetooth start
hciconfig
fang -s
fang -r b0aa3618e5d8-b0aa3618e5f4 -s
hcitool lescan
hcitool inq
sdptool browse <mac>
l2ping <mac> -f -s 2000
apt-get install minicom
blueranger hci0 [mac]
======================================================================================
# Windows中可代替粘滞键的后门文件:
sethc.exe
utilman.exe
osk.exe
narrator.exe
magnify.exe
displayswitch.exe
=========================================================================================
# shellcode注入攻击:
setoolkit中1,9生成shellcode
在说服受害者在命令行下复制shellcode则生效
=========================================================================================
# WebWAF防火墙探测 及 负载均衡器探测:
wafw00f www.baidu.com
lbd www.baidu.com
=========================================================================================
# 自动扫描仪扫描web的CMS(内容管理系统):
BlindElephant.py www.baidu.com joomla
=========================================================================================
# 网络爬虫探测网站现有目录和文件结构:
使用DirBuster
=========================================================================================
# 扫描VPN(IPSec):
nmap -sU -Pn -p 500 <IP>
ike-scan -M <IP>
ike-scan -M --showbackoff 192.168.0.10
截获预共享密钥:
ike-scan --pskcrack --aggressive --id=peer <target>
ike-scan -M -A -Ppsk-hash -d <target>(输出文件)
离线破解PSK:
psk-crack -d rockyou-75.txt psk-hash
=========================================================================================
# armitage
service postgresql start
=========================================================================================
# 端口
67:DHCPserver
68:DHCPclient
5900:VNC
=========================================================================================
# 修改网卡MAC:
ifconfig wlan0 down
ifconfig wlan0 hw ether 00:00:00:00:00:11
ifconfig wlan0 up
永久修改:
vim /etc/network/interfaces
添加下行:
pre-up ifconfig wlan0 hw ether 00:00:00:00:00:11
=========================================================================================
更改grub启动图片:
/usr/share/images/desktop-base/
update-grub
=========================================================================================
# ettercap ARP欺骗
ettercap -Tqi eth1 -M arp:remote /10.128.128.212// /10.128.128.1//
=========================================================================================
Google搜索SQL注入点:
site:[URL] inurl:login
=========================================================================================
第三方渗透模块:
W3AF 综合性web应用扫描审计
SQLmap SQL注入
wXf 开元web渗透框架
XSSF 跨站式脚本攻击
BeEF 浏览器攻击平台框架
其他:
Wapiti:SQL扫描准确度第一
burpsuite:神器
=========================================================================================
数据库“重灾区”:
microsoft SQL Server 1433端口 mssql_ping
Oracle SQL监听器 tnslsnr:1521 tnslsnr_version
=========================================================================================
SQL注入示例:
SECLECT * FROM [USERS] WHERE USERNAME = ? AND PASSWORD = ?
改成:
SECLECT * FROM [USERS] WHERE USERNAME = 'admin'OR'1' AND PASSWORD = 'test'OR'1'
或者:
SECLECT * FROM [USERS] WHERE USERNAME = 'admin'OR 1=1-- AND PASSWORD = '任意值'
=========================================================================================
google hacking:
inurl:”viewerframe?mode=motion 在线视频摄像头
intitle:”Live View / – AXIS
filetype:xls inurl:”email.xls
intitle:index.of xxxxx wwwroot.zip等敏感信息的打包文件,这些信息泄露对黑客来说是极具有危险性的
intitle:”VNC Viewer for Java
Active Webcam Page” inurl:8080
=========================================================================================
# 破解zip:
zip2john [zip_file] >> ./hash
john hash --wordlist=[Dictionary]
=========================================================================================
# 添加网关到路由:
route add default gw 192.168.1.1 dev wlan0
=========================================================================================
# 查看日志
head -10000 /var/lib/mysql/slowquery.log > temp.log
=========================================================================================
# android x86显示图形界面:
进入debug模式
mount -o remount,re/mnt
vi /mnt/grub/menu.lst
在第一个d的root前面加入nomodeset_
=========================================================================================
# 关于git ignore生效:
#add .gitignore
#查看状态,是否忽略了指定的文件?
$ git status --ignored #查看状态,包括忽略的文件

#让其对已经跟踪的文件也起作用
$ git rm -r --cached . #清除缓存 -r 表示递归删除(如果有文件夹的话) . 表示所有文件

#查看一下具体效果
$ git status --ignored
$ git add . #重新trace file
$ git commit -m "update .gitignore" #提交和注释
=========================================================================================

Debian Notes

安全启动和填充程序启动程序

安全启动是一项确保您仅运行由操作系统供应商验证的软件的技术。为了完成其工作,引导序列中的每个元素都会验证它将执行的下一个软件组件。在最深层,UEFI固件嵌入了Microsoft提供的加密密钥,以检查引导加载程序的签名,以确保执行安全。由于由Microsoft进行二进制签名是一个漫长的过程,因此Debian决定不直接对GRUB进行签名。取而代之的是,它使用一个称为shim的中间引导程序,该引导程序几乎不需要更改,其唯一作用是检查Debian在GRUB上提供的签名并执行GRUB。要在启用了安全启动的机器上运行Debian,您需要安装由shim签名的软件包。
在堆栈中,GRUB将对内核进行类似的检查,然后内核可能还会检查要加载的模块上的签名。内核也可能禁止某些可能改变系统完整性的操作。
Debian 10是第一个支持安全启动的发行版。以前,您必须在BIOS或UEFI提供的系统设置程序屏幕中禁用该功能。

1
2
3
4
CULTURE Secure Boot and the shim bootloader
Secure Boot is a technology ensuring that you run only software validated by your operating system vendor. To accomplish its work each element of the boot sequences validates the next software component that it will execute. At the deepest level, the UEFI firmware embeds cryptographic keys provided by Microsoft to check the bootloader's signature, ensuring that it is safe to execute. Since getting a binary signed by Microsoft is a lengthy process, Debian decided to not sign GRUB directly. Instead it uses an intermediary bootloader called shim, which almost never needs to change, and whose only role is to check Debian's provided signature on GRUB and execute GRUB. To run Debian on a machine having Secure Boot enabled, you need to install the shim-signed package.
Down the stack, GRUB will do a similar check with the kernel, and then the kernel might also check signatures on modules that get loaded. The kernel might also forbid some operations that could alter the integrity of the system.
Debian 10 is the first release supporting Secure Boot. Before, you had to disable that feature in the system setup screen offered by the BIOS or the UEFI.

我该如何安装 Debian Sid?

正规的答案是:Debian 从不发布 unstable。你只能从 testing 升级至它。你可以以编辑 /etc/apt/sources.list 的方式更改你的软件源,从 testing 变为 unstable。(如果你安装的是稳定版,你应该先升级为 testing 再升级为 unstable。)

如果你在使用从 testing 分支而来的网络安装方式,直接安装 sid 的软件包(而不是 testing 的软件包)也是可能的。这种方式不被支持,但如果你想试试看,我们也不会拦着你。到底来说这还是你自己的机器,只要别在出问题时哭鼻子就好。

Debian Backports的简单使用

反向移植是在稳定环境中经过测试(主要是经过测试)和不稳定(在少数情况下,例如,安全更新)重新编译的软件包,因此它们将在Debian稳定发行版上在没有新库的情况下(只要有可能)运行。

不能对Backports进行像Debian稳定版那样广泛的测试,并且按原样提供Backports,存在与Debian稳定版中其他组件不兼容的风险。小心使用!

因此,建议选择适合您需要的单个反向移植软件包,而不要使用所有可用的反向移植。

通俗说,你可以在Backports中找到稳定版中没有的软件包。

将反向端口添加到您的sources.list

  1. 添加下列:

    1
    deb http://deb.debian.org/debian buster-backports main

    到您的sources.list (或在/etc/apt/sources.list.d/中添加扩展名为“ .list”的新文件)。

  2. 运行apt-get更新

从Backports安装软件包

默认情况下,所有Backport均处于禁用状态(即,使用ButAutomaticUpgrades将软件包固定为100,在Release文件中为“是”。如果要从反向端口安装某些内容,请运行:

1
apt-get install <package>/buster-backports

当然,您也可以使用aptitude:

1
aptitude install <package>/buster-backports

有几种不同的方法可以确定某个Debian软件包的反向端口是否存在。一个非常方便的方法是使用Debian的基于Web的软件包搜索(packages.debian.org)。

使用apt search命令搜索软件包名称时,也会出现软件包的反向移植版本,或者可以通过运行以下命令查看软件包的所有可用版本:

1
2
3
apt show package-name -a
# 安装cockpit
apt -t buster-backports install cockpit

列出已安装的backport

1
dpkg-query -W | grep '~bpo'

“草率“(随意…?)发行版

为了保证从先前稳定的发行版到下一个稳定发行版的升级路径整洁,不允许将程序包从当前测试上传到该反向移植发行版。为了允许这些系统使用一些较新的软件包,我们创建了所谓的草率发行版。

您可以将其完全用作当前backport发行版,只需向您的sources.list添加另一行,然后通过apt-get -t Stretch-backports install安装新软件包

订阅安全公告邮件列表

如果要在backports.debian.org上获取有关安全更新的公告,请订阅debian-backports-announce邮件列表

报告错误

请将您在软件包中找到的错误报告给backports邮件列表,不要报告给Debian BTS!

Systemd

关于加速启动速度:https://wiki.debian.org/BootProcessSpeedup

查看服务被依赖:例如查看NetworkManager-wait-online.service被哪些依赖:systemctl list-dependencies --reverse NetworkManager-wait-online.service

查看开机服务占用时间(仅供参考,不大准):systemd-analyze blame

查看服务的启动顺序:systemd-cgls

查看启动时间:systemd-analyze

导出启动流程图:systemd-analyze plot > boot.svg

Debian Package

  1. 二进制包的结构

    Debian的包可以任何Unix系统的经典命令来提取,如artarxzgzipbzip2。这个看似微不足道的特性对于可移植性和灾难恢复很重要。

    dpkg本身也是Debian的软件包,你需要用dpkg来安装Debian软件包…如果您错误地删除了dpkg程序,您将无法再安装Debian软件包。幸运的是,您知道软件包的格式,因此可以下载dpkg软件包的.deb文件并手动安装(请参见sidebar工具)。如果你不幸丢失artargzipxzbzip2中的一个或多个程序,您只需要从另一个完整的系统复制丢失的程序(由于这几个程序都以完全自主的方式运行,没有依赖关系,因此只需一个简单的复制就可以了)。如果您的系统遭受了更大的损失,甚至连这些都不起作用(也许缺少最深层的系统共享库?),您应该尝试使用的静态版本busybox(在busybox-static软件包中提供),该版本更加相对独立且提供了如busybox arbusybox tarbusybox xz的子命令。

    为了应对突发状况,你需要不时对系统进行备份:(Debian Doc:第 9.10 节 “备份”)。关于手册man请查看:第 7 章 问题的解决与相关信息的检索 更详细地讨论手册页 (参见 第 7.1.1 节 “手册页面”)。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    #### dpkg、APT 和 ar
    dpkg是处理.deb文件(二进制程序包)的程序,尤其是提取,分析和解压缩文件的程序。

    APT(“Advanced Packaging Tool高级包装工具”的缩写)是一组程序,可以对系统执行更高级别的修改:安装或删除程序包(同时保持依赖关系),更新和升级系统,列出可用程序。包装等。

    ar程序,它允许处理相同名称的文件:显示该归档文件中包含的文件列表,将文件从归档文件中提取到当前工作目录中,从归档文件中删除文件,等等。其手册页(ar1))记录了其所有其他功能。这是一个非常基本的工具,Unix管理员只会在极少数情况下使用,但管理员通常会使用,它是一个经过改进的存档和文件管理程序。这就是为什么在错误删除的情况下很容易恢复的原因。您只需要下载Debian软件包并从系统根目录()中的档案中提取内容即可: ar t archivear x archivear d archive fileartardpkgdata.tar.xz/

    # ar x dpkg_1.19.7_amd64.deb
    # tar -C / -p -xJf data.tar.xz

    #### 查看Man手册:
    初学者可能会在看到“ar(1)”这样的文字注记时感到疑惑。这通常是个简写,它表示指向 man 手册第一类中标题是 ar 的页面。
    有时这种注记也用来避免歧义,比如要区分清楚是 printf 命令,可以用 printf(1) 来指明,如果是 C 语言里的 printf 函数,就可以用 printf(3) 来引用。

Manjaro Notes

修改国内源

  • 根据清华开源镜像站指南:

    编辑 /etc/pacman.d/mirrorlist, 在文件的最顶端添加:

    1
    Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch

    更新软件包缓存(仅用于第一次更新):

    1
    sudo pacman -Syy
  • 根据GUI提示操作:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    #1. 第一部分使用 pacman-mirrors 更新官方软件源
    ##1.1 按照地区自动更新为最快最稳定的软件源镜像地址
    sudo pacman-mirrors --country China
    ##1.2. 恢复默认软件源操作
    sudo pacman-mirrors --interactive --default
    ##1.3 软件源更新之后,我们一般会进行系统更新
    sudo pacman -Syyu # 软件源更新完成之后进行系统软件更新操作
    ##1.4 查看所有可用的地区信息
    sudo pacman-mirrors -l
  • Arch Linux CN仓库:Arch Linux 中文社区仓库 是由 Arch Linux 中文社区驱动的非官方用户仓库。包含中文用户常用软件、工具、字体/美化包等。

    使用方法:在 /etc/pacman.conf 文件末尾添加以下两行:

    1
    2
    [archlinuxcn]
    Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

    之后安装 archlinuxcn-keyring 包导入 GPG key。

  • Arch for edu源:Arch4edu 是面向高校用户推出的非官方软件仓库, 支持 Arch Linux 和 Arch Linux ARM, 主要包含高校用户常用的科研、教学及开发软件。

    • 导入 GPG key
    1
    2
    3
    $ pacman-key --recv-keys 7931B6D628C8D3BA
    $ pacman-key --finger 7931B6D628C8D3BA
    $ pacman-key --lsign-key 7931B6D628C8D3BA
    • /etc/pacman.conf 文件末尾添加以下内容:
    1
    2
    [arch4edu]
    Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch
    • [不推荐] 不导入 GPG key,并直接在 /etc/pacman.conf 文件末尾添加以下内容:
    1
    2
    3
    [arch4edu]
    SigLevel = Never
    Server = https://mirrors.tuna.tsinghua.edu.cn/arch4edu/$arch

修改AUR源

yay用户

执行以下命令修改 aururl :

1
yay --aururl "https://aur.tuna.tsinghua.edu.cn" --save

修改的配置文件位于 ~/.config/yay/config.json ,还可通过以下命令查看修改过的配置:

1
yay -P -g

Pacman指南

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
#2. 第二部分使用 pacman 管理软件
##2.1 同步并且更新你的系统
sudo pacman -Syyu
##2.2 在软件仓库中搜索软件
sudo pacman -Ss [software package name]
##2.3 查看已安装软件
sudo pacman -Qs [software package name]
sudo pacman -Qi [software package name] # 附带详细信息
sudo pacman -Qii [software package name] # 附带更加详细的包信息
sudo pacman -Ql # 列出所有安装的软件包
##2.4 查看软件的详细依赖
sudo pactree [software package name]
##2.5 查看系统中那些没有被使用软件依赖包(orphans)
sudo pacman -Qdt
##2.6 自动移除那些系统中没有被使用的依赖包【类似于Debian下的 sudo apt autoremove --purge】
sudo pacman -Rs $(pacman -Qdtq)
##2.7 下载并安装软件包
sudo pacman -Syu [software package name] # 从软件仓库安装
yay -S [software package name] # Packages from the AUR
sudo pacman -U [/package_path/][software package name.pkg.tar.xz] # 从本地安装
pacman -U http://www.examplepackage/repo/examplepkg.tar.xz # 从网络安装【非官方仓库】
##2.8 卸载软件
sudo pacman -R [software package name]
sudo pacman -Rs [software package name] # 同时删除依赖
sudo pacman -Rns [software package name] # 删除软件及其依赖,还有pacman生成的配置文件,即更彻底的删除
##2.9 清空缓存【默认情况下安装软件会先来缓存中查看是否已经下载过,没有再去下载,软件安装后通常下载缓存还在】
sudo pacman -Sc
sudo pacman -Scc # 更彻底的清理
关于 pacman 常用就这些了,更多请使用 man pacman OR pacman -h 去查看

安装VirtualBox

首先查看自己内核版本

1
2
$ sudo uname -r 
Linux bl 5.8.16-2-MANJARO #1 SMP PREEMPT Mon Oct 19 11:33:03 UTC 2020 x86_64 GNU/Linux

装符合自己版本的

1
2
3
4
5
 $  sudo pacman -S virtualbox
## 这里需要选择与当前内核相同的内核模块比如笔者正在使用的内核版本为5.8.16-2-MANJARO,则需要安装linux58-virtualbox-host-modules
$ pacman -Sy linux58-virtualbox-host-modules
$ sudo gpasswd -a $USER vboxusers #添加当前用户到vboxusers
$ sudo modprobe vboxdrv

fcitx输入法

~/.pam_environment中添加[亲测好用,推荐]

1
2
3
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"

Do-WeChat——Docker微信

Docker微信

项目地址:https://github.com/huan/docker-wechat

Docker Hub:https://hub.docker.com/r/zixia/wechat/tags?page=1&ordering=last_updated

一键启动脚本——我加了个root检测罢了。

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
# 请在这里指定镜像版本!
DEFAULT_WECHAT_VERSION=2.9.0.114
#
# dochat.sh - Docker WeChat for Linux
#
# Author: Huan (李卓桓) <zixia@zixia.net>
# Copyright (c) 2020-now
#
# License: Apache-2.0
# GitHub: https://github.com/huan/docker-wechat
#

# 颜色colors
CDEF=" \033[0m" # default color
CCIN=" \033[0;36m" # info color
CGSC=" \033[0;32m" # success color
CRER=" \033[0;31m" # error color
CWAR=" \033[0;33m" # warning color
b_CDEF=" \033[1;37m" # bold default color
b_CCIN=" \033[1;36m" # bold info color
b_CGSC=" \033[1;32m" # bold success color
b_CRER=" \033[1;31m" # bold error color
b_CWAR=" \033[1;33m"

# echo like ... with flag type and display message colors
# -s 绿
# -e 红
# -w 黄
# -i 蓝
prompt () {
case ${1} in
"-s"|"--success")
echo -e "${b_CGSC}${@/-s/}${CDEF}";; # print success message
"-e"|"--error")
echo -e "${b_CRER}${@/-e/}${CDEF}";; # print error message
"-w"|"--warning")
echo -e "${b_CWAR}${@/-w/}${CDEF}";; # print warning message
"-i"|"--info")
echo -e "${b_CCIN}${@/-i/}${CDEF}";; # print info message
*)
echo -e "$@"
;;
esac
}

ROOT_UID=0

prompt -w "\n检查权限 —— Checking ...\n"
if [ "$UID" -eq "$ROOT_UID" ]; then
# Error message
prompt -e "\n [ Error ] -> 请不要使用管理员权限(not sudo)运行 Please run as not root \n"
exit 1
else
prompt -s "\n—————————— Unit Ready ——————————\n"
fi

set -eo pipefail

#
# The defeault docker image version which confirmed that most stable.
# See: https://github.com/huan/docker-wechat/issues/29#issuecomment-619491488
#
# DEFAULT_WECHAT_VERSION=2.7.1.85

#
# Get the image version tag from the env
#
DOCHAT_IMAGE_VERSION="zixia/wechat:${DOCHAT_WECHAT_VERSION:-${DEFAULT_WECHAT_VERSION}}"

function hello () {
cat <<'EOF'

____ ____ _ _
| _ \ ___ / ___| |__ __ _| |_
| | | |/ _ \| | | '_ \ / _` | __|
| |_| | (_) | |___| | | | (_| | |_
|____/ \___/ \____|_| |_|\__,_|\__|

https://github.com/huan/docker-wechat

+--------------+
/| /|
/ | / |
*--+-----------* |
| | | |
| | 盒装 | |
| | 微信 | |
| +-----------+--+
| / | /
|/ |/
*--------------*

DoChat /dɑɑˈtʃæt/ (Docker-weChat) is:

📦 a Docker image
🤐 for running PC Windows WeChat
💻 on your Linux desktop
💖 by one-line of command

EOF
}

function pullUpdate () {
if [ -n "$DOCHAT_SKIP_PULL" ]; then
return
fi

echo '🚀 Pulling the docker image...'
echo
docker pull "$DOCHAT_IMAGE_VERSION"
echo
echo '🚀 Pulling the docker image done.'
}

function main () {

hello
pullUpdate

DEVICE_ARG=()
for DEVICE in /dev/video* /dev/snd; do
DEVICE_ARG+=('--device' "$DEVICE")
done

echo '🚀 Starting DoChat /dɑɑˈtʃæt/ ...'
echo

rm -f "$HOME/DoChat/Applcation Data/Tencent/WeChat/All Users/config/configEx.ini"

#
# --privileged: enable sound (/dev/snd/)
# --ipc=host: enable MIT_SHM (XWindows)
#
docker run \
"${DEVICE_ARG[@]}" \
--name DoChat \
--rm \
-i \
\
-v "$HOME/DoChat/WeChat Files/":'/home/user/WeChat Files/' \
-v "$HOME/DoChat/Applcation Data":'/home/user/.wine/drive_c/users/user/Application Data/' \
-v /tmp/.X11-unix:/tmp/.X11-unix \
\
-e DISPLAY \
-e DOCHAT_DEBUG \
-e DOCHAT_DPI \
\
-e XMODIFIERS \
-e GTK_IM_MODULE \
-e QT_IM_MODULE \
\
-e AUDIO_GID="$(getent group audio | cut -d: -f3)" \
-e VIDEO_GID="$(getent group video | cut -d: -f3)" \
-e GID="$(id -g)" \
-e UID="$(id -u)" \
\
--ipc=host \
--privileged \
\
"$DOCHAT_IMAGE_VERSION"

echo
echo "📦 DoChat Exited with code [$?]"
echo
echo '🐞 Bug Report: https://github.com/huan/docker-wechat/issues'
echo

}

main

Debian服务器 - 从命令行搭建X窗口

安装好Debian后,如果只有root用户,请添加新用户。

1
2
3
4
5
6
7
8
9
10
11
# 新建用户
$ useradd -s /bin/zsh -g group –G adm,root sam
## 此命令新建了一个用户sam,该用户的登录Shell是 `/bin/zsh`,它属于group用户组,同时又属于adm和root用户组,其中group用户组是其主组。
$ useradd –d /home/sam -m sam
## 此命令创建了一个用户sam,其中-d和-m选项用来为登录名sam产生一个主目录 /home/sam(/home为默认的用户主目录所在的父目录)。
$ useradd -m -G wheel,users -s /bin/zsh -p passwd username

# 如果你想更改用户Shell:
$ chsh -s /bin/zsh
# 或者,这样也可以
$ usermod -s /bin/zsh 【用户名】

安装X窗口管理器

首先更新系统,然后安装Xorg-xinit和fluxbox窗口管理器。

1
2
apt-get update && apt-get dist-upgrade
apt-get install xinit fluxbox

在用户目录新建.xinit文件,并写入 : exec startfluxbox 。然后下次登录时,命令行输入 startx就能启动Fluxbox wm了。

自动登录tty终端

编辑/etc/systemd/logind.conf ,将#NAutoVTs=6 改为 NAutoVTs=1

然后用systemctl edit getty@tty1 命令在/etc/systemd/system/getty@tty1.service.d/override.conf中生成一个getty@tty1.service.d 文件夹和override.conf文件 。在文件中填入:

1
2
3
[Service]
ExecStart=
ExecStart=-/usr/sbin/agetty --autologin username --noclear %I $TERM

优化Fluxbox

配置 Fluxbox配置下载

Fluxbox英特尔显卡调整亮度:

apt install xbacklight

错误处理:No outputs have backlight property

新建文件 /etc/X11/xorg.conf.d/20-intel.conf

1
2
3
4
5
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "Backlight" "intel_backlight"
EndSection

注意:intel_backlight/sys/class/backlight目录中的英特尔显卡文件名。

调整亮度:

1
2
$ xbacklight -inc 10
$ xbacklight -dec 10

系统托盘显示无线Wifi:

安装Network Manager

1
apt install network-manager network-manager-gnome

然后在fluxbox的startup脚本中添加nm-applet&就ok了。

~/.fluxbox/keys设置快捷键

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
! fluxbox-update_configs added '(workspace=[current])' to (Next|Prev)(Window|Group)
! check lines marked by 'FBCV13' if they are correctly updated
!mouse actions added by fluxbox-update_configs
OnTitlebar Mouse1 :MacroCmd {Focus} {Raise} {ActivateTab}
!mouse actions added by fluxbox-update_configs
OnTitlebar Move1 :StartMoving
OnLeftGrip Move1 :StartResizing bottomleft
OnRightGrip Move1 :StartResizing bottomright
OnWindowBorder Move1 :StartMoving

!mouse actions added by fluxbox-update_configs
OnTitlebar Mouse2 :StartTabbing

!mouse actions added by fluxbox-update_configs
OnTitlebar Double Mouse1 :Shade
OnTitlebar Mouse3 :WindowMenu

!mouse actions added by fluxbox-update_configs
OnWindow Mod1 Mouse1 :MacroCmd {Raise} {Focus} {StartMoving}
OnWindow Mod1 Mouse3 :MacroCmd {Raise} {Focus} {StartResizing BottomRight}

!mouse actions added by fluxbox-update_configs
OnDesktop Mouse1 :hideMenus
OnDesktop Mouse2 :workspaceMenu
OnDesktop Mouse3 :rootMenu

Mod1 Tab :NextWindow (workspace=[current]) !! FBCV13 !!
Mod1 Shift Tab :PrevWindow (workspace=[current]) !! FBCV13 !!
Mod1 1 :Workspace 1
Mod1 2 :Workspace 2
Mod1 3 :Workspace 3
Mod1 4 :Workspace 4
Mod1 5 :Workspace 5
Mod1 6 :Workspace 6
Mod1 Escape :MaximizeWindow
#Mod1 F1 :RootMenu
Mod1 m :RootMenu


# change to a specific workspace
#Mod1 1 :ExecCommand wmctrl -s 0
#Mod1 2 :ExecCommand wmctrl -s 1
#Mod1 3 :ExecCommand wmctrl -s 2
#Mod1 4 :ExecCommand wmctrl -s 3
#Mod1 5 :ExecCommand wmctrl -s 4
#Mod1 6 :ExecCommand wmctrl -s 5

##### 自定义的快捷键 - Customized
### 这里是Alt键
Mod1 q :ExecCommand xfce4-terminal
Mod1 w :ExecCommand deadbeef
Mod1 e :ExecCommand thunar
Mod1 r :ExecCommand firefox
Mod1 t :ExecCommand virtualbox
# 窗口全屏、关闭窗口
Mod1 f :Fullscreen
Mod1 F4 :Close
# 重启fluxbox
Mod1 Mod4 p :Restart

### 这里是Super(开始键)键
# 显示桌面
Mod4 d :ShowDesktop
# 最大化、最小化窗口
Mod4 Up :MaximizeWindow
Mod4 Down :MinimizeWindow
# 收起、放下窗口
Mod4 Left :ShadeOn
Mod4 Right :ShadeOff
# 安装scrot截屏
Print :ExecCommand scrot

~/.fluxbox/menu 设置桌面主菜单(示例)

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
33
34
35
36
37
38
[begin] (Fluxbox Menu)
# 格式:
#[submenu] (Label)
# [exec] (Label) {Command}
#[end]
#[exec] (Play music) {deadbeef}
[exec] (File Manager) {thunar}
[submenu] (Browsers)
[exec] (Firefox) {firefox}
[exec] (Chromium) {chromium}
[end]
[submenu] (Appearance)
[config] (Configure)
[submenu] (Menu size) {Choose Size...}
[stylesdir] (~/.fluxbox/styles)
[restart] (Apply style)
[end]
[submenu] (Conky size) {Choose Size...}
[exec] (size 10) {~/.fluxbox/scripts/conky/conky-10}
[exec] (size 12) {~/.fluxbox/scripts/conky/conky-12}
[exec] (size 14) {~/.fluxbox/scripts/conky/conky-14}
[exec] (size 16) {~/.fluxbox/scripts/conky/conky-16}
[exec] (size 18) {~/.fluxbox/scripts/conky/conky-18}
[exec] (size 20) {~/.fluxbox/scripts/conky/conky-20}
[end]
[exec] (Theme & Font) {lxappearance}
[end]
#[exec] (X-terminal) {Eterm -c green -t ml-theme-small -g 90x23 -L 10000 -O --shade 80}
[exec] (Xfce4-terminal) {xfce4-terminal}
[exec] (OBS) {obs}
[exec] (OSD-Lyrics) {osdlyrics}
[separator]
[restart] (Restart Fluxbox)
[exit] (Exit Session)
[exec] (Reboot) {sudo shutdown -r now}
[exec] (Poweroff) {sudo shutdown -P now}
[end]
[end]

~/.fluxbox/startup 设置自启动项目,记得给予可执行权限!

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
33
34
35
36
37
38
#!/bin/bash
#
# fluxbox startup-script:
#
# Lines starting with a '#' are ignored.

# Customize Here
/usr/bin/fbsetbg -a ~/.fluxbox/backgrounds/music-white-black-hd-wallpaper.jpg&
conky&
fcitx&
# 联网
nm-applet&

# Change your keymap:
xmodmap "/home/jessie/.Xmodmap"

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
#
# unclutter -idle 2 &
# wmnd &
# wmsmixer -w &
# idesk &
#
# Debian-local change:
# - fbautostart has been added with a quick hack to check to see if it
# exists. If it does, we'll start it up by default.
which fbautostart > /dev/null
if [ $? -eq 0 ]; then
fbautostart
fi

# And last but not least we start fluxbox.
# Because it is the last app you have to run it with ''exec'' before it.

# exec fluxbox
# or if you want to keep a log:
exec fluxbox -log "/home/jessie/.fluxbox/log"

命令行登录后自动启动图形界面(zsh为例),编辑~/.zprofile

1
2
3
4
5
export QT_QPA_PLATFORMTHEME=qt5ct

if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]; then
startx
fi

安装xfce4

Xfce4提示缺少dbus-launcher:

apt install dbus-x11

Xfce4锁屏

dm-tool lock

系统个性化——Customize

Linux自定义安装

GRUB安装

通用知识点:

  • 在你运行 grub-install 的时候使用 --removable 选项,就可以让 GRUB 把它的 EFI 映像写入到 /boot/efi/EFI/BOOT/BOOTX64.efi,这样启动固件就可以在没有 UEFI 启动条目的的情况下找到。
Legacy Boot——BIOS启动
  • 安装GRUB:grub-install --target=i386-pc /dev/sdX
UEFI——UEFI启动

要从一个磁盘上使用 UEFI 模式启动,磁盘上必须要先有一个 EFI 分区。按照 EFI system partition#Check for an existing partition 上说的来查看你是否已经有一个 EFI 分区,如若没有,就创建一个。

  • 磁盘开头添加BIOS保留区

    如果是在GPT磁盘安装UEFI启动Linux,建议在磁盘开头新建一个BIOS启动保留分区,避免被误认为MBR启动引导分区而遭到破坏。

    1
    2
    3
    4
    安装 GRUB 前,在一个没有文件系统的磁盘上,创建一个1兆字节(使用 fdisk 或 gdisk 和参数+1M)的分区(保留的BIOS启动分区),将分区类型设置为 GUID 21686148-6449-6E6F-744E-656564454649
    对于 fdisk,选择分区类型 BIOS boot。
    对于 gdisk,选择分区类型代码 ef02。
    对于 parted, 在新创建的分区上设置/激活 bios_grub 标记。
  • 安装GRUB:grub-install --target=x86_64-efi --efi-directory=esp --bootloader-id=GRUB

    提示: 如果你使用了 --removable 选项,那 GRUB 将被安装到 *esp*/EFI/BOOT/BOOTX64.EFI (当使用 i386-efi 时是 *esp*/EFI/BOOT/BOOTIA32.EFI),此时即使 EFI 变量被重设或者你把这个驱动器接到其他电脑上,你仍可从这个驱动器上启动。通常来说,你只要像操作 BIOS 设备一样在启动时选择这个驱动器就可以了。如果和 Windows 一起多系统启动,注意 Windows 通常会在那里安装一个 EFI 可执行程序,这只是为了重建 Windows 的 UEFI 启动项。

    注意:

    • --efi-directory--bootloader-id 是 GRUB UEFI 特有的。--efi-directory 替代了已经废弃的 --root-directory
    • 您可能注意到在 grub-install 命令中没有一个 选项,例如 /dev/sda。事实上即使提供了 ,也会被 GRUB 安装脚本忽略,因为 UEFI 启动加载器不使用 MBR 启动代码或启动扇区。
    • 确保 grub-install 命令是在你想要用 GRUB 引导的那个系统上运行的。也就是说如果你是用安装介质启动进入了安装环境中,你需要在 chroot 之后再运行 grub-install。如果因为某些原因不得不在安装的系统之外运行 grub-install,在后面加上 --boot-directory= 选项来指定挂载 /boot 目录的路径,例如 --boot-directory=/mnt/boot
安装到 U 盘
BIOS

假设 U 盘的第一个分区是 FAT32格式,其分区是/dev/sdy1

1
2
3
4
# mkdir -p /mnt/usb
# mount /dev/sdy1 /mnt/usb
# grub-install --target=i386-pc --debug --boot-directory=/mnt/usb/boot /dev/sdy
# grub-mkconfig -o /mnt/usb/boot/grub/grub.cfg

可以选择将配置备份到 grub.cfg

1
2
3
4
# mkdir -p /mnt/usb/etc/default
# cp /etc/default/grub /mnt/usb/etc/default
# cp -a /etc/grub.d /mnt/usb/etc
# sync; umount /mnt/usb
EFI

在你运行 grub-install 的时候使用 --removable 选项,就可以让 GRUB 把它的 EFI 映像写入到 /boot/efi/EFI/BOOT/BOOTX64.efi,这样启动固件就可以在没有 UEFI 启动条目的的情况下找到。

安装到分区上或者无分区磁盘上

警告: GRUB 极不推荐 将其安装到分区启动扇区或者无分区磁盘上(Grub Legacy 和 syslinux 相反)。这种安装方式不安全,当升级时可能会损坏。Arch 开发人员也 不支持 这种方式.

下面的命令将会将 GRUB 安装到分区扇区或者无分区磁盘(也称作超级软盘),或者安装到软盘上。下面例子中以 /dev/sdaX 作为 /boot 分区。

1
2
3
# chattr -i /boot/grub/i386-pc/core.img
# grub-install --target=i386-pc --debug --force /dev/sdaX
# chattr +i /boot/grub/i386-pc/core.img

注意:

  • /dev/sdaX 仅用作示例。
  • --target=i386-pcgrub-install 仅为 BIOS 系统安装。建议总是使用这个选项来排除 grub-install 命令中的模糊性。

你应该使用 --force 选项来启用对 blocklists(块列表)的支持,而不应该使用 --grub-setup=/bin/true,后者类似于单纯地生成 core.img

grub-install 会生成以下警告,来提醒你哪里有可能出现问题。

1
2
3
/sbin/grub-setup: warn: Attempting to install GRUB to a partitionless disk or to a partition. This is a BAD idea.
/sbin/grub-setup: warn: Embedding is not possible. GRUB can only be installed in this setup by using blocklists.
However, blocklists are UNRELIABLE and their use is discouraged.

不使用 --force 选项则可能会出现以下错误,并且 grub-setup 不会将启动代码安装到启动扇区上:

1
/sbin/grub-setup: error: will not proceed with blocklists

而指定了 --force,会出现:

1
Installation finished. No error reported.

grub-setup 默认不启用这个选项,是因为在分区或者无分区磁盘上,grub 依赖于嵌入分区引导扇区的块列表 (blocklists) 来定位 /boot/grub/i386-pc/core.img 和前缀目录 /boot/grub。而 core.img 在分区上的扇区位置很有可能随着分区文件系统的更改而变化(复制文件,删除文件等)。详情请参考 https://bugzilla.redhat.com/show_bug.cgi?id=728742https://bugzilla.redhat.com/show_bug.cgi?id=730915.

临时解决方案是给 /boot/grub/i386-pc/core.img 文件加“不可变”(immutable) 标志(按照上面提过的,使用 chattr 命令)。这样 core.img 文件的位置就不会变。只有当将 GRUB 安装到分区启动扇区或者无分区磁盘上时才需要给 /boot/grub/i386-pc/core.img 加上“不可变”标志,在安装到 MBR 或者单纯地生成 core.img 而不嵌入到其他引导扇区里的时候,就不用添加(正如上面所述)。

然而即使没有报错,生成的 grub.cfg 文件也不会包含正确的 UUID。参考 https://bbs.archlinux.org/viewtopic.php?pid=1294604#p1294604 。 要解决这个问题,使用如下命令:

1
2
3
4
5
# mount /dev/sdxY /mnt        #Your root partition.
# mount /dev/sdxZ /mnt/boot #Your boot partition (if you have one).
# arch-chroot /mnt
# pacman -S linux
# grub-mkconfig -o /boot/grub/grub.cfg
只生成 core.img

通过添加 --grub-setup=/bin/true 选项,grub-install 命令会填充 /boot/grub 文件夹并生成 /boot/grub/i386-pc/core.img,但是 不会 将 GRUB 启动引导代码嵌入到 MBR、MBR 后部区域或者分区引导扇区中。

1
# grub-install --target=i386-pc --grub-setup=/bin/true --debug /dev/sda

注意:

  • /dev/sda 仅是示例。
  • --target=i386-pcgrub-install 仅为 BIOS 系统安装。建议总是使用这个选项来排除 grub-install 命令中的模糊性。

生成后,Grub Legacy 或者 syslinux 就可以通过链式加载 GRUB 的 core.img 来间接加载 Linux 内核或者多启动内核了。参阅Syslinux (简体中文)#Chainloading#Chainloading)[断开的链接:无效的部分]。

BOOT分区

  • 如果是加密磁盘,且boot分区在加密分区中,则进入GRUB之前需要输入密码。如果将boot分区单独出来则可以在进入GRUB后选择系统之后再考虑输入密码的事。

GRUB个性化——GRand Unified Bootloader

官方文档

Tips and tricks/Tipsand_tricks(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)#%E5%85%B6%E5%AE%83%E5%AE%89%E8%A3%85%E6%96%B9%E5%BC%8F)

GRUB配置

图形化工具:grub-customizer — GRUB 或者 BURG 的 GTK+ 定制器

安装GRUB后,需要生成主配置文件 /boot/grub/grub.cfg。配置文件的生成过程受到 /etc/default/grub 中的选项和 /etc/grub.d/ 下脚本的影响。请记住,每当修改 /etc/default/grub 或者 /etc/grub.d/ 中的文件之后,都需要再次#生成主配置文件#生成主配置文件)。

配置需要编辑:/etc/default/grub/etc/grub.d/

1
# grub-mkconfig -o /boot/grub/grub.cfg

如果你没有进行额外配置,自动生成程序会在当前启动的系统的根文件系统中侦测配置文件。所以请确保系统已经启动或者已经通过chroot 进入。

注意:

  • 请记住,每当修改 /etc/default/grub 或者 /etc/grub.d/ 中的文件之后,都需要再次生成 /boot/grub/grub.cfg
  • 默认的文件路径是 /boot/grub/grub.cfg,而非 /boot/grub/i386-pc/grub.cfg
  • 如果你是在 chroot 或者 systemd-nspawn 容器中运行 grub-mkconfig,可能会报 grub-probe 无法获取 “canonical path of /dev/sdaX” 错误而无法正常执行。此时可以尝试使用 arch-chroot,参见 BBS post
  • 如果你在使用了 LVM 的 chroot 环境中安装 GRUB,grub-mkconfig 会无限期挂起。参见 #Device /dev/xxx not initialized in udev database even after waiting 10000000 microseconds#Device_/dev/xxx_not_initialized_in_udev_database_even_after_waiting_10000000_microseconds)。

视觉配置

GRUB 默认支持改变菜单外观。如果你没有初始化,请务必以视频模式 gfxmode 初始化 GRUB 图形终端 gfxterm,你可以在 GRUB (简体中文)#”No suitable mode found” 错误#”Nosuitable_mode_found”错误)一节找到这部分内容。此视频模式由 GRUB 通过 gfxpayload 传递给 Linux 内核,任何视觉配置都需要这种模式才能够有效果。

GRUB主题

主题可以从OpenDesktop下载到。

我这里提供了一些案例:(目前主题在rm_scripts 仓库 > https://github.com/rmshadows/rm_scripts/tree/main/Debian_GNOME_Init/OtherResource/grub-theme)

  • Gemlion-aurora-penguinis

    Gemlion-aurora-penguinis

  • Sleek

    • Sleek_theme-bigSur

      Sleek_theme-bigSur

    • Sleek_theme-white

      Sleek_theme-white

    • Sleek_theme-dark

      Sleek_theme-dark

  • Bigsur

    BigSur GRUB Theme

下面的例子将展示如何使用 GRUB 包里面的 Starfield 主题:

编辑 /etc/default/grub

1
GRUB_THEME="/usr/share/grub/themes/starfield/theme.txt"

需要重新生成#生成主配置文件) grub.cfg 来让修改起作用。如果配置成功的话,在重生成配置过程中,会在终端里出现 Found theme: /usr/share/grub/themes/starfield/theme.txt

一旦使用了主题,你设置的背景图像通常就不起作用了。

关于主题制作可以参见这里:

设置帧缓冲分辨率

GRUB 既可以为自己,也可以为内核设定帧缓冲。现在已经不使用老的 vga= 配置了,推荐方法是在 /etc/default/grub 文件中按照下面的例子编辑,来设定宽度(像素)x高度(像素)x颜色深度

1
2
GRUB_GFXMODE=1024x768x32
GRUB_GFXPAYLOAD_LINUX=keep

可以指定多种分辨率,包括默认的 auto,所以建议你编辑成这个样:GRUB_GFXMODE=<心仪的分辨率>,<后备分辨率比如 1024x768>,auto。更多信息请见 GRUB gfxmode 文档gfxpayload 属性可以确保内核也保持该分辨率。

注意:

  • 只有显卡通过 VESA BIOS 拓展支持的模式才能用。要查看所支持的模式列表,安装 hwinfo 然后以 root 权限运行 hwinfo --framebuffer。或者进入 GRUB 命令行运行 videoinfo 命令。
  • 早期版本的 NVIDIA 专有驱动(使用显卡 GeForce GTX 970,驱动 nvidia 370 进行了测试)支持的 GRUB_GFXMODE 格式为 *<宽>*x*<高>*-*<色深>*(例如 1920x1200-24,而不是 1920x1200x24)。这应该不会影响新的显卡和驱动。使用比较新的驱动的 Pascal 显卡(以 GeForce GTX 1060 显卡和 nvidia 381.22 驱动测试)没法使用上文建议的格式,而且会引发严重的问题,包括但不限于系统崩溃以及 hard lock。当前的驱动和显卡最好使用标准的 *<width>*x*<height>*x*<depth>* 格式来配置 GRUB_GFXMODE
  • 确保在修改完后运行 grub-mkconfig -o /boot/grub/grub.cfg

这种方法不管用的话,可以试试老的 vga= 方法。将它添加到 /etc/default/grub 文件中的 "GRUB_CMDLINE_LINUX_DEFAULT=" 一行就行了。比如 "GRUB_CMDLINE_LINUX_DEFAULT="quiet splash vga=792" 可以将系统的分辨率设定为 1024x768

915resolution 破解

有些时候,Intel 显卡无法通过 # hwinfo --framebuffervbeinfo 显示你需要的分辨率。这种情况下,你可以使用 915resolution 破解。这种破解会临时性的修改显卡 BIOS 来添加所需的分辨率。详情请参考915resolution 主页。这个包可以在这里找到:915resolutionAUR

首先,找一个你想要修改的视频模式。为此需要在 GRUB 命令行模式下运行:

1
2
3
4
5
sh:grub> 915resolution -l
Intel 800/900 Series VBIOS Hack : version 0.5.3
[...]
Mode 30 : 640x480, 8 bits/pixel
[...]

然后,使用 1440x900 分辨率覆盖 Mode 30

1
2
3
4
5
/etc/grub.d/00_header
[...]
915resolution 30 1440 900 # 添加这行
set gfxmode=${GRUB_GFXMODE}
[...]

最后按照之前描述的方式设置 GRUB_GFXMODE,再重新生成 GRUB 配置文件,重启并测试是否生效。

背景图像和点阵字体

GRUB 原生支持设置背景图像和 pf2 格式的点阵字体。grub 包中包含了 unifont 字体,名为unicode.pf2,(也有可能只包含名为 ascii.pf2 的ASCII字符字体)。

在载入正确的模块之后,GRUB 支持的图像格式有 tga, png 和 jpeg。所支持的最大图像分辨率跟硬件有关。

请确保你已经设定了合适的帧缓冲分辨率/Tipsand_tricks(简体中文)#设置帧缓冲分辨率)。

按如下方式编辑 /etc/default/grub

1
2
3
GRUB_BACKGROUND="/boot/grub/myimage"
#GRUB_THEME="/path/to/gfxtheme"
GRUB_FONT="/path/to/font.pf2"

注意: 如果你将 GRUB 安装在单独的分区上,grub.cfg 文件中会自动将 /boot/grub/myimage 改成 /grub/myimage

需要重新生成#生成主配置文件) grub.cfg 来让修改起作用。如果成功添加了背景图片,用户会在运行命令的终端中看到 "Found background image..."。如果句话没有出现,你设定的图像信息可能没有成功添加进 grub.cfg 文件。

如果图像没有正确显示,执行如下检查:

  • /etc/default/grub 文件中,图像的路径和名字要正确
  • 图像的大小和格式要合适 (tga, png, 8-bit jpg)
  • 图像需要以 RGB 模式存储,而且没有索引
  • /etc/default/grub 文件里面开启了 console 模式
  • 需要执行 grub-mkconfig 命令以将图像信息写入 /boot/grub/grub.cfg 文件
  • grub-mkconfig 脚本不会对 grub.cfg 文件中所写的文件名添加引号,所以要确保这些名字里没有空格
菜单颜色

GRUB 支持设置菜单颜色。可使用的颜色能从 GRUB 手册里面找到。示例如下:

编辑 /etc/default/grub

1
2
GRUB_COLOR_NORMAL="light-blue/black"
GRUB_COLOR_HIGHLIGHT="light-cyan/blue"
隐藏菜单

GRUB 特性之一就是支持隐藏/跳过菜单,可以在需要的时候按 Esc 来取消隐藏/跳过。同时还支持设置是否显示 timeout 计时器。

按照你的想法来编辑 /etc/default/grub。添加下面的几行可以启动这个功能,其中计时器被设定为 5 秒钟,而且可以被用户看到:

1
2
GRUB_TIMEOUT=5
GRUB_TIMEOUT_STYLE='countdown'

GRUB_TIMEOUT 是设置显示菜单前等待几秒。

禁用 framebuffer

使用 NVIDIA 私有驱动的用户可能希望禁用 GRUB 的 framebuffer,因为它会导致驱动错误。

要禁用 framebuffer,只要在 /etc/default/grub 中取消下面这行的注释:

1
GRUB_TERMINAL_OUTPUT=console

如果你想保留 GRUB 的 framebuffer,解决方法是在 GRUB 载入内核前进入文字模式。可以通过在 /etc/default/grub 中进行如下修改:

1
GRUB_GFXPAYLOAD_LINUX=text

添加GRUB启动菜单

  • 方法1: 如果想要添加自定义条目,你可以编辑 /etc/grub.d/40_custom 文件,然后重新生成 /boot/grub/grub.cfg

  • 方法2: 或者你可以创建 /boot/grub/custom.cfg 文件然后把条目添加进这里面。修改 /boot/grub/custom.cfg 文件后不用再运行 grub-mkconfig 程序,因为 /etc/grub.d/40_custom 文件已经在生成的主配置文件中添加了相关的 source 语句来引用 /boot/grub/custom.cfg

提示: /etc/grub.d/40_custom 可以用做创建 /etc/grub.d/*nn*_custom 文件的模板,其中 *nn* 为优先级,规定脚本文件的执行顺序。而脚本文件的执行顺序决定了其所添加的条目在 GRUB 启动菜单中的位置。*nn* 应当比 06 大,以此保证重要的脚本能够优先执行。

如要参考自定义菜单条目的例子,请看#启动菜单条目示例#启动菜单条目示例):

“关机” 菜单项
1
2
3
4
menuentry "System shutdown" {
echo "System shutting down..."
halt
}
“重启” 菜单项
1
2
3
4
menuentry "System restart" {
echo "System rebooting..."
reboot
}
“固件设置” 菜单项(仅限 UEFI)
1
2
3
4
5
if [ ${grub_platform} == "efi" ]; then
menuentry "Firmware setup" {
fwsetup
}
fi
EFI 可执行文件

在启用了 UEFI 模式时,GRUB 可以 chainload 其它 EFI 可执行文件。

提示: 如要让这些启动条目仅在 GRUB 处于 UEFI 模式的时候显示,只需把它们放到下面的 if 语句中:

1
2
3
if [ ${grub_platform} == "efi" ]; then
放入仅 UEFI 显示的启动条目
fi
UEFI Shell

要启动 UEFI Shell#UEFIShell),你可以将它放在 [EFI 系统分区](https://wiki.archlinux.org/index.php/EFI_system_partition(简体中文))的根目录里,然后添加如下菜单条目:

1
2
3
4
5
6
menuentry "UEFI Shell" {
insmod fat
insmod chain
search --no-floppy --set=root --file /shellx64.efi
chainloader /shellx64.efi
}
gdisk

下载 gdisk EFI application 然后复制 gdisk_x64.efi*esp*/EFI/tools/

1
2
3
4
5
6
menuentry "gdisk" {
insmod fat
insmod chain
search --no-floppy --set=root --file /EFI/tools/gdisk_x64.efi
chainloader /EFI/tools/gdisk_x64.efi
}
Chainload 一个 Arch Linux .efi 文件

如果你有一个按照 Secure Boot 或者其他方法生成的 .efi 文件,你可以把它添加到启动菜单里。例如:

1
2
3
4
5
6
menuentry "Arch Linux .efi" {
insmod fat
insmod chain
search --no-floppy --set=root --fs-uuid FILESYSTEM_UUID
chainloader /EFI/arch/vmlinuz.efi
}
多系统启动
Linux

假设另一个发行版位于 sda2

1
2
3
4
5
menuentry "Other Linux" {
set root=(hd0,2)
linux /boot/vmlinuz (add other options here as required)
initrd /boot/initrd.img (if the other kernel uses/needs one)
}

或者让 GRUB 根据 UUIDlabel 查找正确的分区:

1
2
3
4
5
6
7
8
9
10
menuentry "Other Linux" {
# 假设 UUID 为 763A-9CB6
search --no-floppy --set=root --fs-uuid 763A-9CB6

# 按照 label OTHER_LINUX 来搜索(确保分区 label 是精确的)
#search --no-floppy --set=root --label OTHER_LINUX

linux /boot/vmlinuz (按需求在这里添加其他的选项,例如: root=UUID=763A-9CB6 )
initrd /boot/initrd.img (如果其他的内核需要的话)
}
UEFI/GPT 模式下安装的 Windows

这个模式寻找 Windows 的启动加载器的位置,然后当用户选择了相应的菜单条目的时候,通过链式载入的方法在 GRUB 之后加载它。这里主要的任务是找到 EFI 系统分区然后从上面运行启动加载器。

注意: 这个启动项仅在 UEFI 模式下才起作用,而且 Windows 和 UEFI 的位数必须相同。如果 GRUB 是 BIOS 模式,这个方法无效。参考 Dual boot with Windows (简体中文)#Windows UEFI 和 BIOS 启动限制#WindowsUEFIBIOS启动限制) 和 Dual boot with Windows (简体中文)#UEFI / BIOS 启动管理器限制#UEFI/_BIOS启动管理器限制)。

1
2
3
4
5
6
7
8
9
if [ "${grub_platform}" == "efi" ]; then
menuentry "Microsoft Windows Vista/7/8/8.1 UEFI/GPT" {
insmod part_gpt
insmod fat
insmod chain
search --no-floppy --fs-uuid --set=root $hints_string $fs_uuid
chainloader /EFI/Microsoft/Boot/bootmgfw.efi
}
fi

其中 $hints_string$fs_uuid 由下述两个命令得到。

$fs_uuid 命令检测 EFI 系统分区的 UUID:

1
2
# grub-probe --target=fs_uuid esp/EFI/Microsoft/Boot/bootmgfw.efi
1ce5-7f28

或者你可以(以 root 身份)运行 blkid 然后从结果中找到 EFI 系统分区的 UUID。

$hints_string 命令可以确定 EFI 系统分区的位置,在当前的例子中是 harddrive 0:

1
2
# grub-probe --target=hints_string esp/EFI/Microsoft/Boot/bootmgfw.efi
--hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1

这两个命令都是假设 Windows 使用的 ESP 是挂载在$esp上的。当然,Windows的 EFI 文件路径可能有变,因为这就是Windows….

BIOS/MBR 模式下安装的 Windows

注意: GRUB 支持直接启动 bootmgr,如今启动 BIOS/MBR 模式下安装的 Windows 时不再需要链式加载分区启动扇区了。

警告: bootmgr 位于系统分区(system partition),而不是 Windows 系统所在的分区(通常为 C: 盘)。系统分区的文件系统标签#by-label) 是 System Reserved 或者 SYSTEM 而且这个分区的容量只有大概 100 到 549 MB。详情参考 Wikipedia:System partition and boot partition

本节假设你的 Windows 分区是 /dev/sda1。如果分区不同,需要对每一处 hd0,msdos1 进行修改。

注意: 这些菜单条目仅在 BIOS 启动模式下可用,不能在 UEFI 模式下安装的 GRUB 上使用。参考 Dual boot with Windows (简体中文)#Windows UEFI 和 BIOS 启动限制#WindowsUEFIBIOS启动限制) 和 Dual boot with Windows (简体中文)#UEFI / BIOS 启动管理器限制#UEFI/_BIOS启动管理器限制)。

在所有例子里,*XXXXXXXXXXXXXXXX*是指文件系统的 UUID,可以通过 lsblk --fs 命令得到。

对于 Windows Vista/7/8/8.1/10:

1
2
3
4
5
6
7
8
9
if [ "${grub_platform}" == "pc" ]; then
menuentry "Microsoft Windows Vista/7/8/8.1/10 BIOS/MBR" {
insmod part_msdos
insmod ntfs
insmod ntldr
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 XXXXXXXXXXXXXXXX
ntldr /bootmgr
}
fi

对于 Windows XP:

1
2
3
4
5
6
7
8
9
if [ "${grub_platform}" == "pc" ]; then
menuentry "Microsoft Windows XP" {
insmod part_msdos
insmod ntfs
insmod ntldr
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 XXXXXXXXXXXXXXXX
ntldr /ntldr
}
fi

更多引导设备、方式请参见:

取消子菜单

如果你安装了多个内核,比如说 linux 和 linux-lts,那么 grub-mkconfig 默认会把他们分成一组建立一个子菜单。如果你不想这样,可以在 /etc/default/grub 文件里添加下面这行来回到仅有一个菜单的情形:

1
GRUB_DISABLE_SUBMENU=y

调用之前的启动条目

GRUB 能够记住你最近一次使用的启动项,并且在下次启动时将其作为默认项。当你使用多个内核或操作系统时(比如当前的 Arch 和一个用来做后备选项的 LTS 内核),这个特性很有用。要开启这个功能,编辑 /etc/default/grub 中的 GRUB_DEFAULT 选项:

1
GRUB_DEFAULT=saved

上面的命令会告诉 GRUB 使用记住的启动项为默认启动项。要想让 GRUB 记住当前选择的启动项,将下面的行添加到 /etc/default/grub

1
GRUB_SAVEDEFAULT=true

仅当 /boot 不是 btrfs 文件系统的时候才能用,因为 GRUB 没法对 btrfs 进行写入操作。但它会生成一个容易误导人的错误信息:”sparse file not allowed. Press any key to continue.”

注意: 手动添加启动项到 /etc/grub.d/40_custom/boot/grub/custom.cfg中,比如添加 Windows 启动项,需要先添加savedefault选项。

修改默认菜单条目

可以通过修改 /etc/default/grub 中的 GRUB_DEFAULT 值来改变默认启动项:

使用菜单标题:

1
GRUB_DEFAULT='Advanced options for Arch Linux>Arch Linux, with Linux linux'

使用数字编号:

1
GRUB_DEFAULT="1>2"

GRUB 启动项序号从 0 开始计数,0 代表第一个启动项,也是上述选项的默认值,1 表示第二个启动项,以此类推。主菜单和子菜单项之间用 > 隔开。

上面的例子启动的是主菜单项 ‘Advanced options for Arch Linux’ 下子菜单的第三项。

自动启动非默认启动条目(仅一次)

如果你想在下一次启动的时候启动一个非默认的启动项,命令 grub-reboot 非常有用。当系统下一次启动时,GRUB 会自动载入这个命令后的第一个参数所指的那个启动项,而以后再次启动时,GRUB 会回到正常状态加载默认条目。这样就不用修改配置文件或者在启动时进行手动选择了。

注意: 这个功能需要在 /etc/default/grub 中设定 GRUB_DEFAULT=saved,然后重新生成grub.cfg;或者在手动生成的 grub.cfg 中, 使用 set default="${saved_entry}"

演奏一曲——酷吗?

通过修改 GRUB_INIT_TUNE 变量,你可以在启动时让 PC-speaker 演奏曲子。比如要演奏柏辽兹《幻想交响曲》“妖魔夜宴”乐章片段(大管部分),你可以添加下面的设置:

1
GRUB_INIT_TUNE="312 262 3 247 3 262 3 220 3 247 3 196 3 220 3 220 3 262 3 262 3 294 3 262 3 247 3 220 3 196 3 247 3 262 3 247 5 220 1 220 5"

更多相关信息可以查看 info grub -n play

关于开机音乐更多信息:

From:https://itectec.com/ubuntu/ubuntu-play-a-sound-before-or-after-grub-loads/

现成乐谱
  • Mario Bros. Mushroom Powerup: 1750 523 1 392 1 523 1 659 1 784 1 1047 1 784 1 415 1 523 1 622 1 831 1 622 1 831 1 1046 1 1244 1 1661 1 1244 1 466 1 587 1 698 1 932 1 1195 1 1397 1 1865 1 1397 1
  • Star Wars’ Imperial Death March: 480 440 4 440 4 440 4 349 3 523 1 440 4 349 3 523 1 440 8 659 4 659 4 659 4 698 3 523 1 415 4 349 3 523 1 440 8
  • xiè-jìléi’s tune (ascending): 2000 400 4 0 1 500 4 0 1 600 4 0 1 800 6
  • Adams’s tune (rington-like to me): 480 220 1 277 1 330 1 440 1 185 1 220 1 277 1 370 1 294 1 370 1 440 1 587 1 330 1 415 1 494 1 659 1
  • 更多
了解曲调

语法为: GRUB_INIT_TUNE="tempo [pitch1 duration1] [pitch2 duration2] ..."

速度是所有音符持续时间的基础。60给出1秒的基数,120给出半秒的基数,依此类推。音调为Hz。将音调设置为0即可产生静止。

来源:grub文档,grub play命令文档(同一页)。

预览/测试音乐

如果您想测试音调:安装sox并使用该ubuntuforum.org线程中的脚本(我稍作修改以删除警告):

平淡无奇的音乐
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/dash

if [ $# -lt 3 ]; then
echo "Usage: $0 tempo freq dur [freq dur freq dur...]" >&2
exit 1
fi

tempo=$1; shift

tmpdir=$(mktemp -d)

while [ -n "$*" ]; do
freq=$1; shift
dur=$1; shift
dur=$(echo "$dur*(60/$tempo)"|bc -l)
sox -e mu-law -r 8000 -n -t raw - synth $dur sine $freq >>$tmpdir/grubtune.ul 2> /dev/null
done

play -q -c1 -r 8000 $tmpdir/grubtune.ul

rm -r $tmpdir

使它可执行 chmod +x grub-playtune

使用示例:

1
grub-playtune 2000 400 4 0 1 500 4 0 1 600 4 0 1 800 6
音符的频率

一个基于python3的脚本来计算音符的频率:

音调
1
2
3
#!/bin/bash

python3 -c "print(*(int(0.5 + 440 * 2 ** (note/12)) for note in (${*/%/,})))"

使用示例:

1
2
3
4
5
6
7
8
$ pitch 0        # gives you A_4
440
$ pitch 2 # gives you B_4
494
$ pitch -2 # gives you G_3
392
$ pitch -12 0 12 # gives you A_3, A_4 and A_5
220 440 880

频率表

这里有一个。也可以使用上面的脚本生成它,如下所示:

1
2
3
4
5
6
$ pitch {-12..0} # A_3 to A_4
220 233 247 262 277 294 311 330 349 370 392 415 440
$ pitch {0..12} # A_4 to A_5
440 466 494 523 554 587 622 659 698 740 784 831 880
$ pitch {12..24} # A_5 to A_6
880 932 988 1047 1109 1175 1245 1319 1397 1480 1568 1661 1760

加密的GRUB —— 密码保护GRUB菜单,或者仅防止编辑(推荐)

GRUB 配置文件组成结构

注意:/etc/grub.d/文件夹中的文件如果无执行权限,相当于无效

  • /boot/grub/grub.cfg 负责直接指导 GRUB 运行的配置文件(一般不编辑)。
  • grub-mkconfig 负责生成上述 grub.cfg 配置文件的程序。
  • /etc/grub.d/ 执行上述 grub-mkconfig 时使用的一系列 shell 脚本(实现高级功能)。
  • /etc/default/grub 控制上述 grub-mkconfig 执行时的行为的配置文件(简单功能)。
1
2
3
4
5
6
例如:
/etc/default/grub
可以看到/etc/default/grub文件里有GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet idle=halt biosdevname=0 net.ifnames=0 console=tty0 console=ttyS0,115200n8 noibrs nvme_core.io_timeout=4294967295 nvme_core.admin_timeout=4294967295"这样一行,rhgb表示图形化启动,启动界面有进度条,quiet表示静默安装,只打印必要的开机信息。

The *superuser/user* information and password do not *have* to be contained in the */etc/grub.d/00_header* file. The information can be placed in any */etc/grub.d* file as long as that file is incorporated into *grub.cfg*. The user may prefer to enter this data into a custom file, such as */etc/grub.d/40_custom* so it is not overwritten should the Grub package be updated. If placing the information in a custom file, do *not* include the "cat << EOF" and "EOF" lines as the content is automatically added from these files.
超级用户/用户*信息和密码*不*包含在*/etc/grub.d/00_header* 文件中。 该信息可以放置在任何 */etc/grub.d* 文件中,只要该文件合并到 *grub.cfg* 中即可。 用户可能更愿意将此数据输入到自定义文件中,例如 */etc/grub.d/40_custom*,这样即使 Grub 软件包更新,它也不会被覆盖。 如果将信息放入自定义文件中,请勿*包含“cat << EOF”和“EOF”行,因为内容是从这些文件中自动添加的。
用密码保护 GRUB 菜单

警告: 如果有人能对你的机器进行物理上的访问,而且可以使用 Live USB 或磁盘启动(例如 BIOS 允许从外接磁盘启动),而 /boot 又处于一个没有加密的分区上面,那他就可以非常简单地通过编辑 GRUB 设置文件来绕过下面的这些。参考GRUB (简体中文)#/boot 加密#/boot加密)和[Security (简体中文)#磁盘加密](https://wiki.archlinux.org/index.php/Security(简体中文)#磁盘加密)。

如果你想禁止其他人改变启动参数或者使用 GRUB 命令行,可以给 GRUB 的配置文件关联一个用户名/密码。只需 运行 grub-mkpasswd-pbkdf2,输入密码然后确认:

1
2
3
4
5
6
7
grub-mkpasswd-pbkdf2
[...]
Your PBKDF2 is grub.pbkdf2.sha512.10000.C8ABD3E93C4DFC83138B0C7A3D719BC650E6234310DA069E6FDB0DD4156313DA3D0D9BFFC2846C21D5A2DDA515114CF6378F8A064C94198D0618E70D23717E82.509BFA8A4217EAD0B33C87432524C0B6B64B34FBAD22D3E6E6874D9B101996C5F98AB1746FE7C7199147ECF4ABD8661C222EEEDB7D14A843261FFF2C07B1269A

输入口令:???????
重新输入口令:
您的密码的 PBKDF2 散列为 grub.pbkdf2.sha512.10000.23326FAA32B59868779E3CE14090E6F247C841AE0A678F1A55FACC0B133853A2357F5845E88040E5694D0DDE055391E9BC659F3290AF88ACE4B0BE224764B4BC.42F1758D8C127A69EED3CB9A762F92461C4D6C7F027B8853873BC0EEDC0E73072348C4A5CAD84349037FE4B1D0BB9FEE8F93E04649C530285FFDA29E5C777EC7

然后将下面的内容添加到 /etc/grub.d/40_custom

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
格式:
/etc/grub.d/40_custom
set superusers="用户名"
password_pbkdf2 用户名 <密码>

e.g.:
#!/bin/sh
# /etc/grub.d/40_custom
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the menu entries you want to add after this comment. Be careful not to change the 'exec
# tail' line above.

set superusers="admin"
password_pbkdf2 admin grub.pbkdf2.sha512.10000.23326FAA32B59868779E3CE14090E6F247C841AE0A678F1A55FACC0B133853A2357F5845E88040E5694D0DDE055391E9BC659F3290AF88ACE4B0BE224764B4BC.42F1758D8C127A69EED3CB9A762F92461C4D6C7F027B8853873BC0EEDC0E73072348C4A5CAD84349037FE4B1D0BB9FEE8F93E04649C530285FFDA29E5C777EC7

-----------------------------------分割----------------------------------------

#!/bin/sh
# /etc/grub.d/41_custom
cat <<EOF
if [ -f \${config_directory}/custom.cfg ]; then
source \${config_directory}/custom.cfg
elif [ -z "\${config_directory}" -a -f \$prefix/custom.cfg ]; then
source \$prefix/custom.cfg
fi
EOF

这里的 <密码> 是由 grub-mkpasswd_pbkdf2 所生成的那个字符串。

然后重新生成主配置文件,现在你的 GRUB 命令行、启动参数和所有的启动条目都得到保护了。

可以参考 GRUB 手册中的 “Security” 部分来将设置放宽或者针对多用户进行更复杂的定制。

通过以上操作,GRUB的所有菜单项目全部都要输入密码才能使用(包括进入、启动、编辑、命令行)

只针对编辑 GRUB 和控制台选项进行密码保护

https://superuser.com/questions/1001810/grub-menu-edit-protection-only
http://daniel-lange.com/archives/75-Securing-the-grub-boot-loader.html
https://help.ubuntu.com/community/Grub2/Passwords

对一个菜单条目添加 --unrestricted 选项将会允许所有的用户启动这个操作系统,但却不能修改这个条目,也不能进入 GRUB 命令行控制台。 只有超级用户或者由 --user 开关指定的用户才能修改这个菜单条目。

1
2
/boot/grub/grub.cfg
menuentry 'Arch Linux' --unrestricted --class arch --class gnu-linux --class os ...

注意:本章节存在争议! The factual accuracy of this article or section is disputed.

Reason: /etc/grub.d/10_linux 文件不应该被手工编辑,每次升级 grub 包都会自动把它覆盖掉。 (Discuss in Talk:GRUB (简体中文)/Tips and tricks (简体中文)#/Tipsand_tricks(简体中文)))

要给 Linux 启动条目添加 --unrestricted,可以修改 /etc/grub.d/10_linux 文件开头的 CLASS 变量。

1
2
/etc/grub.d/10_linux
CLASS="--class gnu-linux --class gnu --class os --unrestricted"

注意:我的实际操作(成功测试):仅加密编辑模式、命令行模式,启动可以直接启动,包括Windows系统引导

1
2
3
4
5
6
7
8
编辑/etc/grub.d/10_linux文件(Linux相关入口)和/etc/grub.d/30_os-prober(Windows系统等的相关入口)
修改CLASS变量,在末尾加上--unrestricted

/etc/grub.d/10_linux
CLASS="--class gnu-linux --class gnu --class os --unrestricted"

/etc/grub.d/30_os-prober
CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g' --unrestricted)"

在没有按着 SHIFT 键时隐藏 GRUB 界面

为了获取更快的启动速度,而不用等 GRUB 倒计时,可以命令 GRUB 在启动时隐藏目录,仅在 Shift 被按住的时候才显示。

将如下行添加到/etc/default/grub来启动这个功能:

1
GRUB_FORCE_HIDDEN_MENU="true"

然后创建连接里的文件[1],给它可执行权限,然后重新生成主配置文件:

1
2
# chmod a+x /etc/grub.d/31_hold_shift
# grub-mkconfig -o /boot/grub/grub.cfg

注意: 这个设置使用 keystatus 来检测按键事件,所以可能在某些机器上不能用。

将 UUID 和基础脚本结合使用

如果你想要使用 UUID 来避免不可靠的 BIOS 设备命名或者正在研究 GRUB 语法,这里有个使用了 UUID 的启动菜单项,和一个让 GRUB 使用你系统中正确的磁盘分区的小脚本。如果你想要将其移植到自己的系统上,只需要把 UUID 改成你的系统上的就行了。这个例子假设系统的 boot 和 root 文件系统是在不同的分区上,如果你还有其他分区,请相应地修改 GRUB 设置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
menuentry "Arch Linux 64" {
# Set the UUIDs for your boot and root partition respectively
set the_boot_uuid=ece0448f-bb08-486d-9864-ac3271bd8d07
set the_root_uuid=c55da16f-e2af-4603-9e0b-03f5f565ec4a

# (Note: This may be the same as your boot partition)

# Get the boot/root devices and set them in the root and grub_boot variables
search --fs-uuid $the_root_uuid --set=root
search --fs-uuid $the_boot_uuid --set=grub_boot

# Check to see if boot and root are equal.
# If they are, then append /boot to $grub_boot (Since $grub_boot is actually the root partition)
if [ $the_boot_uuid == $the_root_uuid ] ; then
set grub_boot=($grub_boot)/boot
else
set grub_boot=($grub_boot)
fi

# $grub_boot now points to the correct location, so the following will properly find the kernel and initrd
linux $grub_boot/vmlinuz-linux root=/dev/disk/by-uuid/$the_root_uuid ro
initrd $grub_boot/initramfs-linux.img
}

探测其他操作系统(os-prober)

想要让 grub-mkconfig 探测其他已经安装的系统并自动把他们添加到启动菜单中,安装 软件包 os-prober挂载#挂载文件系统) 包含其它系统的磁盘分区。然后重新运行 grub-mkconfig。

注意:Debian 12开始,请务必保证/etc/default/grub文件中GRUB_DISABLE_OS_PROBER=false

MS Windows

os-prober 通常能自动发现包含 Windows 的分区。当然在载入默认的 Linux 驱动的情况下,NTFS 分区也不是总能够被探测到。如果 GRUB 没能发现它,尝试安装 ntfs-3g,然后重新挂载这个分区再试一次。

加密的 Windows 分区需要在解密之后才能挂载。对于 BitLocker,可以使用 dislockerAUR。这足够 os-prober 来添加正确的启动条目了。

额外的参数

如想为 Linux 镜像添加额外的参数,你可以在 /etc/default/grub 中设置 GRUB_CMDLINE_LINUXGRUB_CMDLINE_LINUX_DEFAULT 变量。生成普通启动项时,这两个参数的值会合并在一起传给内核。生成 recovery 启动项时, 仅使用 GRUB_CMDLINE_LINUX 参数。

两个参数不是一定要一起用。例如要系统支持休眠后恢复,可以使用 GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=*uuid-of-swap-partition* quiet",其中 *uuid-of-swap-partition* 是你的交换分区的 UUID#by-uuid)。这样在生成 recovery 启动项时,将不会启用 resume 功能,也不会有 quiet 参数来省略启动时的内核信息。而其他的普通启动项会包含它们。

grub-mkconfig 默认使用根文件系统的 UUID,要禁用此设置,取消 GRUB_DISABLE_LINUX_UUID=true 前的注释。

要生成 GRUB recovery 启动项,需要确保在 /etc/default/grubGRUB_DISABLE_RECOVERY 没有设置为 true

更多信息请参考Kernel parameters (简体中文))。

移除MBR GRUB

在迁移到 GPT/UEFI 后,你可能想要移除 MBR 启动代码),只需 使用 dd:

1
# dd if=/dev/zero of=/dev/sdX bs=440 count=1

LVM

Notes: grub-mkconfig 能自动检测是否需要 lvm 模块,没有必要专门在GRUB_PRELOAD_MODULES 中标明。将警告移动到#安装#安装) & #Installation_2#Installation2) 或创建一个Known issues section 并在里面写明。 (Discuss in [Talk:GRUB (简体中文)#](https://wiki.archlinux.org/index.php/Talk:GRUB(简体中文)))

警告: GRUB 不支持 thin-provisioned 逻辑卷。

如果你的 /boot 或者 / 分区使用了 LVM,确保 lvm 模块已经预先加载好。

1
2
/etc/default/grub
GRUB_PRELOAD_MODULES="... lvm"

RAID阵列

Notes: grub-mkconfig 能自动检测是否需要 mdraid09 以及 mdraid1x 模块,不需要在 GRUB_PRELOAD_MODULES 里面标明。将两个 grub-install 写到一个注意事项里,然后把它移动到#安装#安装);将那些 set root 语句转移到 #定制 grub.cfg#定制grub.cfg)。 (Discuss in [Talk:GRUB (简体中文)#](https://wiki.archlinux.org/index.php/Talk:GRUB(简体中文)))

GRUB 可以很方便地操作 RAID) 卷,你只需加载 GRUB 模块 mdraid09 或者 mdraid1x 就可以像其他卷一样进行操作了。

1
2
/etc/default/grub
GRUB_PRELOAD_MODULES="... mdraid09 mdraid1x"

例如 /dev/md0 写成:

1
set root=(md/0)

而 RAID 卷上的分区(如 /dev/md0p1)则是:

1
set root=(md/0,1)

如要在 /boot 分区使用 RAID1 时(或者 /boot 位于使用了 RAID1 的根分区之中)安装 GRUB,对于 BIOS 系统,直接在各个驱动器上运行 grub-install 即可,就像这样:

1
2
# grub-install --target=i386-pc --debug /dev/sda
# grub-install --target=i386-pc --debug /dev/sdb

上例中 /boot 所在的 RAID 1 序列位于 /dev/sda/dev/sdb 上。

注意: GRUB 支持从 Btrfs RAID 0/1/10 启动,但 不支持 RAID 5/6。对 RAID 5/6,你可以使用 mdadm,这个 GRUB 是支持的。

/boot 加密

GRUB 还专门支持从加密的 /boot 启动。这需要解锁一个 LUKS 块设备,来读取配置文件以及载入 initramfs#initramfs) 和内核)。这个选项试图解决未加密的 boot 分区问题。

注意: /boot 不需要 专门放到一个单独的分区,它也可以就留在系统的根目录 / 下面。

警告: GRUB 不支持 LUKS2 headers,参见 GRUB bug #55093。当使用 cryptsetup luksFormat 创建加密分区时,一定要加上 --type luks1

要启用这个功能,正常使用 LUKS/boot 所在的分区加密,然后在 /etc/default/grub 中添加如下选项:

1
2
/etc/default/grub
GRUB_ENABLE_CRYPTODISK=y

grub-install 使用这个选项来生成 core.img,所以在修改这个选项之后要重新安装 grub#安装)。

如果没有进一步的修改,你需要两次输入一个密码:第一次是为了让 GRUB 在启动伊始解锁 /boot 的挂载点,第二次是在 initramfs 的要求下解锁根文件系统。你可以用 keyfile 来避免密码输入过程。

警告:

  • 如果你想要 生成主配置文件#生成主配置文件),确保 /boot 已经挂载好了。
  • 为了进行与 /boot 的挂载点有关的系统更新,确保在进行更新之前已经对加密的 /boot 进行了解锁和挂载。如果使用了独立的 /boot 分区,这个可以通过使用 crypttab 和一个 keyfile 在启动的时候自动完成。

注意:

  • 如果你使用了特别的键盘映射,默认安装的 GRUB 是不知道的。这关系到如何输入密码来解锁 LUKS 块设备。
  • 如果你遇到问题没法显示输入密码的界面(与 cryptouuid, cryptodisk相关的错误,或者 “device not found”),可以试着重新安装 GRUB,并在 grub-install 命令的尾部加上 --modules="part_gpt part_msdos"

提示: 你可以使用 pacman hooks 来在升级时涉及到 /boot 中的文件的时候自动挂载它。

定制 grub.cfg

Reason: 添加指导如何编写一个定制的 /boot/grub/grub.cfgUser:Eschwartz/Grub 中有一个草稿可以查阅。 (Discuss in Talk:GRUB (简体中文)#Manually generate grub.cfg#Manually_generate_grub.cfg))

这一节讲述如何在 /boot/grub/grub.cfg 中手工创建 GRUB 启动条目,而非使用 grub-mkconfig。

基础的 GRUB 配置文件使用如下的设置:

  • (hd*X*,*Y*) 为磁盘 X 上的分区 Y,分区编号从 1 开始,磁盘编号从 0 开始。
  • set default=*N* 为在用户选择时间内没有进行选择时的默认启动条目。
  • set timeout=*M* 即在使用默认条目启动前,等待用户自行选择的时间为 M 秒。
  • menuentry "title" {entry options} 为一个标题为 title 的启动条目。
  • set root=(hd*X*,*Y*) 设置 \boot 分区,即内核和 GRUB 模块存储的位置。(\boot 不一定要位于一个独立的分区,可能是根分区(/) 下面的一个目录。)

GNOME桌面环境

调整GNOME屏幕分辨率 - DPI

gsettings set org.gnome.desktop.interface scaling-factor 2

让Debian GNOME支持超级用户登录——不建议

1
2
3
4
5
6
vi /etc/gdm3/daemon.conf
# 在[security]下添加:
AllowRoot = true
vi /etc/pam.d/gdm-password
# 注释掉:
# auth required pam_succeed_if.so user != root quiet_success

备份GNOME配置

可以使用dconf

备份:dconf dump / > backup

重置:dconf reset / -f

导入:dconf load < backup

Desktop——添加GNOME Application列表

  • 添加.desktop文件到/usr/share/applications/或者~/.local/applications
  • 模板:
1
2
3
4
5
6
7
8
9
10
11
[Desktop Entry]
Encoding=UTF-8
Name=
GenericName=
Comment=
Exec=/home/jessie/Prog/Application/
Icon=/home/jessie/Prog/Application/
Terminal=false
Type=Application
Categories=Application;
StartupNotify=false
  • Eclipse的Desktop模板:
1
2
3
4
5
6
7
8
9
10
11
[Desktop Entry]
Encoding=UTF-8
Name=eclipse
GenericName=Eclipse IDE for Java
Comment=Eclipse
Exec=/home/jessie/eclipse/eclipse/eclipse
Icon=/home/jessie/图片/图标-ICO/eclipse.gif
Terminal=false
Type=Application
Categories=Application;
StartupNotify=false

Systemd——创建自己的服务

服务文件通常位于下面三个文件夹中,从上到下,最下面的最重要:
/lib/systemd/system/

/run/systemd/system/

/etc/systemd/system/

systemctl脚本目录:/usr/lib/systemd/
系统服务目录:/usr/lib/systemd/system/
用户服务目录:/usr/lib/systemd/user/

1
2
3
4
5
6
7
8
Unit 文件按照 Systemd 约定,应该被放置指定的三个系统目录之一中。这三个目录是有优先级的,如下所示,越靠上的优先级越高。因此,在三个目录中有同名文件的时候,只有优先级最高的目录里的那个文件会被使用。
/etc/systemd/system:系统或用户自定义的配置文件
/run/systemd/system:软件运行时生成的配置文件
/usr/lib/systemd/system:系统或第三方软件安装时添加的配置文件。
CentOS 7:Unit 文件指向该目录
ubuntu 16:被移到了 /lib/systemd/system

Systemd 默认从目录 /etc/systemd/system/ 读取配置文件。但是,里面存放的大部分文件都是符号链接,指向目录 /usr/lib/systemd/system/,真正的配置文件存放在那个目录。

参考:

https://www.e-learn.cn/topic/3367780

https://www.jianshu.com/p/81aefcbf0f94

所以咱们自己创建的文件放在/lib/systemd/system/中。

/lib/systemd/system/ssh.service服务文件示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=OpenBSD Secure Shell server
After=network.target auditd.service
ConditionPathExists=!/etc/ssh/sshd_not_to_be_run
[Service]
EnvironmentFile=-/etc/default/ssh
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartPreventExitStatus=255
Type=notify
[Install]
WantedBy=multi-user.target
Alias=sshd.service

开始自己创建:

  1. 创建文件:vi ./YourServiceName.service

  2. 编辑文件:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    [Unit]
    Description=自定义的服务,用于开启启动/home/USER/.Templates下的script文件--2019.12.18
    After=network.target
    # 根据上面的配置,在 120 秒的时间间隔内,服务重启次数不能超过 3 次。如果服务崩溃超过五次,将不再允许它启动。
    StartLimitIntervalSec=120
    StartLimitBurst=3

    [Service]
    ExecStart=/home/$USER/.Templates/services/autorun.sh

    Type=forking
    # 独立的tmp目录
    PrivateTmp=True
    # 是否在失败时重启
    Restart=on-failure
    RestartSec=8s
    # 用户
    User=xxx

    [Install]
    WantedBy=multi-user.target
  3. 这里演示的运行脚本:mkdir ~/.Templates/ && mkdir ~/.Templates/services

    vi ~/.Template/services/autorun.sh

    1
    2
    3
    4
    #!/bin/bash
    # 禁止所有IPv6流量
    ip6tables -A INPUT -j DROP
    ip6tables -A OUTPUT -j DROP

    chmod +x ~/.Template/services/autorun.sh

  4. 自行编辑脚本后。将service文件复制到/lib/systemd/system/

    cp YourServiceName.service /lib/systemd/system/

  5. systemctl deamon-reload 就有显示我们自定义的服务了。

Update-alternatives设置软件版本偏好

1
2
3
4
5
6
7
8
9
# 切换默认java:
# 查看java连接 比如在/usr/bin/java
whereis java
# 显示版本
update-alternatives --display java
# 切换版本
update-alternatives --config java
# 添加版本
update-alternatives --install /usr/bin/java java [JAVA 11_HOME] [优先级,比如300]

Grub-Setting修改默认网卡命名规则

wlxxxxxwlan0

vi /etc/default/grub

`GRUB_CMDLINE_LINUX="" 改成 GRUB_CMDLINE_LINUX="net.ifnames=0 biosdevname=0"

然后更新GRUB:

grub-mkconfig -o /boot/grub/grub.cfg

Addgroup禁止某些软件联网的方法

禁止某软件联网,可以新建一个无网络的组,然后让某软件在某用户下运行:

1
2
3
4
5
6
sudo addgroup no-internet
sudo adduser $USER no-internet #我觉得这步不需要
sudo iptables -I OUTPUT 1 -m owner --gid-owner no-internet -j DROP
sudo ip6tables -I OUTPUT 1 -m owner --gid-owner no-internet -j DROP
#Process you don't want to have internet access using sg or sudo -g (execute command as different group ID):
sg no-internet -c "processFullPath args"

SwapFile——Linux交换文件代替交换分区

BTRFS不适用,F2FS、XSF请用dd代替fallocate

创建:

fallocate -l 512M /swapfile

dd if=/dev/zero of=/swapfile bs=1M count=512

设置权限:

chmod 600 /swapfile

格式化:

mkswap /swapfile

启用:

swapon /swapfile

添加fstab自动挂载:

1
/swapfile none swap defaults 0 0

卸载、删除:

1
2
swapoff -a
rm -rf /swapfile

最后更改/etc/fstab

从Debian Buster迁移到Beowulf——一款没有Systemd的发行版

原文:https://www.devuan.org/os/documentation/dev1fanboy/en/buster-to-beowulf

网络配置(可选)

迁移时,您可以选择使用wicd还是手动配置网络。手动配置的优点是不需要dbus或网络管理器。对于远程迁移,您应该始终使用手动网络配置,否则很可能在迁移过程中失去网络访问权限。

使用网络管理器的优点是易于使用并具有GUI界面。此方法应用于不包括wicd安装的迁移说明。

使用wicd网络管理器

您首先需要安装wicd软件包。完整的软件包在这里用于提供gtk界面以及控制台的curses界面。

apt-get install wicd

网络管理器守护程序应在引导时停止并禁用。

service network-manager stop

update-rc.d -f network-manager remove

重新启动wicd守护程序,使其在管理网络中处于活动状态。

service wicd restart

现在,无线用户应该在其桌面环境中从wicd gtk客户端配置其网络。

手动有线网络配置

在较新的Debian发行版中,您将看到对应的直观界面名称,例如,ens3用于安全添加当前界面名称和直观设备名称的行。

请注意,移植后将找不到Debian风格的界面,因此将不会进行配置。

可以通过向interfaces文件添加配置行来管理有线连接。

editor /etc/network/interfaces

——自动网络配置

每当检测到链接时,这将自动配置网络。如有必要,请根据您的接口名称进行调整。

1
2
3
4
5
allow-hotplug eth0
iface eth0 inet dhcp

allow-hotplug ens3
iface ens3 inet dhcp

——静态网络配置

或静态配置网络。

1
2
3
4
5
6
7
8
9
10
11
auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

auto ens3
iface ens3 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

手动无线网络配置

这类似于有线网络,除了您需要提供身份验证详细信息。如果需要自动网络配置,则应使用wicd网络管理器。

编辑接口文件以配置无线网络上的主机。

1
root@debian:~# editor /etc/network/interfaces

调整接口文件以适合您的接口和网络配置。

1
2
3
4
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid myssid
wpa-psk mypassphrase

开始迁移

这些说明仅用于从Debian Buster发行版迁移。当迁移到Beowulf时,说明是针对您所来自的Debian版本的,仅应按照书面说明进行操作。

从Beowulf开始,您将在迁移时丢失网络管理器软件包。此处的解决方案是使用wicd网络管理器,但是如果您喜欢手动网络配置,则需要在继续之前完成此操作。

第一步是将sources.list更改为指向Beowulf存储库。

editor /etc/apt/sources.list

使您的sources.list看起来像所提供的那样。注释掉所有其他行。

1
2
3
4
deb http://deb.devuan.org/merged beowulf main
deb http://deb.devuan.org/merged beowulf-updates main
deb http://deb.devuan.org/merged beowulf-security main
#deb http://deb.devuan.org/merged beowulf-backports main

现在,您必须从Beowulf存储库中更新软件包列表。APT最近的更改意味着不允许这样做,但是我们可以覆盖此行为。

apt-get update --allow-insecure-repositories

现在应该安装Devuan密钥环,以便可以对软件包进行身份验证。

apt-get install devuan-keyring --allow-unauthenticated

再次更新软件包列表,以便从此处开始对软件包进行身份验证。

apt-get update

如果要使用wicd网络管理器,则需要立即安装,否则升级将失败。

apt-get install wicd-gtk

升级您的软件包,以便您具有最新版本。请注意,这不会完成迁移。

apt-get upgrade

完成此操作后,需要安装eudev。请注意,如果您使用的是Gnome,它将被此命令删除,但可以在迁移后再次安装。

apt-get install eudev

已知最后一个命令会导致程序包中断,但是我们将在迁移过程中解决此问题。

apt-get -f install

需要重新启动才能将sysvinit更改为pid1

reboot

现在,您可以正确执行迁移了。

apt-get dist-upgrade

我们已经迁移到Devuan,因此现在不需要与systemd相关的软件包。

apt-get purge systemd libnss-systemd

如果此时您没有台式机,则应立即安装一个。Devuan中的默认值为XFCE。

apt-get install task-xfce-desktop

或者,如果您想继续使用它,可以安装Gnome。

apt-get install task-gnome-desktop

现在,您可以删除迁移过程中孤立的所有软件包,以及从Debian安装中遗留下来的所有不可用的档案。

apt-get autoremove --purge apt-get autoclean

其他(杂记)

Linux压力测试:stress --cpu 4 --io 18 --vm 4 --vm-bytes 7000M --timeout 1m

华为麒麟9908核ARM+银河麒麟ps aux进程

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root 1 0.6 0.1 172068 14148 ? Ss 15:13 0:08 /sbin/init splash
root 2 0.0 0.0 0 0 ? S 15:13 0:00 [kthreadd]
root 3 0.0 0.0 0 0 ? I< 15:13 0:00 [rcu_gp]
root 4 0.0 0.0 0 0 ? I< 15:13 0:00 [rcu_par_gp]
root 6 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/0:0H-wdt_wq]
root 7 0.1 0.0 0 0 ? I 15:13 0:02 [kworker/u16:0-memlat_wq]
root 8 0.0 0.0 0 0 ? I< 15:13 0:00 [mm_percpu_wq]
root 9 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/0]
root 10 0.1 0.0 0 0 ? I 15:13 0:01 [rcu_preempt]
root 11 0.0 0.0 0 0 ? I 15:13 0:00 [rcu_sched]
root 12 0.0 0.0 0 0 ? I 15:13 0:00 [rcu_bh]
root 13 0.0 0.0 0 0 ? S 15:13 0:01 [migration/0]
root 14 0.1 0.0 0 0 ? I 15:13 0:02 [kworker/0:1-events]
root 15 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/0]
root 16 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/1]
root 17 0.0 0.0 0 0 ? S 15:13 0:00 [migration/1]
root 18 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/1]
root 19 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/1:0-events]
root 20 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/1:0H-kblockd]
root 21 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/2]
root 22 0.0 0.0 0 0 ? S 15:13 0:00 [migration/2]
root 23 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/2]
root 25 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/2:0H-events_highpri]
root 26 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/3]
root 27 0.0 0.0 0 0 ? S 15:13 0:00 [migration/3]
root 28 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/3]
root 30 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/3:0H-kblockd]
root 31 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/4]
root 32 0.0 0.0 0 0 ? S 15:13 0:00 [migration/4]
root 33 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/4]
root 35 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/4:0H-kblockd]
root 36 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/5]
root 37 0.0 0.0 0 0 ? S 15:13 0:00 [migration/5]
root 38 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/5]
root 40 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/5:0H-kblockd]
root 41 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/6]
root 42 0.0 0.0 0 0 ? S 15:13 0:00 [migration/6]
root 43 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/6]
root 45 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/6:0H-kblockd]
root 46 0.0 0.0 0 0 ? S 15:13 0:00 [cpuhp/7]
root 47 0.0 0.0 0 0 ? S 15:13 0:00 [migration/7]
root 48 0.0 0.0 0 0 ? S 15:13 0:00 [ksoftirqd/7]
root 50 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/7:0H-kblockd]
root 51 0.0 0.0 0 0 ? S 15:13 0:00 [kdevtmpfs]
root 52 0.0 0.0 0 0 ? I< 15:13 0:00 [netns]
root 53 0.0 0.0 0 0 ? S 15:13 0:00 [rcu_tasks_kthre]
root 55 0.0 0.0 0 0 ? D 15:13 0:00 [bbox_main]
root 57 0.0 0.0 0 0 ? D 15:13 0:00 [bbox_cleartext]
root 58 0.0 0.0 0 0 ? S 15:13 0:00 [kauditd]
root 59 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/7:1-events]
root 60 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-10]
root 61 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-11]
root 62 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-12]
root 63 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-13]
root 64 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-14]
root 65 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-15]
root 66 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-16]
root 67 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-17]
root 68 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-18]
root 69 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-23]
root 70 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-25]
root 71 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-26]
root 72 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-27]
root 73 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-28]
root 74 0.0 0.0 0 0 ? S 15:13 0:00 [mailbox-30]
root 75 0.0 0.0 0 0 ? S 15:13 0:00 [ao-mailbox-0]
root 76 0.0 0.0 0 0 ? S 15:13 0:00 [npu-mailbox-0]
root 77 0.0 0.0 0 0 ? S 15:13 0:00 [npu-mailbox-1]
root 78 0.0 0.0 0 0 ? S 15:13 0:00 [npu-mailbox-2]
root 79 0.0 0.0 0 0 ? S 15:13 0:00 [npu-mailbox-3]
root 81 0.0 0.0 0 0 ? S 15:13 0:00 [oom_reaper]
root 82 0.0 0.0 0 0 ? I< 15:13 0:00 [writeback]
root 83 0.0 0.0 0 0 ? S 15:13 0:00 [kcompactd0]
root 84 0.0 0.0 0 0 ? I< 15:13 0:00 [crypto]
root 85 0.0 0.0 0 0 ? I< 15:13 0:00 [kblockd]
root 86 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/5:1-mm_percpu_wq]
root 88 0.0 0.0 0 0 ? I< 15:13 0:00 [dsm_wq]
root 89 0.0 0.0 0 0 ? I< 15:13 0:00 [ata_sff]
root 90 0.0 0.0 0 0 ? S 15:13 0:00 [spi3]
root 91 0.0 0.0 0 0 ? I< 15:13 0:00 [devfreq_wq]
root 92 0.0 0.0 0 0 ? S 15:13 0:00 [rdr_lpm3_thread]
root 93 0.0 0.0 0 0 ? S 15:13 0:00 [watchdogd]
root 94 0.0 0.0 0 0 ? S 15:13 0:00 [kysec_auth]
root 95 0.0 0.0 0 0 ? I< 15:13 0:00 [slimbus_lost_sy]
root 97 0.0 0.0 0 0 ? I< 15:13 0:00 [rpciod]
root 98 0.7 0.0 0 0 ? I< 15:13 0:09 [kworker/u17:0-kbase_pm_poweroff_wait]
root 99 0.0 0.0 0 0 ? I< 15:13 0:00 [xprtiod]
root 100 0.0 0.0 0 0 ? I< 15:13 0:00 [cfg80211]
root 101 0.0 0.0 0 0 ? S 15:13 0:00 [siqthread/0]
root 102 0.0 0.0 0 0 ? S 15:13 0:00 [ipihelper]
root 103 0.0 0.0 0 0 ? S 15:13 0:00 [agent_rpmb]
root 104 0.0 0.0 0 0 ? S 15:13 0:00 [smc_svc_thread]
root 145 0.4 0.0 0 0 ? S 15:13 0:06 [kswapd0]
root 146 0.0 0.0 0 0 ? S 15:13 0:00 [ecryptfs-kthrea]
root 147 0.0 0.0 0 0 ? I< 15:13 0:00 [nfsiod]
root 148 0.0 0.0 0 0 ? I< 15:13 0:00 [cifsiod]
root 149 0.0 0.0 0 0 ? I< 15:13 0:00 [cifsoplockd]
root 150 0.0 0.0 0 0 ? I< 15:13 0:00 [xfsalloc]
root 151 0.0 0.0 0 0 ? I< 15:13 0:00 [xfs_mru_cache]
root 200 0.0 0.0 0 0 ? I< 15:13 0:00 [kthrotld]
root 201 0.0 0.0 0 0 ? S 15:13 0:00 [irq/125-dwc_dpt]
root 202 0.0 0.0 0 0 ? S 15:13 0:00 [irq/195-hpd_gpi]
root 204 0.0 0.0 0 0 ? I< 15:13 0:00 [pmic-otmp-wq]
root 205 0.0 0.0 0 0 ? I< 15:13 0:00 [pmu-ocp-wq]
root 206 0.0 0.0 0 0 ? S 15:13 0:00 [scsi_eh_0]
root 207 0.0 0.0 0 0 ? I< 15:13 0:00 [scsi_tmf_0]
root 208 0.0 0.0 0 0 ? S 15:13 0:00 [ufs_eh_worker]
root 210 0.1 0.0 0 0 ? I 15:13 0:01 [kworker/u16:3-devfreq_wq]
root 211 0.1 0.0 0 0 ? I 15:13 0:01 [kworker/u16:4-devfreq_wq]
root 212 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/6:2-pm]
root 214 0.0 0.0 0 0 ? S 15:13 0:00 [scsi_eh_1]
root 215 0.0 0.0 0 0 ? I< 15:13 0:00 [scsi_tmf_1]
root 216 0.0 0.0 0 0 ? S 15:13 0:00 [scsi_eh_2]
root 217 0.0 0.0 0 0 ? I< 15:13 0:00 [scsi_tmf_2]
root 218 0.0 0.0 0 0 ? S 15:13 0:00 [scsi_eh_3]
root 219 0.0 0.0 0 0 ? I< 15:13 0:00 [scsi_tmf_3]
root 220 0.0 0.0 0 0 ? D 15:13 0:00 [long_powerkey]
root 221 0.0 0.0 0 0 ? I< 15:13 0:00 [wdt_wq]
root 222 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/0:1H-kblockd]
root 224 0.0 0.0 0 0 ? I< 15:13 0:00 [dw-mci-card/2]
root 225 0.0 0.0 0 0 ? S 15:13 0:00 [ion_system_heap]
root 226 0.0 0.0 0 0 ? I< 15:13 0:00 [memlat_wq]
root 227 0.0 0.0 0 0 ? I< 15:13 0:00 [hwlog_wq]
root 228 0.0 0.0 0 0 ? D 15:13 0:00 [clear_dfx_happe]
root 230 0.0 0.0 0 0 ? S 15:13 0:00 [bbox_diaginfo]
root 231 0.0 0.0 0 0 ? S 15:13 0:00 [bbox_lpmcu_diag]
root 232 0.0 0.0 0 0 ? S 15:13 0:00 [rdr_codec_hifi_]
root 233 0.0 0.0 0 0 ? S 15:13 0:00 [rdr_codec_hifi_]
root 234 0.0 0.0 0 0 ? D 15:13 0:00 [modemddrc_emit]
root 235 0.0 0.0 0 0 ? S 15:13 0:00 [hisi-drg]
root 236 0.0 0.0 0 0 ? S 15:13 0:00 [irq/151-asp_dma]
root 238 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/3:1-events]
root 239 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/2:1-rcu_gp]
root 240 0.0 0.0 0 0 ? S 15:13 0:00 [irq/194-ffb0400]
root 241 0.0 0.0 0 0 ? I< 15:13 0:00 [ipv6_addrconf]
root 242 0.0 0.0 0 0 ? S< 15:13 0:00 [krfcommd]
root 243 0.0 0.0 0 0 ? S 15:13 0:00 [core_ctl/0]
root 244 0.0 0.0 0 0 ? S 15:13 0:00 [core_ctl/4]
root 245 0.0 0.0 0 0 ? S 15:13 0:00 [core_ctl/6]
root 250 0.0 0.0 0 0 ? S 15:13 0:00 [kysec_notify_th]
root 251 0.0 0.0 0 0 ? S 15:13 0:00 [hisi_smmu_evt.1]
root 252 0.0 0.0 0 0 ? S 15:13 0:00 [hisi_smmu_evt.0]
root 253 0.0 0.0 0 0 ? I< 15:13 0:00 [crtc0_ldi_under]
root 254 0.0 0.0 0 0 ? I< 15:13 0:00 [crtc1_ldi_under]
root 255 0.0 0.0 0 0 ? S 15:13 0:00 [irq/259-edp_bri]
root 256 0.0 0.0 0 0 ? I< 15:13 0:00 [tca_wq]
root 257 0.0 0.0 0 0 ? S 15:13 0:00 [thermal_hotplug]
root 258 0.0 0.0 0 0 ? S 15:13 0:00 [irq/84-faultirq]
root 259 0.0 0.0 0 0 ? S 15:13 0:00 [irq/83-errirq]
root 260 0.0 0.0 0 0 ? I< 15:13 0:00 [noc_err_handle_]
root 261 0.0 0.0 0 0 ? S 15:13 0:00 [rpmb_task]
root 262 0.0 0.0 0 0 ? S 15:13 0:00 [pll_delayed_rel]
root 263 0.0 0.0 0 0 ? I< 15:13 0:00 [hi64xx_micbias_]
root 264 0.0 0.0 0 0 ? S 15:13 0:00 [irq/260-LineIn]
root 265 0.0 0.0 0 0 ? S 15:13 0:00 [irq/261-Rear He]
root 266 0.0 0.0 0 0 ? S 15:13 0:00 [irq/262-Rear Mi]
root 267 0.0 0.0 0 0 ? I< 15:13 0:00 [msg_proc_wq]
root 268 0.0 0.0 0 0 ? S 15:13 0:00 [hi64xxdumplog]
root 269 0.0 0.0 0 0 ? S 15:13 0:00 [left_data_parse]
root 270 0.0 0.0 0 0 ? S 15:13 0:00 [right_data_pars]
root 271 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/6:1H-kblockd]
root 336 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/7:1H-kblockd]
root 337 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/4:1H-kblockd]
root 338 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/5:1H-kblockd]
root 340 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/1:1H-kblockd]
root 342 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/3:1H-kblockd]
root 348 0.0 0.0 0 0 ? S 15:13 0:00 [scsi_eh_4]
root 349 0.0 0.0 0 0 ? I< 15:13 0:00 [scsi_tmf_4]
root 350 0.0 0.0 0 0 ? S 15:13 0:00 [usb-storage]
root 422 0.1 0.0 0 0 ? S 15:13 0:02 [jbd2/sdd3-8]
root 423 0.0 0.0 0 0 ? I< 15:13 0:00 [ext4-rsv-conver]
root 497 0.0 0.0 0 0 ? S 15:13 0:00 [jbd2/sdd2-8]
root 498 0.0 0.0 0 0 ? I< 15:13 0:00 [ext4-rsv-conver]
root 499 0.0 0.0 0 0 ? S 15:13 0:00 [jbd2/sdd5-8]
root 500 0.0 0.0 0 0 ? I< 15:13 0:00 [ext4-rsv-conver]
root 554 0.0 0.3 61344 24100 ? S<s 15:13 0:01 /lib/systemd/systemd-journald
root 574 0.1 0.0 0 0 ? I 15:13 0:02 [kworker/u16:6-events_unbound]
root 589 0.0 0.0 20800 5692 ? Ss 15:13 0:00 /lib/systemd/systemd-udevd
root 733 0.0 0.0 0 0 ? I< 15:13 0:00 [kworker/2:1H-events_highpri]
root 740 0.0 0.0 0 0 ? I 15:13 0:00 [kworker/4:2-mm_percpu_wq]
root 748 0.0 0.0 75932 876 ? Ssl 15:13 0:00 /usr/sbin/kyseclogd
root 770 0.0 0.0 11260 1880 ? S<sl 15:13 0:00 /sbin/auditd
systemd+ 779 0.0 0.1 26180 10724 ? Ss 15:13 0:00 /lib/systemd/systemd-resolved
root 780 0.0 0.0 90232 6108 ? Ssl 15:13 0:00 /lib/systemd/systemd-timesyncd
root 905 0.0 0.0 0 0 ? S 15:13 0:00 [audit_prune_tre]
root 908 0.1 0.0 1956 1256 ? Ss 15:13 0:01 /opt/ol/OptiDaemon
root 909 0.0 0.0 241768 6132 ? Ssl 15:13 0:00 /usr/lib/accountsservice/accounts-daemon
root 911 0.0 0.0 1792 884 ? Ss 15:13 0:00 /usr/lib/audesktop/auserver
avahi 912 0.1 0.0 6292 3276 ? Ss 15:13 0:01 avahi-daemon: running [kylin-pc.local]
root 913 0.0 0.6 1086620 54796 ? SLsl 15:13 0:00 /usr/lib/biometric-authentication/biometric-authenticationd
root 916 0.0 0.0 12320 2408 ? Ss 15:13 0:00 /usr/sbin/cron -f
avahi 917 0.0 0.0 6080 300 ? S 15:13 0:00 avahi-daemon: chroot helper
root 918 0.0 0.0 33688 7472 ? Ss 15:13 0:00 /usr/sbin/cupsd -l
root 919 0.0 0.2 51724 16416 ? Ss 15:13 0:00 /usr/bin/python3 /usr/bin/location.py
root 927 0.0 0.1 436572 13840 ? Ssl 15:13 0:00 /usr/sbin/kylin-daq-daemon
root 932 0.2 1.0 310916 81300 ? Ssl 15:13 0:03 /usr/bin/python3 /usr/share/kylin-system-updater/kylin-system-updater
root 933 0.0 0.0 314728 1108 ? Ssl 15:13 0:00 /usr/bin/systime
root 936 0.0 0.0 309496 2880 ? Ssl 15:13 0:00 /usr/bin/perfgenius/perfgenius_server
root 938 0.0 0.0 12292 2896 ? Ss 15:13 0:00 /bin/bash /usr/bin/ppts/start.sh
syslog 943 0.0 0.0 220048 4464 ? Ssl 15:13 0:00 /usr/sbin/rsyslogd -n -iNONE
root 944 1.1 0.0 1212488 6888 ? Sl 15:13 0:15 /usr/bin/ppts/pptsmain
root 954 0.0 0.0 9852 3796 ? Ss 15:13 0:00 /usr/sbin/smartd -n
root 959 0.0 0.0 16012 3572 ? Ss 15:13 0:00 /lib/systemd/systemd-drop-cache
root 960 0.0 0.0 22624 7752 ? Ss 15:13 0:00 /lib/systemd/systemd-logind
root 961 0.0 0.0 104088 1672 ? Ssl 15:13 0:00 /vendor/bin/teecd
root 962 0.0 0.0 12292 3064 ? Ss 15:13 0:00 /bin/bash /usr/bin/hwfp_init.sh
message+ 964 0.9 0.1 15684 9760 ? Ss 15:13 0:12 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
root 966 0.0 0.1 267752 12664 ? Ssl 15:13 0:00 /usr/sbin/NetworkManager --no-daemon
root 970 0.0 0.2 53892 16496 ? Ss 15:13 0:00 /usr/bin/python3 /usr/bin/hedron-domain-hook.py
root 972 0.0 0.0 11844 3028 ? Ss 15:13 0:00 /usr/bin/processStateManage
root 973 0.7 0.1 396736 15700 ? Ssl 15:13 0:09 /usr/lib/udisks2/udisksd
root 974 0.0 0.0 12432 5468 ? Ss 15:13 0:00 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
root 1009 0.0 0.0 23068 4040 ? S 15:13 0:00 /usr/sbin/CRON -f
root 1016 0.0 0.0 20644 4960 ? S 15:13 0:00 /etc/xdg/autostart/SuwellUpdateService
root 1066 0.2 0.1 219700 13428 ? Ssl 15:13 0:02 /opt/pantum/sbin/pantum_smservice
root 1247 0.0 0.0 0 0 ? S 15:13 0:00 [sugov:0]
root 1248 0.0 0.0 0 0 ? S 15:13 0:00 [sugov:4]
root 1249 0.0 0.0 0 0 ? S 15:13 0:00 [sugov:6]
root 1291 0.1 0.0 341916 4104 ? Sl 15:13 0:01 /usr/bin/fingerprint_daemon
root 1309 1.6 0.3 166932 27696 ? Sl 15:13 0:21 /usr/sbin/kysec-daemon
root 1319 0.0 0.0 24800 7640 ? Ss 15:13 0:00 /usr/sbin/certmonger -S -p /run/certmonger.pid -n -d2
root 1320 0.0 0.0 2216 520 ? Ss 15:13 0:00 /bin/sh -c /opt/kingsoft/wtool/wpsupdateserver
root 1326 0.0 0.0 52688 4356 ? S 15:13 0:00 /opt/kingsoft/wtool/wpsupdateserver
root 1338 0.0 0.0 40048 2792 ? Ss 15:13 0:00 /usr/sbin/oddjobd -n -p /var/run/oddjobd.pid -t 300
root 1345 0.0 0.0 234716 6676 ? Ssl 15:13 0:00 /usr/lib/policykit-1/polkitd --no-debug
root 1357 0.0 0.1 947448 12968 ? Sl 15:13 0:00 /usr/bin/kylin-software-properties-service
root 1374 0.0 0.0 145044 6156 ? Sl 15:13 0:00 /usr/sbin/ksc-defender-daemon
dnsmasq 1439 0.0 0.0 15892 2016 ? S 15:13 0:00 /usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service
root 1462 0.0 0.0 10788 64 ? S 15:13 0:00 /usr/sbin/antivirus/avserver
root 1464 0.3 0.7 825084 62512 ? Sl 15:13 0:04 /usr/sbin/antivirus/avserver
root 1532 0.0 0.0 0 0 ? Z 15:13 0:00 [sh] <defunct>
root 1536 0.0 0.0 0 0 ? Z 15:13 0:00 [sh] <defunct>
root 1537 0.0 0.0 0 0 ? Z 15:13 0:00 [sh] <defunct>
root 1542 0.0 0.0 0 0 ? Z 15:13 0:00 [sh] <defunct>
root 1543 0.0 0.0 0 0 ? Z 15:13 0:00 [sh] <defunct>
root 1585 0.0 0.0 312932 4800 ? SLsl 15:13 0:00 /usr/sbin/lightdm
root 1590 0.0 0.2 128148 22276 ? Ssl 15:13 0:00 /usr/bin/python3 /usr/bin/kylin-unattended-upgrade-shutdown --wait-for-signal
root 1654 0.0 0.0 10984 1428 tty1 Ss+ 15:13 0:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root 1656 9.8 0.4 458208 38724 ? Ssl 15:13 2:07 /usr/sbin/kysec-sync-daemon --init
root 1666 0.0 0.0 131756 3980 ? Ssl 15:13 0:00 /usr/bin/ukui-media-control-led
root 1680 0.1 0.0 132104 5852 ? Ssl 15:13 0:01 /usr/bin/monitorkeyDbus
root 2077 0.0 0.0 123252 3816 ? Sl 15:13 0:00 /usr/lib/ukui-greeter/ukui-greeter-daemon
root 2121 0.0 0.0 179776 7232 ? Sl 15:13 0:00 lightdm --session-child 12 19
root 2248 0.0 0.4 108480 37532 ? S 15:13 0:00 /usr/bin/python3 /usr/share/kylin-system-updater/kylin-upgrade-strategies
root 2250 0.0 0.1 135212 8772 ? Sl 15:13 0:00 /usr/bin/backup-daemon
root 2278 0.0 0.1 350404 8620 ? Sl 15:13 0:00 /usr/bin/uniauth-backend
root 2310 0.0 0.0 2300 776 ? Ss 15:13 0:00 /vendor/oam_hisi
admin 2422 0.0 0.1 18804 8320 ? Ss 15:13 0:00 /lib/systemd/systemd --user
admin 2423 0.0 0.0 175460 2648 ? S 15:13 0:00 (sd-pam)
admin 2456 9.8 3.6 4066656 290184 ? Ssl 15:13 2:05 ukui-kwin_wayland --xwayland --drm --no-lockscreen --exit-with-session=/usr/bin/ukui-session
admin 2497 0.3 0.0 12352 6964 ? Ss 15:13 0:04 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
admin 2553 0.0 0.0 5420 1368 ? Ss 15:13 0:00 /usr/bin/ssh-agent /opt/sogouimebs/files/bin/sogouimebs-session /usr/bin/im-launch /usr/bin/ukui-session-wayland
root 2576 0.0 0.0 0 0 ? I< 15:13 0:00 [kbase_event]
admin 2593 5.7 2.2 1504956 181760 ? Sl 15:13 1:13 /usr/bin/Xwayland -displayfd 44 -rootless -wm 47
admin 2617 0.6 0.5 521416 41620 ? Sl 15:13 0:07 /usr/bin/ukui-session
admin 2639 0.0 0.0 156504 4444 ? Sl 15:13 0:00 /usr/libexec/dconf-service
admin 2652 0.0 0.0 2216 544 ? S 15:13 0:00 /bin/sh /usr/share/hw-audio/hwaudioservice.sh
admin 2656 0.3 0.4 591760 38564 ? Sl 15:13 0:04 /usr/bin/sni-daemon
admin 2657 0.0 0.0 431072 5708 ? Sl 15:13 0:00 /usr/bin/hwaudioservice
admin 2658 0.3 0.4 592724 39200 ? Sl 15:13 0:04 /usr/bin/sni-xembed-proxy
admin 2659 0.3 0.4 517916 38436 ? Sl 15:13 0:04 /usr/bin/panel-daemon
admin 2664 0.8 1.0 2589400 80956 ? Sl 15:13 0:10 /usr/bin/ukui-settings-daemon
admin 2666 0.6 1.0 1712672 83404 ? Sl 15:13 0:08 /usr/bin/ukui-panel
admin 2668 0.4 1.7 1793296 140080 ? Sl 15:13 0:06 /usr/bin/peony-qt-desktop -w -d
admin 2686 0.0 0.1 1479520 9356 ? Ssl 15:13 0:00 /usr/bin/pulseaudio --daemonize=no --log-target=journal
root 2706 0.0 0.0 12928 4052 ? Ss 15:13 0:00 /usr/lib/bluetooth/bluetoothd
admin 2712 0.0 0.0 243352 5592 ? Ssl 15:13 0:00 /usr/libexec/gvfsd
admin 2719 0.0 0.0 378644 2596 ? Sl 15:13 0:00 /usr/libexec/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
admin 2721 0.0 0.1 391940 11212 ? SLsl 15:13 0:00 /usr/libexec/gvfs-udisks2-volume-monitor
admin 2754 0.0 0.0 239340 5060 ? Ssl 15:13 0:00 /usr/libexec/gvfs-mtp-volume-monitor
admin 2758 0.3 1.1 695096 88412 ? Sl 15:13 0:04 /usr/bin/ukui-control-center-session
admin 2763 0.0 0.0 241188 5804 ? Ssl 15:13 0:00 /usr/libexec/gvfs-gphoto2-volume-monitor
admin 2772 0.0 0.0 239344 5220 ? Ssl 15:13 0:00 /usr/libexec/gvfs-goa-volume-monitor
admin 2776 0.0 0.0 320480 7192 ? Ssl 15:13 0:00 /usr/libexec/gvfs-afc-volume-monitor
root 2786 0.0 0.1 362904 11140 ? Sl 15:13 0:00 /usr/bin/ukui-powermanagement-service
admin 2792 0.3 0.8 566888 65800 ? Ssl 15:13 0:04 python3 /opt/hp/hplip/bin/systray.py -x
admin 2801 0.0 0.0 12152 2856 ? S 15:13 0:00 /usr/bin/bash /usr/local/hwupdate/runApp.sh
admin 2802 0.0 0.0 197048 2728 ? Sl 15:13 0:00 /usr/local/hwupdate/update_checker
admin 2803 0.0 0.0 391532 4320 ? Sl 15:13 0:00 /usr/libexec/gvfsd-network --spawner :1.35 /org/gtk/gvfs/exec_spaw/0
admin 2805 0.2 0.3 254224 29556 ? Sl 15:13 0:03 ./update_checkApp
admin 2818 0.3 0.4 591516 37036 ? Sl 15:13 0:04 /usr/sbin/ksc-virus-dialog
root 2824 0.0 0.1 278940 10404 ? Sl 15:13 0:00 /usr/bin/launchSysDbus
admin 2842 0.3 0.6 912372 53092 ? Sl 15:13 0:04 /usr/bin/kylin-device-daemon
admin 2843 0.3 0.6 761920 50144 ? Sl 15:13 0:04 /usr/bin/kylin-id
admin 2844 0.4 0.7 1013860 57064 ? Sl 15:13 0:05 /usr/bin/kylin-nm
admin 2845 0.3 0.5 758440 45796 ? Sl 15:13 0:04 /usr/bin/kylin-printer-applet
admin 2850 0.0 0.0 12832 3496 ? S 15:13 0:00 /usr/bin/kylin-updatefinish-notify-new
admin 2852 0.3 0.4 517480 37148 ? Sl 15:13 0:04 /usr/bin/user-guide-daemon
admin 2854 0.3 0.6 694640 47948 ? Sl 15:13 0:05 /usr/bin/kylin-vpn
admin 2855 0.3 1.1 1238932 90420 ? Sl 15:13 0:04 /usr/bin/kylin-weather showmainwindow%u
admin 2861 0.0 0.0 19724 976 ? S 15:13 0:00 /usr/bin/sdk-date
admin 2868 0.7 1.0 1387288 85160 ? Sl 15:13 0:09 /usr/bin/ukui-menu
admin 2870 0.3 0.6 858352 54132 ? Sl 15:13 0:04 /opt/pantum/bin/pantum_scanapp 0
admin 2878 0.3 0.6 931272 55372 ? Sl 15:13 0:04 /opt/pantum/bin/pantum_smclient -s
admin 2882 0.3 0.9 695948 72868 ? Sl 15:13 0:04 /usr/lib/aarch64-linux-gnu/ukui-polkit/polkit-ukui-authentication-agent-1
admin 2884 0.0 0.3 64380 31364 ? S 15:13 0:00 /usr/bin/python3 /usr/share/system-config-printer/applet.py
admin 2926 0.3 0.4 516820 34460 ? Sl 15:13 0:04 /usr/lib/aarch64-linux-gnu/libexec/kf5/kscreen_backend_launcher
admin 2928 0.0 0.1 590504 11900 ? Sl 15:13 0:00 /usr/bin/bluetoothService -o
admin 2934 0.3 0.4 591984 39508 ? Sl 15:13 0:04 /usr/bin/ukui-powermanagement
admin 2935 0.0 0.1 432916 9472 ? Sl 15:13 0:00 /usr/bin/ukui-screensaver-backend
admin 2942 0.3 0.5 625232 42532 ? Sl 15:13 0:04 /usr/bin/ukui-search-app-data-service
admin 2946 0.3 0.5 531940 40076 ? Sl 15:13 0:04 /usr/bin/ukui-search-service-dir-manager
admin 2950 0.3 0.4 605568 38780 ? Sl 15:13 0:04 /usr/bin/ukui-search-service
admin 2952 0.5 1.0 970376 80276 ? Sl 15:13 0:06 /usr/bin/ukui-search
admin 2953 0.3 0.7 694932 61720 ? Sl 15:13 0:04 /usr/bin/ukui-sidebar
admin 2954 0.3 0.4 591956 39084 ? Sl 15:13 0:04 /usr/bin/ukui-upower
admin 2958 0.3 0.6 881672 51552 ? Sl 15:13 0:04 /usr/bin/ukui-volume-control-applet-qt
admin 2959 0.5 0.5 546300 45460 ? Sl 15:13 0:07 /usr/bin/ukui-watermark
admin 2983 0.3 0.4 592236 37768 ? Sl 15:13 0:04 /usr/bin/NotifySend --DesktopNotify
admin 3025 0.0 0.0 1230400 3740 ? Sl 15:13 0:00 ./yh-signature-server/yh-signature-server -c /opt/SC-Reader/server/yh-signature-server/config.toml
root 3048 0.0 0.1 283136 10056 ? Sl 15:13 0:00 /usr/sbin/kysec-auth-daemon
admin 3068 0.3 0.4 592180 37800 ? Ssl 15:13 0:04 /usr/bin/NotifySend --WaitSignalNotify
root 3077 0.0 0.1 733048 8188 ? Sl 15:13 0:00 /usr/sbin/ksc-virus-daemon
root 3078 0.0 0.0 127148 4076 ? Sl 15:13 0:00 /usr/bin/profileDaemon
root 3165 0.0 0.1 256236 8020 ? Ssl 15:13 0:00 /usr/lib/upower/upowerd
admin 3201 0.6 0.4 519184 31972 ? Sl 15:13 0:07 /opt/sogouimebs/files/bin/sogouImeService-watchdog
admin 3219 0.0 0.0 317964 7676 ? Sl 15:13 0:00 /usr/libexec/gvfsd-computer --spawner :1.35 /org/gtk/gvfs/exec_spaw/2
admin 3227 0.0 0.0 1447000 3276 ? Sl 15:13 0:00 /opt/SC-Reader/server/yh-signature-server/yh-oes -m 1 -c /opt/SC-Reader/server/yh-signature-server/oes.toml
admin 3293 0.0 0.0 319016 5352 ? Sl 15:13 0:00 /usr/libexec/gvfsd-dnssd --spawner :1.35 /org/gtk/gvfs/exec_spaw/3
admin 3370 0.0 0.0 10144 3856 ? S 15:13 0:00 /opt/kingsoft/wps-office/office6/wpsd --quickstart=wps,wpp,et --component=wps,wpp,et --mode=window
admin 3382 0.4 0.9 690972 76328 ? Sl 15:13 0:05 /opt/kingsoft/wps-office/office6/wpscloudsvr /jsapihttpserver ksowpscloudsvr://start=RelayHttpServer
admin 3394 0.0 0.0 317616 7772 ? Sl 15:13 0:00 /usr/libexec/gvfsd-trash --spawner :1.35 /org/gtk/gvfs/exec_spaw/4
admin 3438 0.0 0.0 7260 1720 ? S 15:13 0:00 /usr/bin/krd-daemon
root 3451 0.0 0.0 123236 4796 ? Sl 15:13 0:00 /usr/bin/ukui-search-systemdbus
admin 3503 0.2 0.3 65796 26064 ? S 15:13 0:03 python3 /opt/hp/hplip/bin/systray.py -x
admin 3504 0.0 0.2 51584 21120 ? S 15:13 0:00 python3 /opt/hp/hplip/bin/systray.py -x
root 3546 0.0 0.0 99384 5804 ? Sl 15:13 0:00 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /run/NetworkManager/dhclient-enxa446b4906694.pid -lf /var/lib/NetworkManager/dhclient-554b6c8e-b7d2-3e8e-928e-1dacd2c44175-enxa446b4906694.lease -cf /var/lib/NetworkManager/dhclient-enxa446b4906694.conf enxa446b4906694
admin 3559 1.2 0.0 0 0 ? Z 15:13 0:16 [hp-upgrade] <defunct>
admin 3620 0.0 0.5 279348 42888 ? Sl 15:13 0:00 fcitx
admin 3680 0.0 0.0 11132 4728 ? Ss 15:13 0:00 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --config-file /usr/share/fcitx/dbus/daemon.conf
admin 3759 0.0 0.0 4976 1756 ? SN 15:13 0:00 /usr/bin/fcitx-dbus-watcher unix:abstract=/tmp/dbus-rSbHt2L6eb,guid=eb4e97ffd353e0b5d09494eb658142b2 3680
root 3826 0.0 0.2 528012 16744 ? Sl 15:13 0:00 /usr/lib/kylin-daemon/kylin-proxy
admin 4155 0.0 0.0 165960 5508 ? Ssl 15:13 0:00 /usr/libexec/gvfsd-metadata
admin 4953 0.3 0.9 1001624 76276 ? Sl 15:13 0:04 /opt/sogouimebs/files/bin/sogouImeService
admin 5141 0.0 0.0 243604 6740 ? SLl 15:13 0:00 /usr/bin/gnome-keyring-daemon --start --foreground --components=secrets
admin 5330 1.4 1.7 2648044 136564 ? Sl 15:14 0:18 /usr/bin/peony
admin 5361 0.0 0.0 317512 7148 ? Sl 15:14 0:00 /usr/libexec/gvfsd-recent --spawner :1.35 /org/gtk/gvfs/exec_spaw/5
root 6158 0.0 0.2 193484 20808 ? Sl 15:14 0:01 /usr/bin/python3 /usr/bin/kylin-assistant-systemdaemon.py
admin 7020 0.0 0.1 456288 15236 ? Sl 15:14 0:00 /usr/bin/kylin-cloud-sync
admin 7108 1.6 1.2 481688 101256 ? Ssl 15:14 0:20 /usr/bin/kylin-software-center-plugin-synchrodata
admin 7113 0.0 0.0 0 0 ? Z 15:14 0:00 [sh] <defunct>
admin 7117 0.0 0.0 0 0 ? Z 15:14 0:00 [sh] <defunct>
admin 7143 0.0 0.0 0 0 ? Z 15:14 0:00 [sh] <defunct>
admin 7481 0.0 0.0 0 0 ? Z 15:15 0:00 [sh] <defunct>
admin 7483 0.0 0.0 0 0 ? Z 15:15 0:00 [sh] <defunct>
admin 7485 0.0 0.0 0 0 ? Z 15:15 0:00 [sh] <defunct>
admin 9890 2.5 4.9 3149976 390424 ? Sl 15:16 0:29 /usr/lib/firefox-esr/firefox-esr
root 10028 0.0 0.0 316324 7080 ? Ssl 15:16 0:00 /usr/sbin/ModemManager --filter-policy=strict
admin 10159 0.3 1.4 2467328 116172 ? Sl 15:16 0:03 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 1 -isForBrowser -prefsLen 1 -prefMapSize 212925 -parentBuildID 20201207224150 -appdir /usr/lib/firefox-esr/browser 9890 tab
admin 10553 0.4 2.4 2603848 194984 ? Sl 15:16 0:05 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 4 -isForBrowser -prefsLen 9817 -prefMapSize 212925 -parentBuildID 20201207224150 -appdir /usr/lib/firefox-esr/browser 9890 tab
admin 10682 1.0 2.5 2631752 199336 ? Sl 15:16 0:11 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 5 -isForBrowser -prefsLen 9951 -prefMapSize 212925 -parentBuildID 20201207224150 -appdir /usr/lib/firefox-esr/browser 9890 tab
admin 10990 0.0 0.0 317132 6624 ? Sl 15:16 0:00 /usr/libexec/gvfsd-burn --spawner :1.35 /org/gtk/gvfs/exec_spaw/6
root 13048 0.0 0.0 77536 1944 ? Ss 15:18 0:00 gpg-agent --homedir //.gnupg --use-standard-socket --daemon
root 13731 0.3 1.0 189712 82084 ? SNl 15:19 0:03 /usr/bin/python3 /usr/sbin/aptd
admin 15937 0.0 0.0 12284 3072 ? S 15:23 0:00 /bin/bash /usr/bin/wps /media/admin/RyanWS/6-扶贫办/工作交接清单/~$账号密码.doc
admin 15946 12.4 4.6 848116 367052 ? Sl 15:23 1:25 /opt/kingsoft/wps-office/office6/wps /media/admin/RyanWS/6-扶贫办/工作交接清单/~$账号密码.doc
admin 16128 0.5 1.9 2567332 153576 ? Sl 15:23 0:03 /opt/kingsoft/wps-office/office6/wpscloudsvr /qingbangong /start_from=kstartpage silentautologin
root 16860 0.1 0.0 0 0 ? I 15:23 0:01 [kworker/u16:2-memlat_wq]
root 16913 0.0 0.0 0 0 ? I 15:24 0:00 [kworker/4:0-events]
root 16950 0.0 0.0 0 0 ? I 15:24 0:00 [kworker/3:0-events]
root 16998 0.0 0.0 0 0 ? I 15:24 0:00 [kworker/1:2-mm_percpu_wq]
root 17281 0.0 0.0 0 0 ? I 15:24 0:00 [kworker/7:0-pm]
root 17570 0.0 0.0 0 0 ? I 15:25 0:00 [kworker/5:2-cgroup_destroy]
admin 19415 2.3 0.2 35088300 23072 ? Ss 15:26 0:12 /opt/exagear/bin/ubt_x64a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x32a64_al_mem39 -f /opt/cxoffice21/bin/wineserver64 --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wineserver
admin 19421 0.0 0.5 71282236 42496 ? Ssl 15:26 0:00 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\services.exe
admin 19424 1.1 0.6 71286624 53072 ? Sl 15:26 0:06 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\winedevice.exe
admin 19445 1.4 0.5 71281220 43432 ? Sl 15:26 0:07 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\winedevice.exe
admin 19461 0.3 0.6 71284756 50384 ? Sl 15:26 0:02 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\plugplay.exe
admin 19493 0.0 0.3 71274936 29700 ? Sl 15:26 0:00 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\svchost.exe -k LocalServiceNetworkRestricted
admin 19514 0.3 1.0 2403352 82064 ? Sl 15:26 0:01 /usr/lib/firefox-esr/firefox-esr -contentproc -childID 8 -isForBrowser -prefsLen 12768 -prefMapSize 212925 -parentBuildID 20201207224150 -appdir /usr/lib/firefox-esr/browser 9890 tab
admin 19564 0.1 0.8 71319428 67520 ? Sl 15:26 0:00 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\explorer.exe /desktop
admin 19592 0.0 0.4 71279236 37204 ? Sl 15:26 0:00 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\windows\system32\rpcss.exe
admin 19667 15.7 6.9 70815256 552472 ? SLsl 15:26 1:23 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\Program Files\Tencent\WeChat\WeChat.exe
admin 19715 0.0 0.0 12152 3000 ? S 15:26 0:00 /bin/bash /opt/kwre/apps/wechat/run_k1.sh
root 19836 0.6 0.0 0 0 ? I< 15:26 0:03 [kworker/u17:1-mali_jd]
admin 19855 0.2 1.4 70465152 112224 ? Sl 15:26 0:01 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\ThumbPlayer\3314\extracted\WeChatPlayer.exe --wechat_pid=248 --process_name=ThumbPlayer --xlog_path=C:\users\CROS~MYY\APPL~JHT\Tencent\WeChat\log\player --xlog_prefix=player
admin 20103 0.9 4.2 70514336 335204 ? Sl 15:26 0:04 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\WeChatBrowser.exe --wechat_pid=248 --process_name=WebBrowser --enable-features=OverlayScrollbar --core_type=Xweb --locale_name=zh-CN --res_path=C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\ --locale_path=C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\locales --log_path=C:\users\CROS~MYY\APPL~JHT\Tencent\WeChat\log\xweb.log --sub_ua=MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63060012) --xlog_path=C:\users\CROS~MYY\APPL~JHT\Tencent\WeChat\log\xweb --xlog_prefix=xweb --xweb-param={ "reportId":1691, "version":702 } --log-severity=info
root 21868 0.0 0.0 0 0 ? I 15:26 0:00 [kworker/2:2-usb_hub_wq]
root 27445 0.0 0.0 0 0 ? I 15:26 0:00 [kworker/0:0-events]
root 27789 2.1 0.0 16356 7112 ? S 15:27 0:09 /usr/sbin/activation-daemon
root 36603 0.0 0.0 0 0 ? I 15:29 0:00 [kworker/6:0-events]
admin 37973 0.7 3.5 70499020 277944 ? Ssl 15:30 0:02 /opt/exagear/bin/ubt_x32a64_al_mem39 --path-prefix /opt/exagear/images/kylin-x86_64 --utmp-paths-list /opt/exagear/images/kylin-x86_64/.exagear/utmp-list --vpaths-list /opt/exagear/images/kylin-x86_64/.exagear/vpaths-list --opaths-list /opt/exagear/images/kylin-x86_64/.exagear/opaths-list --use-binfmt_misc --smo-mode fbase --smo-severity smart --bolt-socket /opt/exagear/run/exagear.bolt.socket --hifd-start 8192 --bolt-mode none --foreign-ubt-binary /opt/exagear/bin/ubt_x64a64_al_mem39 -f /opt/cxoffice21/bin/wine-preloader --rlimit-nofile-guest 8192,8192 -- /opt/cxoffice21/bin/wine-preloader /opt/cxoffice21/bin/wineloader C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\WeChatBrowser.exe --type=renderer --autoplay-policy=no-user-gesture-required --field-trial-handle=608,11238338704796692943,12560982283073801602,131072 --enable-features=CastMediaRouteProvider,OverlayScrollbar --disable-features=HardwareMediaKeyHandling,HistoryManipulationIntervention,OutOfBlinkCors --disable-gpu-compositing --lang=zh-CN --locales-dir-path=C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\locales --log-severity=info --resources-dir-path=C:\users\crossover\Application Data\Tencent\WeChat\XPlugin\Plugins\XWeb\702\extracted\ --user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36 NetType/WIFI MicroMessenger/7.0.20.1781(0x6700143B) WindowsWechat(0x63060012) --disable-spell-checking --device-scale-factor=1 --num-raster-threads=4 --enable-main-frame-before-activation --renderer-client-id=4 --no-v8-untrusted-code-mitigations --mojo-platform-channel-handle=960 /prefetch:1
root 38014 0.0 0.0 0 0 ? I 15:30 0:00 [kworker/7:2-mm_percpu_wq]
root 40498 0.0 0.0 0 0 ? I 15:30 0:00 [kworker/4:1-events]
root 45255 0.0 0.0 0 0 ? I 15:33 0:00 [kworker/5:0-cgroup_destroy]
admin 45314 1.0 0.8 602972 65552 ? Ssl 15:33 0:01 /usr/libexec/gnome-terminal-server
admin 45321 0.0 0.0 13596 4844 pts/0 Ss 15:33 0:00 bash
root 45768 0.0 0.0 0 0 ? I 15:33 0:00 [kworker/3:2-mm_percpu_wq]
root 50119 0.0 0.0 0 0 ? I 15:33 0:00 [kworker/2:0-mm_percpu_wq]
root 50786 0.0 0.0 0 0 ? I 15:34 0:00 [kworker/6:1-mm_percpu_wq]
root 50815 0.0 0.0 0 0 ? I 15:34 0:00 [kworker/0:2-events]
root 50817 0.0 0.0 0 0 ? S 15:34 0:00 [scsi_eh_5]
root 50818 0.0 0.0 0 0 ? I< 15:34 0:00 [scsi_tmf_5]
root 50870 0.0 0.0 11856 2328 ? Ss 15:34 0:00 /sbin/mount.ntfs /dev/sde3 /media/admin/RyanWS -o rw,nodev,nosuid,windows_names,uid=1000,gid=1000,uhelper=udisks2
admin 51733 0.0 0.0 10584 440 ? S 15:35 0:00 sleep 5
admin 51770 0.0 0.0 14140 2916 pts/0 R+ 15:35 0:00 ps aux


If you like this blog or find it useful for you, you are welcome to comment on it. You are also welcome to share this blog, so that more people can participate in it. If the images used in the blog infringe your copyright, please contact the author to delete them. Thank you !