ubuntu下软件安装、卸载和管理方法汇总

来源:互联网 发布:js中怎么获取name属性 编辑:程序博客网 时间:2024/05/18 03:29


1、软件安装

1.1 使用apt-get相关命令安装(安装时必须取得root权限),该命令搜索自己系统上所添加的源目录里提供的软件包。

相关命令:

sudo apt-get install packageName #(此外,为了安装该包的特定版本,可以apt-get install packageName=version)

sudo apt-get --reinstall install packageName  #修复软件包


此时为了查询某个包的信息,可以

apt-cache search packageName #在源中搜素名字中含有packageName的包

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

apt-cache depends package  #了解使用依赖

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


如果自己系统上源有修改,需要更新本机系统上缓存文件使其与源服务器一致

sudo apt-get  update #更新本系统缓存文件

sudo apt-get upgrade #更新本机上已安装的包

sudo apt-get dist-upgrade #升级系统


为了清除不必要的包,可以

sudo apt-get clean #这会清理/var/cache/apt/archives/ 和 /var/cache/apt/archives/partial/(用apt-get安装软件包时,其deb包都存在这两个目录中)中没有被锁定的文件。当然你再次安装软件的时候,这个软件又被恢复到本地文档库中了。

sudo apt-get autoclean #这会清理旧版本的/var/cache/apt/archives/ 和 /var/cache/apt/archives/partial/中的文件。旧版本是指已经有更新的版本的软件了,再下载的话应下载最新的而不是这个旧版本的了。根据apt-show-versions -p可以知道哪些是旧的。


1.2、使用新立得图形化软件包管理器(synaptic)

很多发行版的系统里已经默认安装了synaptic,若没有安装,可以用前面介绍的 sudo apt-get install synaptic来安装。synaptic图形界面提供了源中可安装的各个包的情况,使用情况比较容易,可以根据图形界面操作。


1.3、利用.deb包安装

.deb是Debian软件包格式的文件拓展名,.deb包是Unixar的标准归档,将包文件信息以及包内容,经过gzip和tar打包而成。Ubuntu系统也以.deb包形式管理软件包,处理这些包的经典程序是dpkg。deb包在Linux操作系统中类似于windows中的软件包(exe)。可在网上自行下载相应软件的.deb包,然后利用dpkg命令处理

dpkg -i package.deb安装包dpkg -r package删除包dpkg -P package删除包(包括配置文件)dpkg -L package列出与该包关联的文件dpkg -l package显示该包的版本dpkg –unpack package.deb解开 deb 包的内容dpkg -S keyword搜索所属的包内容dpkg -l列出当前已安装的包dpkg -c package.deb列出 deb 包的内容dpkg –configure package配置包

1.4、利用源码安装(.gz,.bz2等源码压缩包)

.gz,.bz2是软件的源码经过压缩得到的包,利用该源码方式安装软件时可以在网上下载相关源码,

解压包

tar -xzf 压缩包.gz 目标目录

tar -xjf 压缩包.bz2 目标目录

以解压软件包,然后通过执行

./configure 

来进行配置,执行

make

来进行编译,执行make install

来进行安装,这里边每条命令都有详细的参数以完成完善复杂的功能,详请参阅每个命令的帮助文档。


2、卸载软件包

对应上面每一种安装方式,都有相对应的卸载方式。

2.1 apt-get安装的软件包

sudo apt-get remove packageName #移除式卸载,移除软件包:
sudo apt-get --purge remove packageName #清除式卸载,把与软件安装有关的配置一起卸载


2.2 新立得软件包管理器,在图形界面选择相应的包,点击remove即可

2.3 dpkg包管理器安装的软件包

移除式卸载:dpkg -r xxx
清除式卸载:dpkg -P xxx

2.4 源码安装

直接删除安装软件的目录即可


对于上面介绍的4种软件安装与卸载几乎可以应对ubuntu上软件包的安装了。但有时可能会用到rpm包(Red Package Manager ,红帽软件包管理器)安装,这时可以先安装alien软件包,利用alien命令将rpm软件包转换为.deb包,再利用dpkg命令来安装和卸载。


3、update-alternatives 命令管理系统命令的符号链接

update-alternatives是dpkg的实用工具,用来维护系统命令的符号链接,以决定系统默认使用什么命令。在Debian系统中,我们可能会同时安装有很多功能类似的程序和可选配置,如Web浏览器程序(firefox,konqueror)、窗口管理器(wmaker、metacity)和鼠标的不同主题等。这样,用户在使用系统时就可进行选择,以满足自已的需求。但对于普通用户来说,在这些程序间进行选择配置会较困难。update-alternatives工具就是为了解决这个问题,帮助用户能方便地选择自已喜欢程序和配置系统功能。下面一个显示可选的窗口管理器的示例:

root@debian:~# update-alternatives --display x-window-managerx-window-manager - status is auto.                 #当前配置状态为自动方式 link currently points to /usr/bin/metacity        #当前的窗口管理器是metacity/usr/X11R6/bin/twm - priority 40                   #下面是可选的窗口管理器列表,后面的数字表示优先级 slave x-window-manager.1.gz: /usr/X11R6/man/man1/twm.1x.gz/usr/bin/wmaker - priority 50 slave x-window-manager.1.gz: /usr/share/man/man1/wmaker.1x.gz/usr/bin/larswm - priority 20 slave x-window-manager.1.gz: /usr/share/man/man1/larswm.1x.gz/usr/bin/fluxbox - priority 50 slave x-window-manager.1.gz: /usr/share/man/man1/fluxbox.1.gz/usr/bin/xfwm - priority 20 slave x-window-manager.1.gz: /usr/share/man/man1/xfwm.1.gz/usr/bin/icewm - priority 50 slave x-window-manager.1.gz: /usr/share/man/man1/icewm.1x.gz/usr/bin/metacity - priority 60 slave x-window-manager.1.gz: /usr/share/man/man1/metacity.1.gzCurrent `best' version is /usr/bin/metacity.        #自动选择方式会选择优先级高的程序

重新设置窗口管理器方法:

root@debian:~# update-alternatives --config x-window-managerThere are 7 alternatives which provide `x-window-manager'.  Selection    Alternative-----------------------------------------------      1        /usr/X11R6/bin/twm      2        /usr/bin/wmaker      3        /usr/bin/larswm      4        /usr/bin/fluxbox      5        /usr/bin/xfwm      6        /usr/bin/icewm*+    7        /usr/bin/metacityPress enter to keep the default[*], or type selection number:

星号表示当前系统使用的,加号表示优先级最高的。输入数值可修改默认配置,直接按回车保持原来状态。

修改debian系统默认浏览器的示例:

debian:~#update-alternatives --config x-www-browserThere are 3 alternatives which provide `x-www-browser'.  Selection    Alternative-----------------------------------------------      1        /usr/bin/mozilla*+    2        /usr/bin/epiphany      3        /usr/bin/mozilla-firefoxPress enter to keep the default[*], or type selection number: 3Using `/usr/bin/mozilla-firefox' to provide `x-www-browser'.

下面再举一个通过update-alternatives修改鼠标主题的示例。

同上示例,通过以下命令可列出当前鼠标可用主题:

root@debian:~# update-alternatives --config x-cursor-themeThere are 5 alternatives which provide `x-cursor-theme'.  Selection    Alternative-----------------------------------------------      1        /etc/X11/cursors/core.theme      2        /etc/X11/cursors/redglass.theme      3        /etc/X11/cursors/whiteglass.theme      4        /etc/X11/cursors/handhelds.theme*+    5        /usr/share/themes/Industrial/cursor.themePress enter to keep the default[*], or type selection number:

现在我们从网上下载一个新的主题,要把它安装到系统上,并设置新安装的鼠标主题为默认配置。

  • 我下载了一个5507-Golden-XCursors-3D-0.8.tar.bz2鼠标主题,解压后生成Golden-XCursors-3D-0.8目录,该目录下有两个目录,一个是default目录,存放索引文件;一个是Gold目录,存放主题内容。

  • 将包中Gold目录拷贝到/usr/X11R6/lib/X11/icons中。

  • 将包中default/index.theme拷贝到/usr/X11R6/lib/X11/icons/default中。

  • 将包中default目录中的index.theme改名拷贝成/etc/X11/cursors/Gold.theme。

  • 安装主题

    root@debian:~# cd /etc/alternativesroot@debian:/etc/alternatives# update-alternatives --install x-cursor-theme x-cursor-theme /etc/X11/cursors/Gold.theme 70
  • 由于我系统的x-cursor-theme使用了自动配置方式,而优先级70为最高级别,所以Gold.theme已自动设置为默认配置了,我们可用以命令查询:

    root@debian:/etc/alternatives# update-alternatives --display x-cursor-themex-cursor-theme - status is auto. link currently points to /etc/X11/cursors/Gold.theme/etc/X11/cursors/core.theme - priority 30/etc/X11/cursors/redglass.theme - priority 20/etc/X11/cursors/whiteglass.theme - priority 20/etc/X11/cursors/handhelds.theme - priority 20/usr/share/themes/Industrial/cursor.theme - priority 40/etc/X11/cursors/Gold.theme - priority 70Current `best' version is /etc/X11/cursors/Gold.theme.
  • 这样鼠标主题已生效。你试一下把光标指向桌面的快捷方式上,是不是出现了一个金手指。



0 0
原创粉丝点击