Installing git "sudo: apt-get: command not found"
Solution 1
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.
Solution 2
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
Related videos on Youtube
Roger Sanchez
Updated on September 18, 2022Comments
-
Roger Sanchez over 1 year
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?
-
Admin about 12 yearsWhat Linux distribution are you using?
-
Admin about 12 yearsI think it is
2.6.9-023stab048.6-enterprise #1 SMP
-
Admin about 12 yearsSorry it is
CentOS release 5.2 (Final)
-
Admin about 12 yearsCentOS uses
yum
if I'm not mistaken. -
Admin about 12 yearsso what should I do? what is the comand I should use?
-
-
Roger Sanchez about 12 yearsThank you for answering. I'm getting
-bash: command: apt-get: not found
for the first one. andapt-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 -
alemani about 12 years@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. -
Roger Sanchez about 12 yearsit is yum, centos. what should I try with yum then?
-
alemani about 12 years@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>
becomesyum install <package_name>
be aware that different distros have different package names. -
Admin over 7 yearsIt looks like
packages.sw.be
is now dead. Its timing out. -
Edd almost 7 yearsThat's a shame :( If anyone knows anywhere else where that rpm can be obtained from then it'd be great to update the answer, although given CentOS 6 has been around since 2011 and git was available in the default repository this will hopefully become less and less of a problem for people over time.
-
Admin almost 7 yearsI added my build script in an Answer below to build Git from sources. I gave up trying to find trusted sources for third party repos with the package.
-
Admin almost 7 yearsRpmforge is dead for at least 1 year - github.com/repoforge/rpms/issues/375