问题现象 Ubuntu 20.04.4 LTS 添加汉语语言 安装完iBus及相关的输入法 (ibus-pinyin, ibus-table-wubi)后,就算是切换到zh语言也无法输入中文字符 换成fcitx后解决: 安装fcitx: $ sudo apt install fcitx 打开工具 Language Support/语言支持, 把Keyboard input method system改成fcitx 安装五笔输入法 $ sudo apt install fcitx-table-wubi 按Ctrl + Space或Left Shift在中英文之间切换 按Ctrl + Shift在不同的中文输入法之间切换
Category: Linux
Create a custom Application icon on Ubuntu
Create text file like below: [Desktop Entry] Type=Application Encoding=UTF-8 Name=MyApplication Comment=My fancy new application Exec=my_application Icon=my_application.png Terminal=false Name it as YOUR_APP_NAME.desktop, and then put it into /usr/share/applications for anyone; or put it into ~/.local/share/applications for current user only. Then you will see it in the Applications list Ref: https://askubuntu.com/questions/1026528/adding-custom-programs-to-favourites-of-ubuntu-dock
NTP synchronized cannot set to yes
CentOS 7.5, 配置过ntpd与某个时间服务器同步后,偶然发现某一个节点的NTP synchronized一直是no: # timedatectl Local time: 二 2019-07-30 09:41:08 CST Universal time: 二 2019-07-30 01:41:08 UTC RTC time: 二 2019-07-30 01:08:13 Time zone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: n/a 停掉ntpd, 执行ntpd -gq重新调整时间后,再启动ntpd: # systemctl stop ntpd # ntpd -gq ntpd: time slew …
Disable Out of memory killer in linux
By default Linux has a somewhat brain-damaged concept of memory management: it lets you allocate more memory than your system has, then randomly shoots a process in the head when it gets in trouble. (The actual semantics of what gets killed are more complex than that – Google “Linux OOM Killer” for lots of details …
Split string to array by delimiter in shell
#!/bin/bash STR="Sarah,Lisa,Jack,Rahul,Johnson" #String with names IFS=',' read -ra NAMES <<< "$STR" #Convert string to array #Print all names from array for name in "${NAMES[@]}"; do echo $name done #Print index from array for name in "${!NAMES[@]}"; do echo $name done ref: https://tecadmin.net/split-a-string-on-a-delimiter-in-bash-script/
cut与awk
取field2: # echo field1 field2 field3 | awk '{print $2}' 取value: # echo key:value | cut -d: -f2 组合使用 cut / awk 去除冒号后面值的空格 #echo namespace: lucky-cat | grep --max-count=1 namespace: | cut -d: -f2 | awk '{$1=$1;print}'
CentOS 7重命名一个网卡
把网卡enp0s3改成eth0 # ip link set enp0s3 down # ip link set enp0s3 name eth0 # ip link set eth0 up 但这样修改在系统重启后还是会回到原来的名字,因为系统启动后会按照规则重新进行硬件扫描并命名,所有有效的方法是修改/etc/sysconfig/network-scripts下以ifcfg-开头的文件,在网卡接口对应的文件中配置HWADDR: ... HWADDR=xx:xx:xx:xx:xx:xx DEVICE=eth0 ... 如果系统过程中找到了与ifcfg-xx文件中HWADDR匹配MAC地址的网卡,则系统以ifcfg-xx文件中指定的DEVICE的值作为网卡名称。 网卡命名过程(以下内容摘自:http://blog.sina.com.cn/s/blog_704836f40102w36n.html): ========================================== 按照如下顺序执行udev的rule 1./usr/lib/udev/rules.d/60-net.rules 2./usr/lib/udev/rules.d/71-biosdevname.rules 3./lib/udev/rules.d/75-net-description.rules 4./usr/lib/udev/rules.d/80-net-name-slot.rules 60-net.rules 使用/lib/udev/rename_device这个程序,去查询/etc/sysconfig/network-scripts/下所有以ifcfg-开头的文件 如果在ifcfg-xx中匹配到HWADDR=xx:xx:xx:xx:xx:xx参数的网卡接口 则选取DEVICE=yyyy中设置的名字作为网卡名称。 71-biosdevname.rules 如果系统中安装了biosdevname,且内核参数未指定biosdevname=0,且上一步没有重命名网卡,则按照biosdevname的命名规范,从BIOS中取相关信息来命名网卡。 主要是取SMBIOS中的type 9 (System Slot) 和 type 41 (Onboard Devices Extended Information) 不过要求SMBIOS的版本要高于2.6,且系统中要安装biosdevname程序。 75-net-description.rules udev通过检查网卡信息,填写如下这些udev的属性值 ID_NET_NAME_ONBOARD …
CentOS7中的几个磁盘操作指令
常用的磁盘操作命令有fdisk, cfdisk, sfdisk, mkfs, parted, partprobe kpartx, 在Linux中挂载一个新磁盘时,常用到如下操作: 1. fdisk fdisk可以用于查看指定硬盘的分区或对指定硬盘进行分区: 如显示所有分区: # fdisk -l Disk /dev/vda: 26.8 GB, 26843545600 bytes, 52428800 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: …
Change Timezone to Asia/Shanghai in CentOS 7
# timedatectl set-timezone Asia/Shanghai OR # rm -f /etc/localtime # ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime Reference: https://chrisjean.com/change-timezone-in-centos/
顺手的tar命令
查看包文件 tar -ztvf package.tar.gz 解包 tar -zxvf package.tar.gz 打包 tar -zcvf package.tar.gz .