2011年6月12日星期日

apt 常用命令一览表

apt-cache search package 搜索包

apt-cache show package 获取包的相关信息,如说明、大小、版本等

sudo apt-get install package 安装包

sudo apt-get install package - - reinstall 重新安装包

sudo apt-get -f install 修复安装"-f = ——fix-missing"

sudo apt-get remove package 删除包

sudo apt-get remove package - - purge 删除包,包括删除配置文件等

sudo apt-get update 更新源

sudo apt-get upgrade 更新已安装的包

sudo apt-get dist-upgrade 升级系统

sudo apt-get dselect-upgrade 使用 dselect 升级

apt-cache depends package 了解使用依赖

apt-cache rdepends package 是查看该包被哪些包依赖

sudo apt-get build-dep package 安装相关的编译环境

apt-get source package 下载该包的源代码

sudo apt-get clean && sudo apt-get autoclean 清理无用的包

sudo apt-get check 检查是否有损坏的依赖

Linux 升级内核后删除旧版本内核

Command 1 :查看内核版本
shuxinwei@ubuntu:~$ uname -r

shuxinwei@ubuntu:~$ uname -r
2.6.35-28-generic


Command 2 :列出所有安装的内核
shuxinwei@ubuntu:~$ dpkg --get-selections|grep linux

shuxinwei@ubuntu:~$ dpkg --get-selections|grep linux
libselinux1 install
linux-firmware install
linux-generic install
linux-headers-2.6.35-22 install
linux-headers-2.6.35-22-generic install
linux-headers-2.6.35-28 install
linux-headers-2.6.35-28-generic install
linux-headers-generic install
linux-image-2.6.35-22-generic install
linux-image-2.6.35-28-generic install
linux-image-generic install
linux-libc-dev install
linux-sound-base install
pptp-linux install
syslinux install
syslinux-common install
util-linux install


Command 3 :删除旧版本内核
shuxinwei@ubuntu:~$ sudo apt-get remove linux-image-2.6.35.22-generic

shuxinwei@ubuntu:~$ sudo apt-get remove linux-image-2.6.35.22-generic
[sudo] password for shuxinwei:
Reading package lists... Done
Building dependency tree    
Reading state information... Done
Note, selecting 'linux-image-2.6.35-22-generic' for regex 'linux-image-2.6.35.22-generic'
Note, selecting 'linux-image-2.6.35-22-generic-pae' for regex 'linux-image-2.6.35.22-generic'
Package linux-image-2.6.35-22-generic-pae is not installed, so not removed
The following packages will be REMOVED:
  linux-image-2.6.35-22-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 107MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 144479 files and directories currently installed.)
Removing linux-image-2.6.35-22-generic ...
Examining /etc/kernel/prerm.d.
run-parts: executing /etc/kernel/prerm.d/dkms 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
dkms: uninstalling: fglrx 8.780 (2.6.35-22-generic) (i686)

-------- Uninstall Beginning --------
Module:  fglrx
Version: 8.780
Kernel:  2.6.35-22-generic (i686)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

fglrx.ko:
 - Uninstallation
   - Deleting from: /lib/modules/2.6.35-22-generic/updates/dkms/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
depmod......

DKMS: uninstall Completed.
Examining /etc/kernel/postrm.d .
run-parts: executing /etc/kernel/postrm.d/initramfs-tools 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
run-parts: executing /etc/kernel/postrm.d/zz-update-grub 2.6.35-22-generic /boot/vmlinuz-2.6.35-22-generic
Generating grub.cfg ...
cat: /boot/grub/video.lst: No such file or directory
Found linux image: /boot/vmlinuz-2.6.35-28-generic
Found initrd image: /boot/initrd.img-2.6.35-28-generic
Found Windows 7 (loader) on /dev/sda1
done
The link /vmlinuz.old is a damaged link
Removing symbolic link vmlinuz.old
 you may need to re-run your boot loader[grub]
The link /initrd.img.old is a damaged link
Removing symbolic link initrd.img.old
 you may need to re-run your boot loader[grub]