# linux **Repository Path**: ttz_ztt/linux ## Basic Information - **Project Name**: linux - **Description**: linux的使用纪录 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-01-27 - **Last Updated**: 2025-04-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: Linux ## README # Debain11 配置 ## BUG 记录 - 进入单用户模式的方式: > grub 引导界面点击键盘`e`,然后选择 linux 一行,在尾部添加 `single init=/bin/bash`,然后在进入的单用户中,键入 `mount / -o remount,rw`,即进入可写的单用户模式,然后就可以瞎搞了 ## su 无法切换 root ```bash sudo passwd root # 重新设置密码即可 ``` ## 安装网卡驱动 ```bash sudo apt install firmware-realtek ``` ## 连接 wifi ```bash sudo nmcli dev wifi # 搜索WIFI sudo nmcli dev wifi connect 'eduroam' password '12345678' iface wlp3s0 # 连接WIFI,eduroam是帐号,12345678是密码,wlp3s0是无线网卡名称, sudo nmcli dev status # 查看状态 ``` ## 安装中文语言包 ```bash dpkg-reconfigure locales ``` > 选择 - zh_CN GB2312 - zh_CN.GBK GBK - zh_CN.UTF-8 UTF-8 - en_US.UTF-8 空格键选择,然后回车键确认 - 如果报错找不到 dpkg-reconfigure,那么就使用 ```bash su - # 加上后面这个符号相当于使用root帐号登录,且会初始化对应的环境变量,加上/usr/sbin目录。 ``` ```bash sudo gedit /etc/default/locale ``` > 设置 LANG=en_US.UTF-8 ```bash sudo apt install xfonts-intl-chinese xfonts-wqy ``` ## 开启触摸板单击 > 在设置中的鼠标与触摸板中将单击打开即可。 ```` ## Install same software ### Install step one ```shell sudo apt install git vim zsh ibus-rime ```` ### setting step one - git - some basic settings ```shell git config --global user.name "tmd" # tmd is local git username git config --global user.email "ttz.ztt@outlook.com" # ttz.ztt@outlook.com is local git email address git config --global credential.helper store # save static passowrd ssh-keygen -t ed25519 -C "xxxxx@xxxxx.com" # create ssh-key cat ~/.ssh/id_ed25519.pub # Show the ssh-key, which can then be copied to gitee, and later the gitee repository can be downloaded using ssh ``` - push repository - reset version ```shell # if your modifies the repository, and remote repository is modify as the same time, and modify the same file, then you can not push local repository, you can reset local version which you not modify this file. then you can pull and push git reset --hard git pull ``` - resolve binary conflicts ```shell git checkout FILE --ours # save your local version git checkout FILE --theirs # save your remote version ``` - 在 gitee 或 github 上出现@+数字,是携带了其他子项目,需要在本地上执行: ```shell sudo rm -rf .git git rm -r --cached . ``` - 设置字体 ```bash # /usr/share/fonts/truetype/目录下新建文件夹myfonts,将*.ttf文件复制到此文件夹下 sudo chmod 777 *.ttf sudo mkfontscale sudo mkfontdir sudo fc-cache -fv sudo fc-list ``` 查看具体安装的字体名称: ```bash fc-list | grep "JetBrains*" #查看(正则表达式) /usr/share/fonts/noto-cjk/NotoSansCJK-Bold.ttc: Noto Sans Mono CJK TC:style=Bold | | | | | | +--------------------------------------------+ +-------------------+ +--------+ 字体文件名称 字体名称 字体样式 ``` vscode 设置为:` "editor.fontFamily": "'JetBrainsMonoNL Nerd Font', monospace",` - zsh-/ohmyzsh ```shell cp -r linux/.oh-my-zsh ~ cp linux/.zshrc ~/.zshrc sudo cp -r linux/.oh-my-zsh /root sudo cp -r linux/.zshrc /root/.zshrc cp .p10k.zsh ~/ chsh -s /bin/zsh sudo chsh -s /bin/zsh source ~/.zshrc ``` - ibus-rime - ibus-set ```shell ibus-setup #1. there have one option in the General that is Candidates orientation, you need choice Horizontal, to row show. #2. click input Method, and add to chinese-rime, #3. click 'F4', later choice "简化字". ``` - alter configuration file - ~/.config/ibus/rime/default.custom.yaml ```shell sudo vim ~/.config/ibus/rime/default.custom.yaml ``` ```text # there have something you should notice, there are two spaces to the left of "menu", and one space before the "7" patch: "menu/page_size": 7 ``` - ~/.config/ibus/rime/ibus_rime.yaml (旧版本) - 新版本在 ~/.config/ibus/rime/ibus/build/ibus_rime.yaml ```shell sudo vim ~/.config/ibus/rime/ibus_rime.yaml ``` ```text style: horizontal: true # there have something you should notice too, there are two spaces to the left of "horizontal", and one space before the "true" ``` ### install step two ```shell sudo apt install g++ gcc openjdk-17-jdk-headless openjdk-17-jre-headless mpv python3 python3-pip okular ``` ### setting step two - some etting about guake - you need amending keyboard shortcuts in ubuntu, and used ctrl + alt + T open terminal, and you need add this program to start-up which open computer should start。 - and you need make some amending in guake setting - ln to python ```bash rm -rf /usr/bin/python sudo ln -s /usr/bin/python3 /usr/bin/python ``` ## install texlive - download texlive.ios - mount this .ios file - Begin to install ```shell sudo ./install-tl ``` - modify PATH variable ```shell # if you used bash you should used this command sudo vim ~/.bashrc # if you used zsh you should used this command sudo vim ~/.zshrc # Add this command in the end, and 2021 is now version, you should modify your version export PATH=/usr/local/texlive/2021/bin/x86_64-linux:$PATH export MANPATH=/usr/local/texlive/2021/texmf-dist/doc/man:$MANPATH export INFOPATH=/usr/local/texlive/2021/texmf-dist/doc/info:$INFOPATH ``` - Add Font of Tex to ubuntu ```shell sudo cp /usr/local/texlive/2021/texmf-var/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf sudo fc-cache -fv ``` ## python high speed download package - use this command ```shell pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple ``` ## stop terminal sound ```shell sudo vim /etc/inputrc ``` delete the ’#‘ in front of "set bell-style none" ### alter file green background ```shell cd ~ dircolors -p > .dircolors sudo cp .dircolors /root/ # alter the configuration about color setting. (maybe alter 4X to 3X) # if you used zsh, not bash, you should copy some bash configuration to zsh. ``` ## you-get you can downloads some video about YouKu or bilibili etc, before you used this tool, you should do something to prepare install this tool. this tool need python. if you have python. you can use this command to install you-get ```shell sudo pip3 install you-get ``` - you can download video like this command ```shell you-get -i [UIL] # this command can show all clarity and all option about video, so you can choose some options to download ``` - you can set savePath l ike this command ```shell you-get --output-dir [DIR] ``` ## LibreOffice 安装 - go to qinhua mirror downloads the main .gz.tar package. if you need china help and china menu, you need downloads langage. ```shell wget https://mirrors.tuna.tsinghua.edu.cn/libreoffice/libreoffice/stable/7.2.6/deb/x86_64/LibreOffice_7.2.6_Linux_x86-64_deb.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/libreoffice/libreoffice/stable/7.2.6/deb/x86_64/LibreOffice_7.2.6_Linux_x86-64_deb_helppack_zh-CN.tar.gz wget https://mirrors.tuna.tsinghua.edu.cn/libreoffice/libreoffice/stable/7.2.6/deb/x86_64/LibreOffice_7.2.6_Linux_x86-64_deb_langpack_zh-CN.tar.gz ``` - and in debs dir, you install all the deb backage. - remove ```shell $sudo apt-get remove --purge libreoffice4.x-* /* 移除所有类似libreoffice4.x-*的包。--purge表示卸载的同时移除所有相关的配置文件 */ ``` ## ubuntu Use Log ## apt error Q: Waiting for cache lock: Could not get lock /var/lib/dpkg/lock-frontend. It is held by process XXX (apt) ## apt update error ```text N: 无法安全地用该源进行更新,所以默认禁用该源。 N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 E: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-updates Release” 没有 Release 文件。 N: 无法安全地用该源进行更新,所以默认禁用该源。 N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 E: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-backports Release” 没有 Release 文件。 N: 无法安全地用该源进行更新,所以默认禁用该源。 N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 E: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-security Release” 没有 Release 文件。 N: 无法安全地用该源进行更新,所以默认禁用该源。 N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 E: 仓库 “https://mirrors.tuna.tsinghua.edu.cn/ubuntu jammy-proposed Release” 没有 Release 文件。 N: 无法安全地用该源进行更新,所以默认禁用该源。 N: 参见 apt-secure(8) 手册以了解仓库创建和用户配置方面的细节。 ``` - you can use this command to see your OS: ```shell lsb_release -a ``` and you rembmber the data that named Release; like this: ```text No LSB modules are available. Distributor ID:Ubuntu Description:Ubuntu 20.04.3 LTS Release:20.04 Codename:focal ``` - then you can in this url to downloads a ca-certificates.deb to solve this problem. > I choice the deb that named ca-certificates_20210119ubuntu0.21.04.1_all.deb > then you update. > **I kill apt process when install some .deb** > A: Because you kill this apt process, so this apt process can not free cache lock, you know only one software can use this cache lock in the same time, when you kill this process, and it don't free cache lock, other software not used, so you can used shell like: ```shell sudo kill -9 PID ``` - -9 if you used this options, you can now kill this process, if you don't used this options, maby after. ## command not found: ifconfig ```shell apt-get install net-tools ``` ## stop startup server if you install mysql, and use 'top' to look cpu status,you will know there has a server run at all times. that is "mysqld", this server was run when you computer boot-strap. you can used this command to stop like this server. ```shell systemctl list-unit-files # find you want to stop server. # at first you should stop this server. sudo systemctl stop mysql.service # latter inhibition this server sudo systemctl disable mysql.service ``` ## zip compaction file if you have many file need to compaction, you need use command like this: ```shell zip -r endFile.zip [file1] [file2] ``` ## unzip decompression file get the random code if use 'unzip' to decompression the file that compaction by windows, windows used ‘GBK’ in many file, but linux used 'utf-8', so you use utf-8 to decode 'GBK', it must get random code. you need assignation way to decode. used like this command. ```shell unzip -O GBK [filename] ``` _tip_: you need see the dir tree in this .zip file, if this file have no directory, you need use 'mkdir' to create a new directory, and decode in this new directory. ## alter default fonts you need download the fonts that you want to set, then, you can alter use this command ```shell sudo vim /etc/fonts/conf.d/64-language-selector-prefer.conf ``` and you need add ```html fontname ``` to that file. and you need add in per \ if you want to add the font that named "FZXiaoBiaoSong-B05S" and "KaiTi" (in font dir that named "方正小标宋简体字体"), your setting file need like this ```html sans-serif FZXiaoBiaoSong-B05S Noto Sans CJK JP Noto Sans CJK KR Noto Sans CJK SC Noto Sans CJK TC Noto Sans CJK HK Lohit Devanagari serif FZXiaoBiaoSong-B05S Noto Serif CJK JP Noto Serif CJK KR Noto Serif CJK SC Noto Serif CJK TC Lohit Devanagari monospace FZXiaoBiaoSong-B05S Noto Sans Mono CJK JP Noto Sans Mono CJK KR Noto Sans Mono CJK SC Noto Sans Mono CJK TC Noto Sans Mono CJK HK ``` ## libreoffice7.2 let pdf to word ```shell libreoffice7.2 --invisible --convert-to docx:"MS Word 2007 XML" pdfFileName.pdf ``` ## reduce noise in microphone - you need add this command in /etc/pulse/default.pa ```text #Active Noise Removal .ifexists module-echo-cancel.so load-module module-echo-cancel aec_method=webrtc source_name=mic source_properties=device.description=MicHD set-default-source "mic" .endif ``` ## open sysrq magic key - when your ubuntu was not listen your operate, you can use magic key to reboot. now let me tell you how to open magic key and how to use it. - you need write something in the `/etc/sysctl.d/10-magic-sysrq.conf` ```bash sudo vim /etc/sysctl.d/10-magic-sysrq.conf ``` > and you need alert kernel.sysrq = 1 - let me tell you how to use magic key - first,you need press ALT and PrtSc. Tip: you need press them at the same time. - then, you press R, and wait 1s - then, you press E, and wait 1s - then, press I,S,U,B ## debian 无法检测外接 HDMI 显示器 ```bash xrandr ``` - 显示只有 screen0 ,没有 HMDI 使用`sudo lshw -C video`查看信息,找不到指令就执行安装指令`sudo apt install lshw`.然后再执行 `sudo lshw -C video` 当显示有`*.display UNCLAIMED`表示有驱动错误,需要安装驱动。 执行命令:`sudo apt-get install firmware-linux-nonfree ` ## 遇到无法进入系统后,回退到上一个内核,重启后重新进入一个其他内核, ### 第一种办法,不删除旧内核,直接修改启动顺序 ```bash grep -e 'menuentry ' -e 'subm' /boot/grub/grub.cfg | awk -F'--' '{print $1}' ``` 查看当前系统中的内核,修改文件 `/etc/default/grub` ```bash GRUB_DEFAULT=0修改为: GRUB_DEFAULT="Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 5.10.0-13-amd64" ``` 然后执行 ``` update-grub ``` ### 第二种办法 删除出问题的内核,让系统修改启动顺序, ``` dpkg --list | grep linux-image # 列出所有内核 sudo apt-get --purge remove linux-image-4.19.0-17-amd64 # 删除内核 sudo update-grub # 更新 ``` ### 如果手贱使用了 autoremove 指令,需要在`/var/log/apt/history.log`目录下找到你删除的包,安装就好了 ## 磁盘自动挂载 1. 查看当前分区的 ID, ```bash sudo blkid ``` 输出如下: ```txt /dev/nvme0n1p9: UUID="7078981e-e20e-47ca-ad95-bf189e179f94" TYPE="swap" PARTUUID="43f1f0d0-4ac6-3e46-9c80-c9d6948c8ed9" /dev/nvme0n1p7: LABEL="F" BLOCK_SIZE="512" UUID="74E73600C94853DF" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="618e49b1-f44c-43d3-9c88-45078295f4e5" /dev/nvme0n1p5: LABEL="D" BLOCK_SIZE="512" UUID="687357F9AC952490" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="ef1824ea-e80b-4303-91e4-92485fc6c0e8" /dev/nvme0n1p3: LABEL="M-gM-3M-;M-gM-;M-^_" BLOCK_SIZE="512" UUID="DE88622E886204FD" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="f0002860-effd-4951-adb2-35164175540e" /dev/nvme0n1p1: UUID="1F1C-48FE" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="7eff1e39-4d1a-4173-add9-88135a141105" /dev/nvme0n1p8: LABEL_FATBOOT="NO_LABEL" LABEL="NO_LABEL" UUID="ADE2-C7EA" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="64353b31-a8a1-3e48-9b50-a2e1332c99f4" /dev/nvme0n1p10: UUID="e5cb88fb-fffe-4092-a030-17958ddb7fd6" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="8c8a64b6-9a37-344f-a465-ce614043ea8c" /dev/nvme0n1p6: LABEL="E" BLOCK_SIZE="512" UUID="644B9321118CED55" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="a40a3f4d-3331-495e-a3ba-f1e3d7705876" /dev/nvme0n1p4: BLOCK_SIZE="512" UUID="D65A31425A312123" TYPE="ntfs" PARTUUID="fe1e5fd4-7a9b-41e7-a957-9a4043d40617" /dev/sda1: LABEL="TMD" BLOCK_SIZE="512" UUID="4969221C6E699C21" TYPE="ntfs" PARTUUID="84946122-01" /dev/nvme0n1p2: PARTLABEL="Microsoft reserved partition" PARTUUID="7ed82960-22d8-49b4-b97c-9b459edf02b5" ``` 2. 修改启动的 fstab, ```bash sudo nvim /etc/fstab # 注意这里的ntfs和ext4前面的符合 ``` 内容如下: ```txt UUID=ADE2-C7EA /boot/efi vfat defaults,noatime 0 2 UUID=7078981e-e20e-47ca-ad95-bf189e179f94 swap swap defaults,noatime 0 0 UUID=e5cb88fb-fffe-4092-a030-17958ddb7fd6 / ext4 defaults,noatime 0 1 UUID=687357F9AC952490 /media/tmd/D ntfs defaults,noatime 0 2 UUID=644B9321118CED55 /media/tmd/E ntfs defaults,noatime 0 2 UUID=74E73600C94853DF /media/tmd/F ntfs defaults,noatime 0 2 UUID=4969221C6E699C21 /media/tmd/TMD ntfs defaults,noatime 0 2 ``` ## 修改 zsh-autosuggestion 颜色白色的问题 ```bash ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=yellow' ``` 可以支持的颜色有限: black , red , green , yellow , blue , magenta , cyan and white