原文地址:
http://wiki.ubuntu.org.cn/UbuntuSkills
ubuntu使用技巧.pdf (1.95 MB)
1—11帖子的内容都在这个zip里面,
前言
下面的命令大都需要在 控制台 / 终端 / shell 下输入。
控制台, 终端, 和 shell 意味着同样一件事 - 一个命令行界面, 他可以用来控制系统。
打开一个控制台:
应用程序 → 附件 → 终端
任何一个使用 ‘sudo’ 作为前缀的命令都需要拥有管理员 (或 root) 访问权限。 所以你会被提示输入
你自己的密码。
安装升级
查看软件 xxx 安装内容
dpkg -L xxx
查找软件库中的软件正则表达式
apt-cache search
或:
aptitude search
显示系统安装包的统计信息
apt-cache stats
显示系统全部可用包的名称
apt-cache pkgnames
显示包的信息
apt-cache show k3b
查找文件属于哪个包
dpkg -S filename
apt-file search filename
查看已经安装了哪些包
dpkg -l
也可用
dpkg -l | less
查询软件 xxx 依赖哪些包
apt-cache depends xxx
查询软件 xxx 被哪些包依赖
apt-cache rdepends xxx
增加一个光盘源
sudo apt-cdrom add
系统更新
sudo apt-get update
(这一步更新包列表)
sudo apt-get dist-upgrade
(这一步安装所有可用更新)
或者
sudo apt-get upgrade
(这一步安装应用程序更新,不安装新内核等)
清除所有已删除包的残馀配置文件
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
如果报如下错误,证明你的系统中没有残留配置文件了,无须担心。
dpkg: --purge needs at least one package name argument
Type dpkg --help for help about installing and deinstalling packages;
Use `dselect' or `aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Type dpkg --license for copyright license and lack of warranty (GNU GPL).
Options marked produce a lot of output - pipe it through `less' or `more'
编译时缺少 h 文件的自动处理
sudo auto-apt run ./configure
查看安装软件时下载包的临时存放目录
ls /var/cache/apt/archives
备份当前系统安装的所有包的列表
dpkg --get-selections | grep -v deinstall > ~/somefile
从上面备份的安装包的列表文件恢复所有包
dpkg --set-selections < ~/somefile
sudo dselect
清理旧版本的软件缓存
sudo apt-get autoclean
清理所有软件缓存
sudo apt-get clean
删除系统不再使用的孤立软件
sudo apt-get autoremove
如果使用
sudo apt-get autoremove --purge
的话会把这些孤立软件的残留配置文件也一并移除
查看包在服务器上面的地址
apt-get -qq --print-uris install ssh | cut -d\' -f2
彻底删除 Gnome
sudo apt-get --purge remove liborbit2
彻底删除 KDE
sudo apt-get --purge remove libqt3-mt libqtcore4
一键安装 LAMP 服务
sudo tasksel install lamp-server
删除旧内核
sudo aptitude purge ~ilinux-image-.*\(\!`uname -r`\)
导入 ppa 源的 key 值
#W: GPG 签名验证错误: http://ppa.launchpad.net jaunty Release: 由于没有公钥,下列签名
无法进行验证: NO_PUBKEY 5126890CDCC7AFE0
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 5126890CDCC7AFE0
#5126890CDCC7AFE0 替换为你需要导入的 Key 值
增加 add-apt-repository 命令
sudo apt-get install software-properties-common
增加一个 ppa 源
sudo add-apt-repository ppa:user/ppa-name
#使用 ppa 的地址替换 ppa:user/ppa-name
添加 163 镜像源
sudo add-apt-repository "deb http://mirrors.163.com/ubuntu/ `lsb_release -cs`
main restricted universe multiverse"
sudo add-apt-repository "deb http://mirrors.163.com/ubuntu/ `lsb_release
-cs`-updates main restricted universe multiverse"
sudo add-apt-repository "deb http://mirrors.163.com/ubuntu/ `lsb_release
-cs`-security main restricted universe multiverse"
系统升级
- 这里指的是版本间的升级,例如 9.04=>10.04。
- 使用该升级方式通常需要使用 backports 源。
sudo apt-get update
sudo apt-get install update-manager-core
sudo do-release-upgrade
系统查看内核
uname -a
查看系统是 32 位还是 64 位
#查看 long 的位数,返回 32 或 64
getconf LONG_BIT
#查看文件信息,包含 32-bit 就是 32 位,包含 64-bit 就是 64 位
file /sbin/init
或者使用
uname -m
查看ubuntu版本:
cat /etc/issue
或 cat /etc/lsb-release
此地址连接下文:http://www.ubuntukylin.com/ukyli … ead&tid=4579&extra=