Linux使用技巧汇总

Debian是我日常使用的桌面系统,这里记录了我在使用Debian和其他Linux时所有的问题和解决办法,以及一些其他的心得体会。
向Debian致敬!


找回桌面系统关机按钮

在/etc/polkit-1/localauthority/50-local.d/新建文件50-admin.pkla,写入如下内容:

1
2
3
4
5
6
7
8
9
10
11
12
[disable suspend]   
Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultAny=no
ResultInactive=no
ResultActive=no
[disable hibernate]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultAny=no
ResultInactive=no
ResultActive=no

无线不能使用的解决方法

安装rfkill工具

apt-get install rfkill

然后运行:

rfkill list all

可以查看到网卡设备的状态如下:

1
2
3
4
5
6
0: dell-wlan: Wireless LAN   
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no

根据软件或者硬件的状态解锁。


wireshark设置普通用户权限

1
2
3
4
5
6
sudo groupadd wireshark
sudo usermod -a -G wireshark YOUR_USER_NAME
sudo chgrp wireshark /usr/bin/dumpcap
sudo chmod 750 /usr/bin/dumpcap
sudo setcap cap_net_raw,cap_net_admin=eip /usr/bin/dumpcap
sudo getcap /usr/bin/dumpcap

Adobe flash player的正确安装姿势

首先下载flash player,保存为flash.tar.gz
then:

1
2
3
tar -zxvf flash.tar.gz
mv usr/* /usr/
mv libflashplayer.so /usr/lib/mozilla/plugins/

重启浏览器即可。


修复Debian8 pptp不能连接的问题

报错内容:(/var/log/syslog)

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
Sep 15 14:58:21 debian NetworkManager[13550]: ** Message: pppd started with pid 14188
Sep 15 14:58:21 debian pppd[14188]: Plugin /usr/lib/pppd/2.4.6/nm-pptp-pppd-plugin.so loaded.
Sep 15 14:58:21 debian NetworkManager[13550]: Plugin /usr/lib/pppd/2.4.6/nm-pptp-pppd-plugin.so loaded.
Sep 15 14:58:21 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (plugin_init): initializing
Sep 15 14:58:21 debian pppd[14188]: pppd 2.4.6 started by root, uid 0
Sep 15 14:58:21 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (nm_phasechange): status 3 / phase 'serial connection'
Sep 15 14:58:21 debian pppd[14188]: Using interface ppp0
Sep 15 14:58:21 debian pppd[14188]: Connect: ppp0 <--> /dev/pts/0
Sep 15 14:58:21 debian NetworkManager[13550]: Using interface ppp0
Sep 15 14:58:21 debian NetworkManager[13550]: Connect: ppp0 <--> /dev/pts/0
Sep 15 14:58:21 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (nm_phasechange): status 5 / phase 'establish'
Sep 15 14:58:21 debian NetworkManager[13550]: <info> (ppp0): new Generic device (driver: 'unknown' ifindex: 57)
Sep 15 14:58:21 debian NetworkManager[13550]: <info> (ppp0): exported as /org/freedesktop/NetworkManager/Devices/15
Sep 15 14:58:21 debian NetworkManager[13550]: <info> devices added (path: /sys/devices/virtual/net/ppp0, iface: ppp0)
Sep 15 14:58:21 debian NetworkManager[13550]: <info> device added (path: /sys/devices/virtual/net/ppp0, iface: ppp0): no ifupdown configuration found.
Sep 15 14:58:52 debian pppd[14188]: LCP: timeout sending Config-Requests
Sep 15 14:58:52 debian pppd[14188]: Connection terminated.
Sep 15 14:58:52 debian avahi-daemon[588]: Withdrawing workstation service for ppp0.
Sep 15 14:58:52 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (nm_phasechange): status 11 / phase 'disconnect'
Sep 15 14:58:52 debian NetworkManager[13550]: <info> devices removed (path: /sys/devices/virtual/net/ppp0, iface: ppp0)
Sep 15 14:58:52 debian pptp[14193]: nm-pptp-service-14185 warn[decaps_hdlc:pptp_gre.c:216]: pppd may have shutdown, see pppd log
Sep 15 14:58:52 debian pppd[14188]: Modem hangup
Sep 15 14:58:52 debian pppd[14188]: Exit.
Sep 15 14:58:52 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (nm_phasechange): status 1 / phase 'dead'
Sep 15 14:58:52 debian NetworkManager[13550]: ** Message: nm-pptp-ppp-plugin: (nm_exit_notify): cleaning up
Sep 15 14:58:52 debian NetworkManager[13550]: ** (nm-pptp-service:14185): WARNING **: pppd exited with error code 16

依次输入如下命令:

1
2
3
modprobe nf_nat_pptp
modprobe nf_conntrack_pptp
modprobe nf_conntrack_proto_gre

下次启动还会失效,所以要编辑/etc/modules-load.d/modules.conf文件,添加如下三行:

1
2
3
nf_nat_pptp
nf_conntrack_pptp
nf_conntrack_proto_gre

减少开机等待时间

  • 减少grub等待时间:
    修改/etc/default/grub,将
    1
    GRUB_TIMEOUT=5
    改为 (grub等待超时改成1秒):
    1
    GRUB_TIMEOUT=1
    然后运行
    1
    # update-grup
  • 减少开关机超时
    修改/etc/systemd/system.conf,修改开关机超时时间为5s:
    1
    2
    DefaultTimeoutStartSec=5s
    DefaultTimeoutStopSec=5s
    重启

使用随机MAC地址

出于隐私需求,不想暴露真实mac地址,把下面这个脚本的内容加入/etc/init.d,就可以在每次开机的时候为网卡随机设置一个mac地址。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/bash
#Chorder
#2016/12/08

mhash=`date +%s|md5sum`

ifconfig eth0 down
ifconfig eth0 hw ether `echo ${mhash:$((RANDOM % 13)):2}:\
${mhash:$((RANDOM % 13)):2}:${mhash:$((RANDOM % 13)):2}:\
${mhash:$((RANDOM % 15)):2}:${mhash:$((RANDOM % 15)):2}:\
${mhash:$((RANDOM % 15)):2} `
ifconfig eth0 up

ifconfig wlan0 down
ifconfig wlan0 hw ether `echo ${mhash:$((RANDOM % 13)):2}:\
${mhash:$((RANDOM % 13)):2}:${mhash:$((RANDOM % 13)):2}:\
${mhash:$((RANDOM % 15)):2}:${mhash:$((RANDOM % 15)):2}:\
${mhash:$((RANDOM % 15)):2} `
ifconfig wlan0 up

gnome删除多余的菜单文件夹

运行

1
gsettings set org.gnome.desktop.app-folders folder-children ['']

CentOS删除旧内核

1
for k in `rpm -qa | grep kernel |grep -v \`uname -r\``;do yum remove $k;done

鼠标滚轮方向调整

修改 ~/.Xmodmap 文件

如果想要鼠标逆序滚动,就将其中的内容改为

pointer = 1 2 3 4 5 6 7 8 9 10 11 12

否则,就将内容改为:

pointer = 1 2 3 5 4 6 7 8 9 10 11 12

4和5代表的是鼠标滚轮方向的映射。


Debian9 GNOME 允许root登录

修改三个文件:

  1. /etc/gdm3/daemon.conf

在Security节,加入

1
AllowRoot=true
  1. /etc/pam.d/gdm-password

注释掉下面这一行

1
auth required pam_succeed_if.so_user != root quiet_success
  1. /etc/pam.d/gdm-autollgoin

注释掉下面这一行

1
auth required pam_succeed_if.so_user != root quiet_success

重启。

Java的面向对象属性 Linux内核学习笔记
Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×