I was doing some stuff on my Ubuntu PC, when I did
sudo apt-get autoremove tar
and messed up my computer. I apparently wanted to reinstall tar, but instead removed it thinking I would install it after it is removed. This was a mistake and I regret doing it.
Now, I can hardly do anything with tar not installed in my computer. I can't install any packages using apt-get
, neither can I install packages using dpkg
. I tried downloading a .deb
file of tar and installing it in my computer using dpkg
, but as I said I couldn't do that either.
I can't install tar using apt-get
either, so I couldn't figure out how to install tar in my computer again.
I tried searching on websites including AU, but couldn't find a solution to this.
How can you install tar without having tar installed in your computer? (solutions with apt-get, dpkg etc will not work) I'm on Ubuntu 14.04 LTS.
Best Answer
I solved the problem with some hacky workarounds, but it works. Might not be the best way to solve the problem though. I got the answer by following some parts of @steeldriver's comment and adding some of my own.
First you need to download the .deb file for tar.
Go to you Downloads folder, by using the command
and then doing
to make sure the download succeeded. You should get an output similar to
If not, you should try downloading again.
I'm going to use the name
mytar.deb
for the answer, but replace that with the real name of your.deb
fileNow, you need to extract the contents of the
.deb
file without using tar.First do
which will extract the files from the archive into the current directory. To list the files present, do
which will output something similar to
data.tar.xz
contains the actual files which we need to copy. We cannot usetar
to extract them because our current computer does not have the tar command.First lets convert
data.tar.xz
todata.tar
. To do this, dowhich should create a new file
data.tar
.Now, we need to create a link to busybox as mentioned by @steeldriver in the comments. So do
to create a symlink.
Then, you basically are using busybox instead of tar. So if you use the command tar, it invokes busybox instead. Now do
to create a dummy directory. Then
to extract the
.tar
file and dump its contents in the directorytemp
. Change the working directory totemp
by usingThen do,
to get an output like
If you do not get the folders like
bin
,etc
, andusr
, you have made some mistake.Now, you can just copy all the files in those folders to the actual destinations (
/bin/tar
,/usr/local/bin/tar
etc), and then doIf you get an output showing the commands of tar, it works!
Now do
which should reinstall tar. If it gives you an error saying to run
apt-get -f install
, do that and then reinstall tar, it worked for me on Ubuntu 14.04 LTS.