YON Blog

关于 Ubuntu 的一些记录

题外话


不久前决定使用 Jekyll 来写博客, 断断续续花费了一周的时间终于在今天将博客搭建完成. 由于之前的博客是自己写的一个类似于微博的系统, 数据不太适合直接转移到 Jekyll 平台, 所以决定把之前的一些内容整理整理再发布到这里.

版本选择


首先, 不是 LTS 版本的都不需要考虑. 这样也就只剩下 10.04 和 12.04 可供选择. 我由于实在不能接受 Unity 的桌面, 所以最后选择了 10.04 的版本.

但是 10.04 也有些问题, 比如不能安装 lightworks 不得不说是令人比较遗憾的地方.

以下所有内容主要基于 Ubuntu 10.04 (Lucid Lynx)

安装


安装基本上没有什么好说, 就是如果使用 USB 安装 Alternate 版本的时候可能会出现找不到镜像文件的错误.

解决方法是在启动的时候把光标移到 Defaut 上然后按 Tab 键来修改 Grub 的启动选项, 之后在 “–” 前添加 “cdrom-detect/try-usb=true”, 最后回车就行了.

上面是 10.04 的解决办法, 如果你安装的是 12.04 的版本的话, 就需要自己手动挂载 ISO 文件到光驱了:

# 将 ISO 文件拷贝到 U盘
# 当出现错误提示的时候按 Alt + F2 切换终端, 然后输入下面的命令
umount /dev/sdb4
mkdir /mnt/usb
mount /dev/sdb4 /mnt/usb
cd /mnt/usb
mount -o loop ubuntu-12.04-alternate-i386.iso /cdrom

软件


MPlayer2

Ubuntu 上最好的播放软件, 没有之一.

sudo add-apt-repository ppa:ripps818/coreavc
sudo apt-get update
sudo apt-get install mplayer2

LibreOffice

安装的话直接去官网下载 deb 包.

安装之前先卸载 OpenOffice:

sudo apt-get purge openoffice*.*

Docky

软件中心的 Docky 无法去除自带的图标, 所以要从 ppa 上安装.

sudo add-apt-repository ppa:docky-core/ppa
sudo apt-get update
sudo apt-get install docky

下面是去除 Docky 自带图标:

  1. 按Alt + F2, 输入 gconf-editor, 回车
  2. 找到 apps/docky-2/docky/items/DockyItem
  3. 取消选择 ShowDockyItem
  4. 重启 Docky

unrar

rar 解压中文压缩包会出现编码问题, unrar 则没有这个问题.

JDK

安装无非就是下载解压, 主要是设置环境变量.

网上有的说是修改 .bashrc 文件, 这样虽说运行确实不成问题, 但是 Eclipse 将无法找到你安装的 JDK.

所以最好是修改 /etc/profile 文件.

sudo vim /etc/profile

添加:

export JAVA_HOME=/opt/java/jdk1.7.0_17
export CLASSPATH=.:${JAVA_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH

美化


修改用户登录界面的桌面背景

默认的紫色背景太丑了.

懒得翻译了, 直接贴原文:

  1. Move your favorite login wallpaper to your Home folder. Make sure that it is of .JPG format.
  2. Move the wallpaper to the system wallpaper directory. In the terminal: sudo mv ~/your-wallpaper-name.jpg /usr/share/backgrounds
  3. Activate the Appearance window upon login sudo cp /usr/share/applications/gnome-appearance-properties.desktop/usr/share/gdm/autostart/LoginWindow
  4. Close the terminal. Log out of your current session. At the login screen, the Appearance window will show up. Go to the background tab and select your favorite wallpaper as the background. (If you can’t find your favorite wallpaper, click Add. You should be able to find your wallpaper in the /usr/share/backgrounds directory).
  5. Your login background will instantly change to the wallpaper you have selected. Now login to your desktop.
  6. Open a terminal. Type the following command to deactivate the Appearance window upon login. sudo unlink /usr/share/gdm/autostart/LoginWindow/gnome-appearance-properties.desktop

How to Change Your Login And Boot Screen In Ubuntu Lucid

修改 Terminal 默认启动大小

给 Terminal 添加 --geometry=132x43 启动参数.

删除信封/帐号图标

# 删除信封图标
sudo apt-get remove indicator-messages

# 删除帐号图标
sudo apt-get remove indicator-me

优化


终端 Tab 键不区分大小写

默认在终端中按 Tab 键进行补全的时候是区分大小写的, 解决方法是:

# Case-Insensitive Tabbing in Ubuntu Terminal
sudo vim /etc/inputrc
# 添加下面内容
set completion-ignore-case on

解决无线 LED 灯一直闪烁的问题

Ubuntu 默认的情况下是, 如果无线上有网络数据交换的话, LED 灯会一直闪烁.

sudo vim /etc/network/if-up.d/wifi-led-noblink

# 添加下面内容

#!/bin/sh
#This script prevents the wifi light from blinking when on.
#To enable this script, create a soft link to it in /etc/network/if-up.d/
echo none > /sys/class/leds/iwl-phy0::RX/trigger
echo none > /sys/class/leds/iwl-phy0::TX/trigger
echo none > /sys/class/leds/iwl-phy0::radio/trigger
echo none > /sys/class/leds/iwl-phy0::assoc/trigger

# Make the script executable
sudo chmod u+x /etc/network/if-up.d/wifi-led-noblink

HOW TO STOP THE BLINKING WIFI LED ON UBUNTU LAPTOPS WITH INTEL WIRELESS CARDS

如果你是 ThinkPad


设置充电阈值

sudo -i
aptitude install tp-smapi-dkms
modprobe tp_smapi
echo 40 > /sys/devices/platform/smapi/BAT0/start_charge_thresh
echo 85 > /sys/devices/platform/smapi/BAT0/stop_charge_thresh

配置风扇

由于 Ubuntu 对于 ThinkPad 的风扇支持不是太好, 导致系统运行过程当中, 风扇持续的高速运转, 可以通过安装 ThinkFan 解决.

# 安装 ThinkFan
sudo apt-get install thinkfan
# 开机加载模块
sudo vim /etc/modprobe.d/thinkfan.conf
# 添加下面内容
options thinkpad_acpi fan_control=1
# 开机启动
sudo vim /etc/default/thinkfan
# no => yes
START=yes
# 按需修改 ThinkFan 配置
sudo vim /etc/thinkfan.conf

设置小红点灵敏度

sudo vim /etc/rc.loal
# 将以下内容写到文件中
sleep 10
echo -n 255 > /sys/devices/platform/i8042/serio1/serio2/speed 
echo -n 255 > /sys/devices/platform/i8042/serio1/serio2/sensitivity

最后,安装 Pointing devices 来启用中键滚动和关闭 TouchPad

其它


解决软件中心中的残留源

懒得修改了, 直接把我原来的博客复制过来.

今天想要解决 network-manager 的 DHCP 问题时,添加了 ppa:network-manager/ppa, ppa:network-manager/trunk 这两个源,后来发现即使是升级了 network-manager 也不能解决问题,然后就先卸载所有和 network-manager 相关的程序,然后从 /etc/apt/sources.list.d 中删除了相关的ppa源,但是发现即使我 update 之后,在 Ubuntu Software Center 中还是有这两个源的存在, 各种Google之后,在下面这个帖子里发现了蛛丝马迹: https://bugs.launchpad.net/ubuntu/+source/software-center/+bug/574155

10楼的兄弟说道: I think I know what´s causing this:

I used some PPA´s which I removed, but I kept using the ppa version of the app The software center keeps the ppa because you still use the ppa version.

After forcing the program back to the lucid version with synaptic, the ppa disappears in the software center after updating the cache. :)

于是打开 Synaptic Package Manager 搜索删不掉的 ppa 源中的软件(一定要完全对应),然后选择 Package - Force Version 在弹出的窗口里的下拉菜单中选择 lucid 的版本, 最后应用修改, 最最后运行 sudo /usr/share/software-center/update-software-center 重建下 software-center 的缓存,一切OK!

rc.local 没有运行?

Q: rc.local is not executed

A: Upstart operates asynchronously. rc.local often runs too soon. Try adding a sleep command at the top of the script

总而言之就是要想你写在 rc.local 的脚本能顺利运行,就在脚本最开始加上 sleep 10

无法编译程序?

现在想想以前每次想要在 Ubuntu 下自己编译程序都不能成功,大概是因为没有安装 build-essential 吧

sudo apt-get install build-essential

桌面背景图片所在文件夹

/usr/share/backgrounds

PPA 源所在文件夹

/etc/apt/sources.list.d

还在用左右箭头移动光标?

bash 中删除一个 word 的快捷键是 Alt + Backspace

在一般的文本编辑器中, 按 word 移动的快捷键时 Ctrl + 光标, 按 word 删除的快捷键是 Ctrl + Backspace

Eclipse 中文注释乱码

  1. window->preferences->General->Content Types
  2. 找到要修改的文件的类型,在下面有个Default encoding,在输入框中输入GBK
  3. 点击Update
  4. 点击OK
  5. 重启eclipse

激活/锁定 root 用户

# 激活 root 用户
sudo passwd root

# 锁定 root 用户
passwd -l root

深度卸载软件

使用 purge 而不是 remove 来卸载.

卸载后执行下面的命令:

sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get clean
dpkg --list | grep "^rc" | cut -d " " -f 3 | xargs sudo dpkg --purge