3

I am new to Ubuntu, today I was learning how to delete files and folders but accidentally I deleted the /opt directory that located in Computer.

I don’t know if what I deleted is important or not. So I want to create the /opt directory again. where all other important folder exists and they are /var,/root, /home and so on.

1
  • drwxr-xr-x 5 root root 4096 sep 28 07:28 opt ;)
    – Rinzwind
    Oct 4, 2014 at 7:32

2 Answers 2

5

On a newly installed Ubuntu system, /opt exists but is empty. You can just run:

sudo mkdir /opt

And that will recreate it, with the correct permissions.

But if there was software installed inside when it was removed, that won't bring it back.

There probably wasn't, though. You'd likely have remembered installing it there. /opt is not usually for programs installed automatically through Ubuntu's package manager. Instead, for the most part it's used for programs that install with their own methods, often (but not only) proprietary payware installed from CD.

If you remember how you deleted /opt, a more specific prediction as to whether or not there was anything in it could be given. For example, if the way you remove it was to run sudo rmdir /opt, that will only work if the directory is empty. On the other hand, if you used rm -r, it needn't have been empty.

4
  • thnx. its works ..
    – jazz_razor
    Oct 4, 2014 at 7:43
  • +1 --- The only well-known and quite popular software I know that install itself on /opt is calibre (barring a couple of microcontroller-developing things that I do not think matter here).
    – Rmano
    Oct 4, 2014 at 8:38
  • 2
    Google Chrome also installs itself under /opt/
    – andol
    Oct 4, 2014 at 12:48
  • 2
    @Rmano there are more: teamviewer, jasperserver.
    – Rinzwind
    Oct 4, 2014 at 13:45
3

First of all, check what files may have been deleted with dpkg -S /opt or grep ^/opt /var/lib/dpkg/info/*.list. It should give you a list of packages that might need to be reinstalled. If none is, then just recreate the directory with a simple sudo mkdir /opt. You may also check if you have installed packages manually in those directories, but that's very tricky.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .