1.1.2 ubuntu的基本/进阶配置

本文详细介绍了Ubuntu系统的基本配置和进阶优化方法,包括更新源、登录管理、桌面环境、语言环境、输入法安装、文件夹命名语言切换、防火墙关闭、终端路径简化、IP设置、系统启动顺序设置、开机启动服务管理、默认启动顺序调整等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

AUTHOR:    朱然(bruce)

MAIL:           821262524@163.com

NOTE:         If you have any problems, please feel free to contact me, thank you!

 

更新历史

v2.12019-10-24合并若干笔记,并增删改部分内容
v2.02018-05-02加入ubuntu18.04的相关更新
v1.12017-03-23整理笔记,分割过于庞大的文档
v1.02014-05-19初稿,整理过往几年的心得笔记

 

前言

这篇文档是我在工作的几年里,陆陆续续写下的,大多数都是一些备忘的小知识,借鉴了不少网上朋友的经验、智慧,再次感谢。

这篇文档写的时间周期太长(后续还会增添),有一些风格习惯,都在慢慢变化,在此做一些解释:

1 文档内容可靠性不做保证,毕竟很多时候,一个系统或软件版本的不同都会造成极大差异;

2 文档中,极少截图,不过我尽可能的将需要做的操作,以命令的方式记录下来了,命令颜色为黑底绿字;

3 文档中,命令执行后,在终端显示的响应内容,以黑底,浅绿色字样显示;

4 文档中,命令开头是”#“的,表明是用root帐号执行的,"$"是普通用户执行;

5 文档初衷只是对自己碰到的一些繁琐小问题进行记录,方便查找,所以写的很浅显,没有什么技术难度。

最后,有什么问题,欢迎联系我,大家一起讨论学习,谢谢!

 

1 基本配置

1.1 配置更新源

(1)简述

源的修改是重中之重,所有软件的安装都依赖于此,缺失包什么的也是在这里添加,选择了一个不合适的源,不但影响软件下载的速度,还可能会引发各种依赖BUG。

 

(2)更新源的两个方法

#1 备份源文件

这一步很重要,特别是对于新手,备份后,起码能让你把自己的源玩坏后,还能方便的将其恢复。

$ sudo cp /etc/apt/sources.list /etc/apt/sources.list_original

 

#2 修改源文件

方法一 : 自动获取最快服务器

菜单->SYSTEM->UpdateManager->Settings->Ubuntu Software->Download from->Other->Select Best Server

按照上面的步骤,让系统自己找最快的服务器,再点确认,最后更新一下源就好了。

但是,系统自己检测到的源,不一定是最好的源!!!推荐用下面的方法更换源。

 

方法二 : 手动修改源:

$ sudo gedit /etc/apt/sources.list

打开源文件,复制新的源地址替换原有内容,然后再保存退出即可。

 

#3 更新源

$ sudo apt-get update

如果更新时提示源出错了,就再换一个,有能力的也可以自行排查下出错原因——例如是不是"/etc/apt/sources.list.d/"目录下也有源文件,且文件中的源地址有误。

 

1.1.1 源地址

1.1.1.1 ubuntu 12.04源

#ubuntu12.04,香港

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise main restricted

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates main restricted

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise universe

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates universe

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise multiverse

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates multiverse

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-updates multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-backports main restricted universe multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security main restricted

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security universe

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security multiverse

deb-src http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ precise-security multiverse

============================================================

 

#zran:ubuntu12.04,163源

deb http://mirrors.163.com/ubuntu/ precise main restricted

deb-src http://mirrors.163.com/ubuntu/ precise main restricted

deb http://mirrors.163.com/ubuntu/ precise-updates main restricted

deb-src http://mirrors.163.com/ubuntu/ precise-updates main restricted

deb http://mirrors.163.com/ubuntu/ precise universe

deb-src http://mirrors.163.com/ubuntu/ precise universe

deb http://mirrors.163.com/ubuntu/ precise-updates universe

deb-src http://mirrors.163.com/ubuntu/ precise-updates universe

deb http://mirrors.163.com/ubuntu/ precise multiverse

deb-src http://mirrors.163.com/ubuntu/ precise multiverse

deb http://mirrors.163.com/ubuntu/ precise-updates multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-updates multiverse

deb http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ precise-security main restricted

deb-src http://mirrors.163.com/ubuntu/ precise-security main restricted

deb http://mirrors.163.com/ubuntu/ precise-security universe

deb-src http://mirrors.163.com/ubuntu/ precise-security universe

deb http://mirrors.163.com/ubuntu/ precise-security multiverse

deb-src http://mirrors.163.com/ubuntu/ precise-security multiverse

============================================================

 

#ubuntu12.04sohu源

deb http://mirrors.sohu.com/ubuntu/ precise main restricted

deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted

deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted

deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted

deb http://mirrors.sohu.com/ubuntu/ precise universe

deb-src http://mirrors.sohu.com/ubuntu/ precise universe

deb http://mirrors.sohu.com/ubuntu/ precise-updates universe

deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe

deb http://mirrors.sohu.com/ubuntu/ precise multiverse

deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse

deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse

deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse

deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted

deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted

deb http://mirrors.sohu.com/ubuntu/ precise-security universe

deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe

deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse

deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse

============================================================

 

#ubuntu12.04官方源

deb http://cn.archive.ubuntu.com/ubuntu/ precise main restricted

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise main restricted

deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates main restricted

deb http://cn.archive.ubuntu.com/ubuntu/ precise universe

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise universe

deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates universe

deb http://cn.archive.ubuntu.com/ubuntu/ precise multiverse

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise multiverse

deb http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-updates multiverse

deb http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

deb-src http://cn.archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu precise-security main restricted

deb-src http://security.ubuntu.com/ubuntu precise-security main restricted

deb http://security.ubuntu.com/ubuntu precise-security universe

deb-src http://security.ubuntu.com/ubuntu precise-security universe

deb http://security.ubuntu.com/ubuntu precise-security multiverse

deb-src http://security.ubuntu.com/ubuntu precise-security multiverse

deb http://extras.ubuntu.com/ubuntu precise main

deb-src http://extras.ubuntu.com/ubuntu precise main

============================================================ 

 

1.1.1.2 ubuntu14.04源

#ubuntu14.04,网易163源

deb http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse

#deb http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ trusty main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ trusty-security main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ trusty-updates main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ trusty-proposed main restricted universe multiverse

#deb-src http://mirrors.163.com/ubuntu/ trusty-backports main restricted universe multiverse

 

#ubuntu14.04,搜狐源

deb http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse

deb http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ trusty main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ trusty-security main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ trusty-updates main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ trusty-proposed main restricted universe multiverse

deb-src http://mirrors.sohu.com/ubuntu/ trusty-backports main restricted universe multiverse

 

1.1.1.3 ubuntu16.04源

#ubuntu16.04,阿里源deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe

deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse

deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties

deb http://archive.canonical.com/ubuntu xenial partner

deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted

deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties

deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe

deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

 

# 清华大学源,deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial universe

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates universe

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security universe

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security multiverse

 

#东北大学源

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial main restricted #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial multiverse

deb http://mirror.neu.edu.cn/ubuntu/ xenial-updates multiverse

deb http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties

deb http://archive.canonical.com/ubuntu xenial partner

deb-src http://archive.canonical.com/ubuntu xenial partner

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted

deb-src http://mirror.neu.edu.cn/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security universe

deb http://mirror.neu.edu.cn/ubuntu/ xenial-security multiverse

 

#香港中文大学

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-updates main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-updates universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-updates multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-backports main restricted universe multiverse

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-security main restricted

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-security universe

deb http://ftp.cuhk.edu.hk/pub/Linux/ubuntu/ xenial-security multiverse

 

1.1.1.4 ubuntu18.04源

#阿里源

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

 

#163源

deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse

 

#清华源

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

 

#中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

 

1.2 配置登录管理器

(1)简述

系统装好了,启动后,首先看到的就是一个登陆界面嘛!

这个登陆界面也是有讲究的,可不是简单的哪个界面比较漂亮那么简单,所有,首先可以学下怎么安装、切换登陆窗口。

不过,如果安装的是desktop版本的ubuntu,建议跳过本节内容的,因为desktop版ubuntu默认使用的就是我比较推荐的lightdm登陆管理器。

 

(2)安装登录管理器

$ sudo apt-get install lightdm/xdm/gdm/kdm/slim/…
最常见的图形化登录管理器包括 XDM、GDM、KDM,用户可根据自己的需要选择其中之一,推荐默认的lightdm(如果没有卸掉的话,不用重装该登陆管理器)。

 

(3)切换登录管理器

$ sudo dpkg –reconfigure lightdm/xdm/gdm/kdm/slim/…
和安装类似,任选其一即可。

 

(4)开机自动登录

$ sudo vim /etc/lightdm/lightdm.conf

[SeatDefaults]

autologin-guest=false

autologin-user=zran

autologin-user-timeout=0

autologin-session=lightdm-autologin

greeter-session=unity-greeter

user-session=ubuntu

 

1.3 配置root账号登陆

(1)简述

Ubuntu12.04之后版本的ubuntu,默认是不允许root账号登陆的,不错,这样更安全,但是有时候也会很不方便,作为爱折腾一族的成员,我还是提供破解方式。


上一节提到过,Ubuntu的登陆窗口不少,一般默认登录窗口是lightm,所以如果想在更换其它窗口后,继续使用root账号登陆…自己百度、谷歌吧!

补充一句,如果不是必要,新手尝鲜时可以用root登录,熟练后可别这么干了,还是老老实实的用普通用户登录吧,这样也能加深对各种权限的理解。

 

(2)lightm登陆管理器下的root帐号登录破解

#1 切换到root账号

Ubuntu 12.04默认是不允许root登录的,在登录窗口只能看到普通用户和访客登录。以普通身份登陆Ubuntu后需要做一些修改,但在修改系统配置文件时需要切换到超级用户模式,所以干脆就用root账号进行配置吧,更简单些。

$ sudo passwd root

$ su –s

 

#2 修改登陆配置文件

$ sudo vim /etc/pam.d/login
auth [success=ok new_authtok_reqd=ok ignore=ignore user_unknown=bad default=die] pam_securetty.so
修改成为下面的内容:
auth requisite pam_securetty.so

 

#3 修改登陆管理器配置文件

# vim /etc/lightdm/lightdm.conf

//增加“greeter-show-manual-login=true  allow-guest=false”。

//修改完的整个配置文件:

greeter-session=unity-greeter

user-session=ubuntu

#user-session=cinnamon

#user-session=fluxbox

#user-session=openbox

#user-session=gnome

#user-session=gnome-classic

#user-session=gnome-fallback

#user-session=gnome-shell

#user-session=ubuntu

#user-session=ubuntu-2d

#user-session=xsession

greeter-show-manual-login=true

allow-guest=false

PS:里面还有一些选项,对应者用户默认桌面,是否需要手工输入登陆系统的用户名和密码,是否允许guest登录等。

 

#4 重启OS

重启ubuntu,登录窗口会有“登录”选项,这时候我们就可以输入帐号,登录root了。

# reboot

 

1.4 配置apt-fast

(1)简述

Apt-fast 是一个用 axel 来加速 apt-get 软件安装的工具,通过这个工具在安装软件时,因为用到了 axel 的多线程下载功能,所以在下载软件包时会比普通的 apt-get 要快上好几倍。使用过程与aptget一样,只需要将apt-get改成apt-fast即可。

PS:"sudo apt-get xxx xxx"可以用"apt-fast xxx xxx"代替。

参考链接:

https://www.linuxidc.com/Linux/2013-11/92849.htm

 

(2)安装apt-fast

$ sudo add-apt-repository ppa:apt-fast/stable

$ sudo apt-get update

$ sudo apt-get install apt-fast

安装过程中,会让你设置axel 下载的最大线程数,一般默认的5 即可——电脑性能强悍,CPU支持更多线程的,可以设置多点,最大16。

 

1.5 配置桌面环境

(1)简述

Ubuntu的默认桌面环境是Gnome Unity,用了用,感觉好不爽好不习惯啊!怎么办?改呗!

桌面有很多,mate、cinnamon 、gnome2.0、lxde、xface、kde桌面等,个人推荐简洁一点的桌面,cinnamon等就不错。

下面就讲述几种的桌面安装,不能满足需求的,请自行搜索,无非就是:安装桌面环境-->注销-->选择新的桌面环境。

PS:桌面环境都会带有一些自己集成的程序,所以最好不要安装过多的桌面,导致程序过多,过于混乱,也许还会引发兼容性问题。

PS:安装桌面建议用命令安装,也可以用新立得软件包搜索xubuntu-desktop、kubuntu-desktop和ubuntu-desktop等进行安装。

 

(2)命令安装X 窗口系统

也许什么时候你的X窗口崩溃了,或者你是服务器版本的ubuntu,想试一试图形化界面,那么可以尝试安装X窗口系统。

$ apt-fast install x-window-system-core

 

(3)图形/文字界面切换

由图形界面到文字界面:

Ctrl + Alt + F1/F2/F3/F4/F5/F6

 

由文字界面到图形界面:

Ctrl + Alt + F7


1.5.1 Cinnamon桌面

sudo add-apt-repository ppa:embrosyn/cinnamon

sudo apt-fast update

sudo apt-fast install cinnamon

 

1.5.2 GNOME桌面

$ apt-get install ubuntu-desktop

 

1.5.3 KDE桌面

$ apt-get install kubuntu-desktop

 

1.5.4 LXDE

apt-fast install lxde

 

1.5.5 MATE (仿Gnome 2.x)桌面

$ apt-get install xubuntu-desktop

 

1.5.6 XFCE 桌面

add-apt-repository “deb http://packages.mate-desktop.org/repo/ubuntu precise main”
apt-fast install mate-archive-keyring
apt-fast update
apt-fast install mate-core
apt-fast install mate-desktop-environment

 

1.6 配置语言环境

(1)简述

桌面装好了,接下来该配置语言环境了,也许有朋友更喜欢英文/中文环境,那就需要修改安装系统时选择好的默认语言环境了。

 

1.6.1 安装语言包

System Settings-->Language Support-->Install/Remove Languages
选择自己需要的语言环境,拖到最顶层,点击应用即可,也许需要安装一些包,好在是自动的,当然,也可以手动安装:

$ apt-fast install libreoffice-help-en-gb libreoffice-help-zh-cn ibus-table-wubi ttf-wqy-zenhei wbritish thunderbird-locale-en-gb hyphen-en-us poppler-data mythes-en-au thunderbird-locale-en-us myspell-en-za fonts-arphic-uming libreoffice-l10n-en-za thunderbird-locale-zh-cn thunderbird-locale-en hunspell-en-ca openoffice.org-hyphenation ttf-arphic-ukai myspell-en-au myspell-en-gb libreoffice-l10n-en-gb ibus-sunpinyin cmap-adobe-gb1 libreoffice-l10n-zh-cn mythes-en-us thunderbird-locale-zh-hans

设置、安装结束后,也许需要重启电脑,如果重启后还不行,或者想通过命令手动配置,就继续往下看。

 

1.6.2 切换英文

#1 修改/etc/default/locale
文件中所有的 zh_CN替换位en_US, zh 替换成en。

$ sudo vim /etc/default/locale
LANG="en_US.UTF-8"
LANGUAGE="en_US:en"

 

#2 安装en_US语言包
如果没有英文语言包,可以用下面的命令安装。
$ apt-fast install language-pack-en

 

#3 修改/etc/environment

$ sudo locale
输出的可能有写问题,比如LC_ALL没有设置,有的还是zh等。


在/etc/environment中复制locale输出结果,并适当修改:
$ sudo vim /etc/environment
LANG=en_US.UTF-8
LANGUAGE=en_US:en
LC_CTYPE=”en_US.UTF-8″
LC_NUMERIC=”en_US.UTF-8″
LC_TIME=”en_US.UTF-8″
LC_COLLATE=”en_US.UTF-8″
LC_MONETARY=”en_US.UTF-8″
LC_MESSAGES=”en_US.UTF-8″
LC_PAPER=”en_US.UTF-8″
LC_NAME=”en_US.UTF-8″
LC_ADDRESS=”en_US.UTF-8″
LC_TELEPHONE=”en_US.UTF-8″
LC_MEASUREMENT=”en_US.UTF-8″
LC_IDENTIFICATION=”en_US.UTF-8″
LC_ALL=en_US.UTF-8

 

#4 注销,再登录

或者用命令xdg-user-dirs-gtk-update,用locale检查。

$ sudo locale

 

1.6.3 切换中文

#1 修改/etc/default/locale
en_US替换成zh_CN,en替换成zh。
# vim /etc/default/locale

LANG="zh_CN.UTF-8"

LANGUAGE="zh_CN:zh_HK:zh_TW:en"

LC_NUMERIC="zh_cn.UTF-8"

LC_TIME="zh_cn.UTF-8"

LC_MONETARY="zh_cn.UTF-8"

LC_PAPER="zh_cn.UTF-8"

LC_IDENTIFICATION="zh_cn.UTF-8"

LC_NAME="zh_cn.UTF-8"

LC_ADDRESS="zh_cn.UTF-8"

LC_TELEPHONE="zh_cn.UTF-8"

LC_MEASUREMENT="zh_cn.UTF-8"

LC_CTYPE="zh_CN.UTF-8"

LC_COLLATE="zh_CN.UTF-8"

LC_MESSAGES="zh_CN.UTF-8"

LC_ALL=zh_CN.UTF-8

 

#2 注销,再登录

或者用命令xdg-user-dirs-gtk-update,用locale检查。

$ sudo locale

 

1.7 配置输入法的安装

(1)简述

桌面语言环境装好了,下一步是安装输入法了。

ibus、fxitx框架我用得比较多,推荐~另外如果是中文安装的,应该会自带了ibus框架。

 

1.7.1 ibus输入法框架

#1 安装语言包

$ apt-fast install ibus ibus-clutter ibus-gtk ibus-gtk3 ibus-qt4

 

#2 启动IBus框架

$ im-switch -s ibus

 

#3 安装IBUS输入法

$ apt-fast install ibus-pinyin                        //IBus拼音

$ apt-fast install ibus-table-wubi                //IBus五笔

$ apt-fast install ibus-googlepinyin            //谷歌拼音

$ apt-fast install ibus-sunpinyin                //SUN拼音

 

#4 设置IBus框架

$ ibus-daemon –drx

此时,IBus Preference设置界面被打开,在Input Method中,选择喜欢的输入法,并配置自己喜欢的快捷键。

 

#5 找回IBUS图标

通常情况下,IBus图标(一个小键盘)会显示在桌面右上角的任务栏中。若这个图标消失,也可使用以下命令找回。

$ sudo ibus-daemon –drx

 

1.7.2 fcitx输入法框架

这个输入法框架我用的比较少,简单提下。

 

#1 安装fcitx输入法框架

$ add-apt-repository ppa:fcitx-team/nightly

$ apt-fast update

$ apt-fast install fcitx

$ apt-fast install fcitx-googlepinyin

$ apt-fast install fcitx-sunpinyin

$ apt-fast install fcitx-module-cloudpinyin

安装完成之后,在Language Support里面Keyboard input method system选择fcitx。

然后用Ctrl+Space打开fcitx的输入法,右键点击输入法指示器,可以选择Configure,在Addon页配置云输入法——推荐Sogou拼音输入法。

 

2 进阶配置

(1)简述

基本配置完毕后,其实ubuntu可以正常使用了,接下来都是优化操作。

 

2.1 切换ubuntu的文件夹命名语言

方法1:

在系统设置里面,将语言,从中文改到英文,或者从英文改到中文,然后注销或者重启后,再次进入桌面,系统会提示是否修改文件夹语言,选择好后,勾上不再提示。

 

方法2:

$ sudo export LANG=zh_CN    //英文-->中文

$ sudo export LANG=en_US    //中文-->英文

$ sudo xdg-user-dirs-gtk-update

在弹出的窗口中询问是否将目录转化为英文,或者中文,同意并关闭。

 

方法3:

$ sudo gedit ~/.config/user-dirs.dirs

# This file is written by xdg-user-dirs-update

# If you want to change or add directories, just edit the line you're

# interested in. All local changes will be retained on the next run

# Format is XDG_xxx_DIR="$HOME/yyy", where yyy is a shell-escaped

# homedir-relative path, or XDG_xxx_DIR="/yyy", where /yyy is an

# absolute path. No other format is supported.

#

#XDG_DESKTOP_DIR="$HOME/桌面"

#XDG_DOWNLOAD_DIR="$HOME/下载"

#XDG_TEMPLATES_DIR="$HOME/模板"

#XDG_PUBLICSHARE_DIR="$HOME/公共的"

#XDG_DOCUMENTS_DIR="$HOME/文档"

#XDG_MUSIC_DIR="$HOME/音乐"

#XDG_PICTURES_DIR="$HOME/图片"

#XDG_VIDEOS_DIR="$HOME/视频"

XDG_DESKTOP_DIR="$HOME/desktop"

XDG_DOWNLOAD_DIR="$HOME/download"

XDG_TEMPLATES_DIR="$HOME/model"

XDG_PUBLICSHARE_DIR="$HOME/public"

XDG_DOCUMENTS_DIR="$HOME/text"

XDG_MUSIC_DIR="$HOME/music"

XDG_PICTURES_DIR="$HOME/picture"

XDG_VIDEOS_DIR="$HOME/movies"

 

然后将文件夹名字逐一手动修改过来

$ mv 桌面 desktop

......

注销或者重启后,再次进入桌面,系统会提示是否修改文件夹语言,选择好后,勾上不再提示。

 

2.2 关闭防火墙

有时候ubuntu的防火墙挺碍事的,比如你在嵌入式开发时… …执行下面的命令,防火墙在系统启用时将自动禁用。

$ sudo ufw disable

 

2.3 简短风格的终端路径

ubuntu默认会在终端显示你当前所在位置,等效于永远开启的pwd命令,但是当你经常进入很长很长的路径时,你也许会觉得那足足一行多的路径位置提示很碍事,那么,在需要时,将其禁掉吧:

$ vim ~/.bashrc

if [ "$color_prompt" = yes ]; then

  PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '

else

    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\W\$ '

找到这一段,替换小写“w”为大写“W”即可。

 

2.4 设置静态/动态IP

如果经常处于一个固定的网络环境,如公司、家,可以考虑将IP设置为静态,方便访问、挂载等,相反的话,要设置成动态。 

 

2.4.1 设置静态IP地址

#1 修改interface

$ sudo vim /etc/network/interfaces

auto lo

iface lo inet loopback

auto eth0

iface eth0 inet static

address 192.168.10.52

netmask 255.255.255.0

gateway 192.168.10.1

network 192.168.10.0

broadcast 192.168.10.255 

 

#2 修改nameserver

$ sudo vim /etc/resolvconf/resolv.cong.d/base

$ sudo vim /etc/resolv.conf

nameserver 192.168.10.1   #example

nameserver 127.0.0.1 

PS:192.168.10.1只是一个范例,添加上你当前所在网络的网关即可。

 

#3 重启网络

$ /etc/init.d/networking restart 

PS:ubuntu14以后的版本,网络重启命令无效,可以选择鼠标点击网络标志,断开、重连网络。

 

2.4.2 设置动态IP地址

#1 修改interface

$ sudo vim /etc/network/interfaces

auto lo

iface lo inet loopback

auto eth0  

 

#2 重启网络

$ /etc/init.d/networking restart 

PS:ubuntu14以后的版本,网络重启命令无效,可以选择鼠标点击网络标志,断开、重连网络。

 

2.5 禁止系统日期时间设为UTC

#1 备份源文件

$ sudo cp /etc/default/rcS /etc/default/rcS_backup

 

#2 修改文件rcS

$ sudo vim /etc/default/rcS

搜寻到"UTC=yes",用"UTC=no"代替。

 

2.6 ubuntu鼠标右键扩展

2.6.1 右键打开终端

用过一些linux系统,也在网上了解了一些,比较喜欢Red Hat可以在任何目录下右键打开终端的功能,很方便,而Ubuntu没这个功能,不爽,于是在网上搜索了解决方法。

 

方法一:

$ sudo apt-get install nautilus-open-terminal

注销、或者再登录即可使用,重新加载文件管理器也行。

 

$ nautilus -q

顺带一提,单独执行nautilus命令,会以root权限打开一个窗口,来管理文件。

 

方法二:

进入主目录的.gnome2/nautilus-scripts目录,新建一个文件,文件名任意(这个文件名会显示在右键菜单里,最好是通俗易懂的,比如“打开终端”或“open-terminal”),文件内容参考下文:

//$ vim .gnome2/nautilus-scripts/open-terminal

#!/bin/bash

# This script opens a gnome-terminal in the directory you select.

# Distributed under the terms of GNU GPL version 2 or later

# Install in ~/.gnome2/nautilus-scripts or ~/Nautilus/scripts

# You need to be running Nautilus 1.0.3+ to use scripts.

# When a directory is selected, go there. Otherwise go to current

# directory. If more than one directory is selected, show error.

 

if [ -n "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" ]; then

set $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS

if [ $# -eq 1 ]; then

destination="$1"

 

# Go to file's directory if it's a file

 

if [ ! -d "$destination" ]; then

destination="`dirname "$destination"`"

fi

else

zenity --error --title="Error - Open terminal here"

--text="You can only select one directory."

exit 1

fi

else

destination="`echo "$NAUTILUS_SCRIPT_CURRENT_URI" | sed 's/^file:////'`"

fi

 

# It's only possible to go to local directories

 

if [ -n "`echo "$destination" | grep '^[a-zA-Z0-9]+:'`" ]; then

zenity --error --title="Error - Open terminal here"

--text="Only local directories can be used."

exit 1

fi

 

$ cd "$destination"

$ exec x-terminal-emulator

 

添加完后,把此文件加上可执行的权限。 

$ chmod +x .gnome2/nautilus-scripts/open-terminal

然后,和方法一类似,注销、重启,或者重新加载文件管理器即可。

 

2.6.2 右键共享文件夹

$ sudo apt-get install nautilus-share

 

2.6.3 右键以 root 权限打开文件夹

$ sudo apt-get install nautilus-gksu

这样右键单击文件或文件夹,选择以管理员打开——不过我实际测试时没有成功,找不到这个软件包了。

 

2.7 设置默认系统启动顺序

#1 修改默认启动盘

如果先安装的windows,再安装ubuntu系统,并选择系统共存,那么windows的编号一般为4,可以直接修改默认启动盘。

$ sudo vim /etc/default/grub

GRUB_DEFAULT=4

PS:"4"只是参考,更准确的,是去看/boot/grub/grub.cfg,检查内容,找到正确的数字。

 

#2 更新grub

$ sudo update-grub

PS:也可以直接修改/boot/grub/grub.cfg,这样就不用更新了,每次更新会将grub中的改动更新到grub.cfg。

重启电脑即可看到效果,如果有误,再调整数字即可。

 

2.8 添加/移除Ubuntu的开机启动服务

2.8.1 添加开机启动服务

#1 将启动脚本复制到 /etc/init.d目录下

$ sudo cp test /etc/init.d/

PS:以脚本"test"为例。

 

#2设置脚本文件的权限

$ sudo chmod 755 /etc/init.d/test

 

#3 分配脚本启动顺序

$ sudo update-rc.d /etc/init.d/test defaults 95

PS:其中数字95是脚本启动的顺序号,按照自己的需要相应修改即可——在你有多个启动脚本,而它们之间又有先后启动的依赖关系时你就知道这个数字的具体作用了。

PS:如果脚本需要用到网络,则NN需设置一个比较大的数字,如95-99。

 

2.8.2 移除开机启动服务

$ sudo update-rc.d -f /etc/init.d/test remove

$ sudo rm /etc/init.d/test

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值