Accidentally deleted /opt, how do I create it again?

5,280

Solution 1

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.

Solution 2

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.

Share:
5,280

Related videos on Youtube

Alexandra Macedo Lopes
Author by

Alexandra Macedo Lopes

Updated on September 18, 2022

Comments

  • Alexandra Macedo Lopes
    Alexandra Macedo Lopes over 1 year

    I have my form 1 and when I click in a button it opens my form 2. I want to introduce some information in this second form in order to uptade the first form. I tried this:

    Public class Form2
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    
        ... {some code here}
    
        Form1.Refresh()
        Me.Close()
    
        End Sub
    End Class
    

    But this isn't refreshing my form1. I know I can close the first form and open it again, but i don't pretend that. Is there any other way to do this?

    • Rinzwind
      Rinzwind over 9 years
      drwxr-xr-x 5 root root 4096 sep 28 07:28 opt ;)
    • jmcilhinney
      jmcilhinney over 5 years
      What exactly do you think that Refresh method does? It's not going to magically know to get data from a database or from a file or whatever else. Perhaps you should explain what Form2 actually does and what exactly you expect to happen in Form1. My guess is that you have data in a grid in Form1 and you making changes to the database in Form2 and expecting Form1 to reflect those changes. I say that because it's common that beginners do that when it's completely wrong. In that case, you should be making the changes in Form1 first, then saving them to the database from there.
    • Alexandra Macedo Lopes
      Alexandra Macedo Lopes over 5 years
      @jmcilhinney hello. Yap but I pretend that. I want to "run" the code of first form after making somes changes in the second form.
    • Alexandra Macedo Lopes
      Alexandra Macedo Lopes over 5 years
      @jmcilhinney yes but how can I execute it from another form?
    • jmcilhinney
      jmcilhinney over 5 years
      How do you usually execute code in an object? You call a method.. It has to be a method that actually contains the code you want executed though. Refresh doesn't contain such code so it won't magically execute such code.
  • jazz_razor
    jazz_razor over 9 years
    thnx. its works ..
  • Rmano
    Rmano over 9 years
    +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).
  • William Brendel
    William Brendel over 9 years
    Google Chrome also installs itself under /opt/
  • Rinzwind
    Rinzwind over 9 years
    @Rmano there are more: teamviewer, jasperserver.
  • jmcilhinney
    jmcilhinney over 5 years
    An answer MUST contain a solution to the question as asked. If you want to clarify the question then add a comment to the question.
  • Alexandra Macedo Lopes
    Alexandra Macedo Lopes over 5 years
    @andreas charidemou hello. Yes, some data is being saved. Then, I want to refresh first form so it can check the new information in database.
  • andreas charidemou
    andreas charidemou over 5 years
    Do you call again the method which is responsible for fetching the data from the database? The refresh method / event handler is different that the Form Load method. You need to call again the method / code responsible for fetching the data from the database.
  • andreas charidemou
    andreas charidemou over 5 years
    @jmcilhinney I don't have yet privilege to add a comment unless I add an answer. I don't know if this is a bug but I tried to add a comment in the first place and did not allowed it to me.
  • video.baba
    video.baba over 5 years
    This should be a comment, not an answer.
  • jmcilhinney
    jmcilhinney over 5 years
    An answer MUST contain an answer. If you can't post a comment then don't post anything.
  • jmcilhinney
    jmcilhinney over 5 years
    If you want to execute some code then you need to execute that code. Calling Refresh is not going to do that and you should not simply assume that it will.
  • andreas charidemou
    andreas charidemou over 5 years
    Just wanted to help
  • jmcilhinney
    jmcilhinney over 5 years
    Helping is good, but don't break the rules of the site to do so.
  • andreas charidemou
    andreas charidemou over 5 years
    Ok my friend. Sorry