Why can't I extract a .rar archive?

45,567

First of all, don't use sudo for this. This can cause permissions issues and, when used in combination with x which extracts the archive with the full path, might result in inadvertently overwriting important system files. Instead, just use unrar x file.rar.

Now, the error you are getting is most likley because you have saved the file in directory X but are running the command from directory Y. For example, you have saved the file in /home/superpajamarama/Downloads and are running the command from /home/superpajamarama/.

To avoid this kind of thing, always use tab completion for file names in the terminal. Start typing the name of the file, and then hit tab:

unrar x file<TAB>

That will give you the possible completions and will let you know that the file is there.

Anyway, you need to either move into the correct directory, for example:

cd /home/superpajamarama/Downloads
unrar x filename.rar

Or give the full path to the file:

unrar x /home/superpajamarama/Downloads/filename.rar

In your case, the problem is that your path has a space in it. You need to either escape that space with a \ or quote the path:

unrar x "~/Desktop/PS2 Games/Futurama.rar" 

or

unrar x ~/Desktop/PS2\ Games/Futurama.rar
Share:
45,567

Related videos on Youtube

Superpajamarama
Author by

Superpajamarama

Updated on September 18, 2022

Comments

  • Superpajamarama
    Superpajamarama over 1 year

    I have installed unrar and have been using the command sudo unrar x filename.rar in the terminal but it gives me this error:

    No such file or directory, No file to extract
    

    I have looked through all the answers of other people's questions and none of them are working for me. Any ideas?

    • Avinash Raj
      Avinash Raj about 10 years
      where is the filename.rar located?
    • Takkat
      Takkat about 10 years
      Why sudo? It's pretty dangerous to unrar x with root permissions.
    • Sadi
      Sadi about 10 years
      Have you tried unrar x '/Full/Path/Fiename.rar'?
    • Superpajamarama
      Superpajamarama about 10 years
      @Sudheer :I have tried that and it says "an error occurred while extracting files".
    • Superpajamarama
      Superpajamarama about 10 years
      @Takkat :I have limited knowledge of this. So why is it dangerous to unrar whith root permissions?
    • Takkat
      Takkat about 10 years
      Terdon wrote all about issues from sudo + unrar in his nice answer
  • Superpajamarama
    Superpajamarama about 10 years
    Thank you for the explanation. It still seems not to be working. I went into properties of the the file and copied the file location, still thinks it doesn't exist. Could there be something wrong with the file?
  • terdon
    terdon about 10 years
    @Superpajamarama not with the message you receive, that just means your are looking in the wrong place. Where is the file? In which directory? What's the exact command you tried that failed? The one where you used the location from the properties.
  • Superpajamarama
    Superpajamarama about 10 years
    It's weird, It's just sitting in a folder on my desktop. I went and copied the file location from properties of the file. I also tried using TAB like you said to complete the file name but to avail...
  • terdon
    terdon about 10 years
    @Superpajamarama if tab failed, you're not looking in the right place. Could you tell me the exact location of the file and the exact command you ran as I asked please? If your file is in a folder called foo in your desktop, you want to run unrar x ~/Desktop/foo/file.rar.
  • Superpajamarama
    Superpajamarama about 10 years
    @tendon Oh yea sorry it's under /home/superpajamarama/Desktop/PS2 Games/Futurama.rar that is the full path I believe.
  • terdon
    terdon about 10 years
    @Superpajamarama Aaaa! OK, you have spaces in the path! Next time, please include the exact command and the exact error message. Had you done so, I would have realized that your file is called foo bar but the error was about foo. Anyway, try this: unrar x "~/Desktop/PS2 Games/Futurama.rar" or unrar x "~/Desktop/PS2<TAB> and it will autocomplete or unrar x ~/Desktop/PS2\ Games/Futurama.rar
  • Superpajamarama
    Superpajamarama about 10 years
    Oh right sorry about that thanks for the advice :P. It did the auto complete perfectly. The only thing is now, it's saying /home/superpajamarama/Desktop/PS2 Games/Futurama.rar is not RAR archive No files to extract... So is it a problem with the file now?
  • Freedo
    Freedo almost 4 years
    how do to this recursive? unrar -e -r *.rar doesn't work and unrar x *.rar also doesn't work
  • terdon
    terdon almost 4 years
    @Freedo please ask a new question. Explain what you mean by recursive, include an example of the directory structure you want to recurse into and tell us exactly what "doesn't work" means.