Article April 12, 2017

QA-on-Linux

Words count 10k Reading time 9 mins. Read count 0

Linux Problems

I’m in Mint

可以把 http://www.cnblogs.com/manhua/p/3631046.html 删除了


Install

终端间通信

linux里有自带的终端间通信命令:write、wall

使用who命令,查看目前登入系统的用户信息,比如pts/0和pts/1是本机登录的两个终端。

在终端0上输入命令write manhua /dev/pts/1,此时在终端0上输入hello,在终端1上会显示。但如果要使终端1也能发送消息到终端0,则需要在终端1上输入write manhua /dev/pts/0,然后两个终端就可以互通消息,类似我们常用的聊天工具。

如果要终止聊天,在终端0处按ctrl +D,则在另一终端1处显示EOF,此时,终端0不能再向终端1发送消息,但终端1可以向终端0发送消息。

wall广播功能

echo “message” | wall ,这样所有的登录用户都可以收到“message”。

shell 参数

变量 说明
$$ Shell本身的PID(ProcessID)
$! Shell最后运行的后台Process的PID
$? 最后运行的命令的结束代码(返回值)
$- 使用Set命令设定的Flag一览
$* 所有参数列表。如用「”」括起来,以”$1 $2 … $n”的形式输出所有参数
$@ 所有参数列表。如用「”」括起来,以”$1” “$2” … “$n” 的形式输出所有参数
$# 添加到Shell的参数个数
$0 Shell本身的文件名
$1~$n 添加到Shell的各参数值。$1是第1参数、$2是第2参数

测试代码

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash
# params.sh
printf "The complete list is %s\n" "$$"
printf "The complete list is %s\n" "$!"
printf "The complete list is %s\n" "$?"
printf "The complete list is %s\n" "$*"
printf "The complete list is %s\n" "$@"
printf "The complete list is %s\n" "$#"
printf "The complete list is %s\n" "$0"
printf "The complete list is %s\n" "$1"
printf "The complete list is %s\n" "$2
1
2
3
4
5
6
7
8
9
10
11
$ bash params.sh 123456 QQ
The complete list is 24249
The complete list is
The complete list is 0
The complete list is 123456 QQ
The complete list is 123456
The complete list is QQ
The complete list is 2
The complete list is params.sh
The complete list is 123456
The complete list is QQ

双系统安装

  • 64位的vmlinuz有后缀名,删去就好了;

  • Easy BCD 设置iso路径时要以/开头,我的h盘是hd(0,8)

  • 启动后先执行命令sudo umount -l /isodevice

  • 安装时注意引导要安装到你所设置的root分区

输入法

安装ibus/搜狗输入法

1.在Mint中比较简单

  • setting->language->Input method->add support for fcitx

  • 安装搜狗官方的deb包 官网

  • 重启->右下角键盘图标’设置’-> ‘+’添加sougou

2.手动方法

sudo add-apt-repository ppa:fcitx-team/nightly
sudo apt-get update
sudo apt-get install fcitx fcitx fcitx-bin fcitx-config-common fcitx-config-gtk fcitx-data fcitx-frontend-all fcitx-frontend-gtk3:amd64 fcitx-libs:amd64 fcitx-libs-gclient:amd64 fcitx-libs-qt:amd64 fcitx-module-cloudpinyin fcitx-module-dbus fcitx-module-kimpanel fcitx-module-x11 fcitx-modules fcitx-qimpanel-configtool fcitx-ui-classic
  • sudo im-config 选择“是” –> 选择fcitx即可,然后确定
  • 安装搜狗官方提供的deb包
  • 如果出现状态栏显示两个相同图标,在系统设置-启动程序中取消fcitx的两个启动项留下搜狗的那个即可

Pinyin输入法只有双拼

ibus-daemon -drx

ibus输入法没有候选词(ibus restart)

ibus-setup
  • 在常规页面,取消了“在应用程序窗口中启用内嵌编辑模式”

  • 重新启动ibus

    killall ibus-daemon
    ibus-daemon -d

其他设置

保护眼睛 休息提醒

  • Workrave sudo apt-get install Workrave

自动挂载NTFS磁盘

  • 查看硬盘分区情况sudo fdisk -l

  • 编辑fstab文件sudo gedit /etc/fstab

  • 添加/dev/sda# /media/manhua/NAME auto defaults,locale=zh_CN.UTF-8 0 0

限制文件夹大小

配额是基于文件系统的,而不是基于目录的。因此,如果你想要限制特定目录的使用空间,你需要确保该目录是其文件系统的根目录或子目录。

激活quota功能:编辑/etc/fstab文件并为要限制大小的文件夹添加usrquota,grpquota
/dev/sda5 /home ext4 defaults,usrquota,grpquota 0 2

挂载镜像的方式限制

:用dd创建一个空的img镜像,进行格式化的配置,然后将其绑定到指定的文件夹上可以限制该文件夹的一些属性

1
2
3
4
5
6
7
8
9
10
11
dd if=/dev/zero of=test.img bs=10M count=1 # 创建img镜像
losetup -f # 查看可用的循环分区
losetup /dev/loop0[可用的循环分区] test.img
mkfs.ext4 /dev/loop0 # 格式化分区
mkdir test # 创建挂载目录
mount -o loop test.img test-dir/ # 挂载
umount test-dir/ # 取消挂载

dd if=/dev/zero of=1G.img bs=1G count=1
cat 1G.img >> test.img
resize2fs test.img

亮度调节只有三级

  • Linux Mint中任务栏右键菜单添加applet:Brightness

修改启动项倒计时

  • sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg_backup
  • sudo gedit /boot/grub/grub.cfg
  • 在### END /etc/grub.d/00_header ###上面找到timeout=10,然后自己改吧

临时更改terminal语言区域

  • echo $LANG
  • LANG=zh_CN.UTF-8LANG=en_US.UTF-8
  • 测试可用日历的命令 cal

桌面环境

1
2
3
4
sudo apt update && sudo apt -y upgrade && \
sudo apt-get purge xrdp && \
sudo apt install -y xrdp xfce4 xfce4-goodies

0%