Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to install git. I run the following command:

sudo apt-get install git-core git-gui git-doc

But receive the following error: sudo: apt-get: command not found

What should I do?

share|improve this question
What Linux distribution are you using? – jofel Mar 7 '12 at 18:30
I think it is 2.6.9-023stab048.6-enterprise #1 SMP – Lucy Weatherford Mar 7 '12 at 18:36
Sorry it is CentOS release 5.2 (Final) – Lucy Weatherford Mar 7 '12 at 18:40
CentOS uses yum if I'm not mistaken. – Lekensteyn Mar 7 '12 at 18:49
so what should I do? what is the comand I should use? – Lucy Weatherford Mar 7 '12 at 19:59

Since you're using CentOS 5, the default package manager is yum, not apt-get. To install a program using it, you'd normally use the following command:

$ sudo yum install <packagename>

However, when trying to install git this way, you'll encounter the following error on CentOS 5:

$ sudo yum install git
Setting up Install Process
Parsing package install arguments
No package git available.
Nothing to do

This tells you that the package repositories that yum knows about don't contain the required rpms (RPM Package Manager files) to install git. This is presumably because CentOS 5 is based on RHEL 5, which was released in 2007, before git was considered a mature version control system. To get around this problem, we need to add additional repositories to the list that yum uses (We're going to add the RPMforge repository, as per these instructions).

This assumes you want the i386 packages. Test by running uname -i. If you want the x86_64 packages, replace all occurrences of i386 with x86_64 in the following commands

First, download the rpmforge-release package:

$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm

Next, verify and install the package:

$ sudo rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
$ rpm -K rpmforge-release-0.5.3-1.el5.rf.i386.rpm
$ sudo rpm -i rpmforge-release-0.5.3-1.el5.rf.i386.rpm

And now we should be able to install git:

$ sudo yum install git-gui

yum will work out the dependencies, and ask you at relevant points if you want to proceed. Press y for Yes, and n or return for No.

share|improve this answer

Are you using a Debian-related distro? If not, you may need to use a different package manager, like YUM (nowadays Red Hat, CentOS, etc.), Portage, Entropy, RPM, etc.

When using a Debian-related distro:

What does it give you?

$ command -V apt-get
apt-get is /usr/bin/apt-get

Is the binary really there?

$ file /usr/bin/apt-get
/usr/bin/apt-get: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
share|improve this answer
Thank you for answering. I'm getting -bash: command: apt-get: not found for the first one. and apt-get: ERROR: cannot open apt-get' (No such file or directory)` for the second.. So what does this mean? that it is not there? is there a replacement? should I add it somehow? how? is there any other way to install git? thanks – Lucy Weatherford Mar 7 '12 at 18:46
@LucyWeatherford Seems that you're not using a Debian related distro so an easy way to find which distro you are on is to run lsb_release -a finding the righ distro you're on will tell you what package manager is available e.g. YUM and RPM if you're using Red Hat or CentOS. – alemani Mar 7 '12 at 18:54
it is yum, centos. what should I try with yum then? – Lucy Weatherford Mar 7 '12 at 20:02
@LucyWeatherford Please read [link]centos.org/docs/4/html/yum/sn-managing-packages.html you need to understand the basics of managing packages with YUM if your background is APT you will find the equivalences between commands e.g. apt-get install <package_name> becomes yum install <package_name> be aware that different distros have different package names. – alemani Mar 7 '12 at 21:38

protected by Community Jun 30 '15 at 12:42

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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