3

I read many articles on the internet about how to install a program on Linux, for example Ubuntu, but I'm still confused!

What I understand 'till now is:

  1. First, we should add repository that contains our intended package. In Ubuntu, it will be done by un-commenting the related line in /etc/apt/sources.list file.

  2. Then we should update our repository's package list by executing apt-get update.

  3. at the end, install our program by executing apt install.

... but still I can't understand!

  1. When we un-comment a repository in sources.list, does that mean that we tell the OS: "download this repository on my computer"? Is it needed that repository be downloaded at all? If not, so what happen in the system by un-commenting a line in sources.list?

  2. What exactly apt-get update does? as I read :

     apt-get update downloads the package lists from the repositories and
    "updates" them to get information on the newest versions of packages
     and their dependencies.
    

What does that mean exactly? We have a repository with some packages; does that means that some repositories may be out of date? So why instead they don't update repositories on the server that would be always up to date and nobody need to do apt-get update?

5

When we un-comment a repository in sources.list, does that mean that we tell the OS: "download this repository on my computer"?

No.

Is it needed that repository be downloaded at all?

Not usually. Unless you want to download possibly hundreds of gigabytes.

If not, so what happen in the system by un-commenting a line in sources.list?

Nothing much, yet.

We have a repository, it has some packages, does that means that some repositories may be out of date?

Repositories can be out of date, yes, but that's not what's being talked about here.

So why instead they don't update repositories on the server that would be always up to date and nobody need to do apt-get update?

It doesn't quite work that way. What happens is this:

  1. Repositories contain packages, true, but they also contain information about those packages (metadata): package names, versions, dependencies of the packages, list of files that the packages contain, hashes of the packages and so on.
  2. apt-get update downloads this metadata.
  3. apt-get install, upgrade, etc. then uses this metadata when you tell it to install a package - it checks available versions, checks whether additional packages needed to installed as dependencies, and so on.
  4. When the repository gets updated, the metadata will get updated to, but your local copy that was downloaded earlier won't. This is natural, you don't want your PC constantly checking with the server if your copy of the metadata is outdated.
  5. Now next time you need to install a package, you could face problems, because your system has outdated metadata, so it can't figure out the correct thing to do.
  6. Then you need to run apt-get update to update this metadata.
  7. When you uncomment the source line, nothing has happened yet, as I said. The next time you run apt-get update, it will download metadata from that source too. And the next time after that when you install, upgrade or remove packages, apt will consider the additional metadata when figuring out things.

That's how apt works. Yum, on the other hand, checks for updated metadata and downloads it whenever you add, remove or upgrade packages. Both methods have their pros and cons.

  • very good explanation, now I get it! thanks a lot muru – feel free Jul 12 at 13:36
3

TL;DR

If you're coming from Windows, you might be a bit confused as in Windows, you can download and install software from wherever. In Linux that is possible as well, but should only be uses as a last resort! (read the long version for more detailed info)

Here are the short answers to your questions:

  1. "uncommenting" a repository makes it available. As you've confused already, don't uncomment any repositories unless you find a reliable source telling you to do so specifically to be able to install a specific piece of software. (again: read the long version)

  2. Afer adding a software source by uncommenting it or by adding a PPA (again: read the long version), the local list of available software must be updated to ensure that you don't run into something called "dependency hell".

so please use the following guidelines when installing software on Ubuntu:

The long version:

16.04 and higher: Ubuntu Software Center has been renamed to Ubuntu Software

(Everything else remains the same)

The most important thing is to remember that some day you'll have to remove this piece of software that you're going to install, so always use a removal method identical to your installation method.

Therefore, use the following priority for installing software on Ubuntu:

  1. Forget about what you know about downloading and installing from websites all over the place and use the following priority list on how to install software under Ubuntu because you now have (and want to keep) a stable system.
  2. For beginning users: first 3 months, up to a year of using Ubuntu
    Install/remove from the standard Ubuntu repositories using the GUI of the Ubuntu Software (Center).

    As per below screen shot, click the dash in the upper left corner, type software, click the Ubuntu Software(Center).

    Opening Ubuntu SW Center

    The Ubuntu Software (Center) opens:

    Ubuntu SW Center Start

    and you have a ton of application categories on the left to choose from. Or type the name of the software in the search box in the top right corner (which is what we'll be using)

    Crap software

    I'm as amazed as you, but there is indeed crap software for Ubuntu, :-) so just click the crap you want, click on "Install", wait a bit and done!

    To remove software using this method, click on the "installed" button on the second screen shot, click the crap you want to uninstall and click the "Uninstall" button! Easy-peasy.

    And if the software is not there, don't go downloading it from somewhere else and install it using some of the more advanced features below! You're a beginner!

  3. (Intermediate users, 6 months-1 year of experience)
    Use the TUI of aptitude
    Press Ctrl+Alt+T to go to a terminal and type:

    sudo aptitude
    

    and press Enter

    If you get aptitude: command not found, type:

    sudo apt install aptitude
    

    to install aptitude and wait until nothing moves any more and then type:

    sudo aptitude
    

    to start it.

    screenshot aptitude

    This is still kind of familiar: you can use the mouse, but it's like you're back in 1988 before the WWW was invented. And now comes the first hurdle: RTFM for aptitude by typing:

    man aptitude 
    

    This is important! aptitude can let you do more advanced things, but is a back-stabbing servant!

  4. Now on to more advanced stuff: (Use only when directed by knowledgeable people on this site having >5000 reputation + at least one gold badge)

    Press Ctrl+Alt+T and type:

    • apt install szPackageName to install
    • apt purge szPackageName to completely remove
    • apt remove szPackageName to remove the application, keeping its configuration files. (meaning: you might want to reinstall this sometime later and you just spent a few hours configuring the damn thing and don't want to lose the config!)
  5. Really advanced stuff: (Use only when directed by immortals, that is: knowledgeable people on this site having >10000 reputation + several gold badges)

    a. Download and install a .deb file: use dpkg --install szPackageName and dpkg --purge szPackageName and dpkg --remove szPackageName to install, completely remove and remove without config files.

    b. Install a PPA: clearly follow instructions. if anything goes wrong, copy-paste the error, ask a question on this site, insert a link to the question and answer you were following and report back to the immortal! ;-)

  6. 'Just download and build from source!!!'

    Probably a developer telling you this and he knows nothing about installing and maintaining a stable system without any problems, but has the coolest stuff on the planet!
    Depending on your point of view to be embraced with love or to be avoided like the plague.

    So if you do download and build from source, use CheckInstall instead of make install to be able to remove this software more easily in the future, like in this example regardless of what the developer says!

Source

  • woooow! so useful guides! really thank you Fabby – feel free Jul 12 at 13:37
  • @feelfree Please don't thank me! ;-) If this answer did help, just click the little grey at the left of this text right now turning it into beautiful green. If you do not like the answer, click on the little grey down-arrow below the number, and if you really like the answer, click on the little grey ☑ and the little up-arrow... If you have any further questions, just ask another one! ;-) – Fabby Jul 12 at 14:08
  • i did so, but it said "Thanks for the feedback! Votes cast by those with less than 15 reputation are recorded, but do not change the publicly displayed post score.", and i have 11 reputations! sorry buddy, i just wanted to thank you. – feel free Jul 12 at 15:44
  • There is still the ☑ you can click, but if you cannot find it: You're welcome! ;-) – Fabby Jul 12 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.