Current revision as of 00:36, 13 May 2014
Package Installation and Updates
Apt and Package Basics
- Install packages:
sudo apt-get install packagename
sudo apt-get install mpd sbackup
- Remove packages:
sudo apt-get remove packagename
- To remove all dependencies:
sudo apt-get autoremove
sudo apt-get remove mpd sbackup
- Search for packages:
sudo apt-cache search <keywords>
sudo apt-cache search Music MP3 sudo apt-cache search "Text Editor"
- Update the apt package database after adding/removing repositories:
sudo apt-get update
- Upgrade packages:
sudo apt-get upgrade
- Upgrade the entire distribution (e.g. from Lucid to Maverick):
sudo apt-get dist-upgrade
Installing .deb packages
Debian (.deb) packages are the packages that are used in Ubuntu/Kubuntu. You can install any .deb package in your system. .deb files can generally be installed from your file manager (Konqueror or Dolphin) merely by clicking on them, since file associations with the default installer is already set in Kubuntu. These instructions are for those who wish to install packages from the command-line terminal (Konsole).
- Install a downloaded Debian (Ubuntu/Kubuntu) package (.deb):
sudo dpkg -i packagename.deb
- Remove a Debian (Ubuntu/Kubuntu) package (.deb):
sudo dpkg -r packagename
- Reconfigure/Repair an installed Debian (Ubuntu/Kubuntu) package (.deb):
sudo dpkg-reconfigure packagename
sudo dpkg-reconfigure mpd
Handling (Tar/GZip) and (Tar/Bzip2) archives
(Tar/GZip) archives end in ".tar.gz" and (Tar/Bzip2) archives end in ".tar.bz2". Bzip2 is the newer, more efficient compression method. These files can generally be automatically extracted by merely clicking on them from your file manager (Konqueror or Dolphin), since file associations with the appropriate archival utilities are set by default in Kubuntu. These instructions are for those who wish to use the command line terminal (Konsole).
- To extract:
tar xvf packagename.tar.gz
Note: tar is an application which can extract files from an archive, decompressing if necessary.
- -x means extract.
- -v means verbose (list what it is extracting).
- -f specifies the file to use.
- Decompressing ".gz" files
- Decompressing ".bz2" files
- Note: You can also decompress a package first by using the command gunzip (for .gz) or bunzip2 (for .bz2), leaving the .tar file. You would then use tar to extract it.
- To create a .gz archive:
tar cvfz packagename.tar.gz folder
- To create a .bz2 archive:
tar cvfj packagename.tar.bz2 folder
Installing a package from source
- Make sure you have all the necessary development tools (i.e. libraries, compilers, headers):
sudo apt-get install build-essential linux-headers-$(uname -r)
- Note: "uname -r" lists the current kernel you are using
- Extract the archive that contains the source files:
tar xvf sourcefilesarchive.tar.gz
- Build the package using the package's script (in this case the configure script), compile the package (make), and install the compiled package into your system (make install):
cd /path/to/extracted/sourcefiles ./configure sudo make sudo make install
- Note: typing ./ before a filename in the current folder allows the Linux shell to try and execute the file as an application even if it is not in the path (the set of folders which it searches when you type a command name). If you get a "permission denied" error, the file is not marked as being executable. To fix this:
sudo chmod +x filename
- Example: In the above instructions, configure is the shell script to build the package from source. To be sure the configure script is executable:
sudo chmod +x configure
Create a .deb package from source files
If your build from source is successful, you can make a Debian (Ubuntu/Kubuntu) package (.deb) for future use:
- Install package tools:
sudo apt-get install checkinstall
- Rebuild package using "checkinstall":
cd /path/to/extracted/package ./configure sudo make sudo checkinstall
- Keep the resulting ".deb" file for future use. It can later be installed using:
sudo dpkg -i packagename.deb
Note: These are basic instructions that may not always work. Some packages require additional dependencies and optional parameters to be specified in order to build them successfully. More info about .deb package structure can be found here.
Muon Package Manager
- In Trusty, the classic Muon Package Manager has been removed. Install the Gtk-based Synaptic Package Manager instead (or install packages using the command-line as outlined in the rest of this guide).
- Muon Discover is a software center that is the remains of the older Muon Package Management Suite. A limited number of packages can be installed using it.
- K Menu -> System -> Muon Discover
Synaptic Package Manager
Synaptic Package Manager is the GTK-based GUI package manager for Gnome/Ubuntu. It can be used in Kubuntu without difficulty. Usage is similar to the other package managers. Install:
sudo apt-get install synaptic
While "apt-get" is a fast way of installing programs/packages, you can also use Synaptic for installing programs/packages. Most (but not all) programs/packages available with apt-get install will also be available from Synaptic and is the preferred method for many desktop users. In this guide, when you see
sudo apt-get install package
you can simply search for package in Synaptic and install it that way.
- Menu -> System -> Synaptic Package Manager
- Search for the name of the program/package. You can also search for a word in its description.
- Right-click on the name of the package -> "Mark for Installation". (If the program is already installed, use "Mark for Removal" or "Mark for Purge" to remove it).
- Click Apply Changes.
- The selected program(s) will be automatically installed (or removed), along with its dependencies.
- Manually, from the Konsole terminal (command line interface):
sudo apt-get update sudo apt-get upgrade sudo apt-get install linux-headers-$(uname -r)
- The Muon Update Manager can be used to manage package updates:
- K Menu -> System -> Muon Update Manager
- Muon Discover can be used to configure the update schedule and types of updates:
- K Menu -> Muon Discover -> Configure Software Sources -> Updates
Turn off Update Notifications
- To turn off the the Update Notifications (in the Panel Taskbar and/or Popups), use the Muon Update Manager:
- System -> Muon Update Manager -> More ... -> Configure Muon Update Manager ... -> Show notifications for available updates (unticked)
Repair broken packages
If a package installation fails (which can cause a Package Manager to freeze or become locked), or if a package has unsatisfied dependencies causing a similar condition, then run one (or both) of the following commands from the command-line terminal:
sudo apt-get install -f sudo dpkg --configure -a
- If a problem occurs with MergeList (appearing as a missing "Package: header" error):
E: Encountered a section with no Package: header E: Problem with MergeList... E: The package lists or status file could not be parsed or opened.
- then repair by recreating the package lists:
sudo rm /var/lib/apt/lists/* -vf sudo apt-get update
- If a problem occurs with a lock on the apt cache, for example:
E: Could not get lock /var/cache/apt/archives/lock - open (11: Resource temporarily unavailable)
- then delete the locks:
sudo fuser -cuk /var/lib/dpkg/lock sudo rm -f /var/lib/dpkg/lock sudo fuser -cuk /var/cache/apt/archives/lock sudo rm -f /var/cache/apt/archives/lock