Debian: how to install software/update the system with apt

DON'T post new tutorials here! Please use the "Pending Submissions" board so the staff can review them first.
Post Reply
User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Debian: how to install software/update the system with apt

Post by bad_brain »

although this HowTo is about Debian's package manager named apt-get it's pretty similar on other distros, just the package managers are different (on Fedora it's yum instead of apt-get, but the commands are mostly the same).

alright, let's start:

basics
apt-get is the package manager for Debian, you can use it to install/remove software. you use it in a shell, there is also a GUI version named aptitude but I focus on the shell version.
the software you install via apt-get are pre-compiled packages stored in the Debian repositories.

what are those repositories?
repositories are like a library where you can pick the software you want and install them online. there are different repositories, first of course for the different Debian versions, but for the current version are also different repositories. why? take a look at the repository names:
- stable
- oldstable
- testing
- experimental
- unstable
pretty self explanatory I think. if a package from the testing repository has been tested long enough it can be labeled as stable and moved to the stable repository. if you're into adventures feel free to use any repository you want, but for beginners and/or systems which have to work reliable (servers for example) I highly recommend to use only the stable repository.

preconditions to use the repositories
how your Debian system knows which repository to use? the sources for the packages which should be searched are stated in the file sources.list , the file is located in /etc/apt/

let's take a look at my sources.list file:

Code: Select all

deb http://ftp.de.debian.org/debian/ sarge main contrib non-free
deb-src http://ftp.de.debian.org/debian/ sarge main contrib non-free
deb http://ftp.de.debian.org/debian-non-US/ sarge/non-US main contrib non-free
deb-src http://ftp.de.debian.org/debian-non-US/ sarge/non-US main contrib non-free
as you can see I use Debian sarge which is not the current version, the current one is etch. sarge is NOT outdated, and I even recommend it because I have experienced some problems with the current version (especially with the MySQL server).
Warning!
if you want to install Debian sarge make sure the box is NOT connected to the internet while installing! because in the default sources.list file the entries point to stable it'll download updates for Debian etch (which is now the stable version) and therefore the install will fail! so install while offline, when done edit the sources.list file and THEN get your updates manually.

if you want to use Debian etch you can stay online while installing, the first updates will be downloaded automatically then, just to be complete here's also the sources.list file for etch:

Code: Select all

# regular updates for etch
deb http://ftp.debian.org/debian/ etch main contrib non-free
deb-src http://ftp.debian.org/debian/ etch main contrib non-free

# security updates for etch
deb http://security.debian.org/ etch/updates main contrib non-free
deb-src http://security.debian.org/ etch/updates main contrib non-free
of course it's a good choice to pick a mirror in your country, for a list look here: http://www.debian.org/mirror/list , simply replace the URLs then.

what are those "non-free", "contrib", etc. about?
contrib
Packages in this area are freely licensed by the copyright holder but depend on other software that is not free.
Non-Free
Packages in this area have some onerous license condition restricting use or redistribution of the software.
Non-US/Main
Packages in this area are free themselves but cannot be exported from a server in the U.S.
Non-US/Non-Free
Packages in this area have some onerous license condition restricting use or redistribution of the software. They cannot be exported from the U.S. because they are encryption software packages that are not handled by the export control procedure that is used for the packages in Main or they cannot be stored on a server in the U.S because they are encumbered by patent issues.

don't worry, you will NEVER have to pay something for a package from the repositories... :wink:

Let's update the system!
once your sources.list file is edited you can do your first system update. uh-oh, sounds like much work, right? nope, all you have to do is:

Code: Select all

apt-get update
this only contacts the repositories and gets updates the list of available packages, always do this first! now your system can compare the installed package versions with the available ones. next step:

Code: Select all

apt-get upgrade
this will download and install the available updates for your system.
that's it! easy, huh? :)
you can do a re-check and upgrade again, you should get this output then:

Code: Select all

0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
alright, your system is fully updated now!

hey, it don't want to update some packages?!
sometimes you might get something like this:

Code: Select all

0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
no need to panic, everything is fine. the Debian package manager updates only packages of the same version, for example: you have package xxx1.9 installed, Debian will update it to xxx1.91, xxx1.92, etc, but NOT to xxx2.0. this is simply for stability reasons, maybe you want to keep 1.9 because you have installed something which will not work together yet with xxx2.0. but usually you can upgrade to the new package version, this is done by:

Code: Select all

apt-get dist-upgrade
now let's install some programs!
in the repositories not only updates are stored, you can also install completely new applications easily! the Debian repositories include more than 18.000 different packages, from new icon themes for your desktop to networking tools or servers, you can find almost anything there...and it's all for free!
if you want to browse through the repositories and look for interesting stuff: http://packages.debian.org/stable/
if you look for a specific package but don't know the actual name:
http://www.debian.org/distrib/packages#search_packages

http://www.debian.org is a bookmarking MUST for any Debian user anyway... :wink:

alright, let's say you found a package you want to install, let's pick nmap as an example. all you have to do is:

Code: Select all

apt-get install nmap
that's it! at this opportunity I have to mention that the Debian packages are not the newest ones, nmap is version 4.11 for example (current is 4.20), but well, I rather use an older version that's really stable instead of the newest (and maybe buggy) one.

how to remove packages again
that's as simple as installing, let's use nmap as example again:

Code: Select all

apt-get remove nmap
and again: that's it!

I hope you find my little HowTo useful, of course I can't go too much into details and list every option of apt-get because this HowTo is for beginners anyway. if you want to get deeper into it use the good old man command to display the manual:

Code: Select all

man apt-get
have fun! :)

User avatar
computathug
Administrator
Administrator
Posts: 2693
Joined: 29 Mar 2007, 16:00
17
Location: UK
Contact:

Post by computathug »

thanks b_b :D i think you know what i was going to ask next lol well i was on with this myself and run into a few problems and u have just answered them.

pseudo_opcode
cyber messiah
cyber messiah
Posts: 1201
Joined: 30 Apr 2006, 16:00
17
Location: 127.0.0.1

Post by pseudo_opcode »

lol nice post... did you actually type it yourself

p99
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 291
Joined: 14 Oct 2006, 16:00
17
Location: Some hippy's van
Contact:

Post by p99 »

Not positive but try out: apt-get cow
Works on ubuntu. I like sarge very much now. More than ubuntu I think.
And it actually came with gcc and g++. :P

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11636
Joined: 06 Apr 2005, 16:00
19
Location: In your eye floaters.
Contact:

Post by bad_brain »

of course I wrote it myself pseudo.... [-(

pseudo_opcode
cyber messiah
cyber messiah
Posts: 1201
Joined: 30 Apr 2006, 16:00
17
Location: 127.0.0.1

Post by pseudo_opcode »

bad_brain wrote:of course I wrote it myself pseudo.... [-(
Good work!! I think convert it to pdf and put it in download, if you want that inactive users should also read... :wink:

User avatar
computathug
Administrator
Administrator
Posts: 2693
Joined: 29 Mar 2007, 16:00
17
Location: UK
Contact:

adding more info!

Post by computathug »

As this post is relevant to this topic i shall post it here.

If you want to update all the packages other than one in your debian server follow this procedure

There are three ways of holding back packages, with dpkg, aptitude or with dselect.

Using dpkg

Put a package on hold

echo “package hold” | dpkg --set-selections

Example

echo “apache2 hold” | dpkg --set-selections

Remove the hold

echo “package install” | dpkg --set-selections

Example

echo “apache2 install” | dpkg --set-selections

Knowing the status of your packages

dpkg --set-selections

Using aptitude

With aptitude, you can hold a package using

#aptitude hold package_name

Example

#aptitude hold apache2

and remove the hold with

aptitude unhold package_name

Example

#aptitude unhold apache2

Using dselect

With dselect, you just have to enter the elect screen, find the package you wish to hold in its present state, and press the `=’ key (or `H’). The changes will go live immediately after you exit the elect screen.

credit to Admin @ debianadmin for this

User avatar
Still_Learning
Fame ! Where are the chicks?!
Fame ! Where are the chicks?!
Posts: 1040
Joined: 11 Jun 2008, 16:00
15
Location: Trigger City

Post by Still_Learning »

I forgot my pw on my debian system so i had to reformat again, since i just got a new flat screen for my new system. now i can run two pcs at once, the only thing is after i reformatted and installed debian again, i used the LVM? encryption method with the encryption and root PW being the same so i didnt have to write it down or remember 2 of them.

I got to the command prompt then did the startx and it booted KDE then the screen blacked out and it would not recognize my network to get online. I had to set the option to reconfig it later. then i just hit the reboot button on the box and now it just beeps when it trys to restart, any ideas? is my 486DX box finally dead?

Post Reply