Accidentally removed $HOME/bin












5















I accidentally removed my ~/bin directory. I have seen plenty of questions asking what to do if /usr/bin is removed, and that situation seems to be much more serious. What can I do to reconstruct the folder?










share|improve this question























  • Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

    – andrew.46
    Jan 14 at 22:40






  • 2





    ~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:41






  • 1





    @preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

    – andrew.46
    Jan 14 at 22:45








  • 1





    If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:45






  • 1





    @ElderGeek Alright. I'll write an answer then.

    – Sergiy Kolodyazhnyy
    Jan 14 at 23:12
















5















I accidentally removed my ~/bin directory. I have seen plenty of questions asking what to do if /usr/bin is removed, and that situation seems to be much more serious. What can I do to reconstruct the folder?










share|improve this question























  • Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

    – andrew.46
    Jan 14 at 22:40






  • 2





    ~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:41






  • 1





    @preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

    – andrew.46
    Jan 14 at 22:45








  • 1





    If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:45






  • 1





    @ElderGeek Alright. I'll write an answer then.

    – Sergiy Kolodyazhnyy
    Jan 14 at 23:12














5












5








5


1






I accidentally removed my ~/bin directory. I have seen plenty of questions asking what to do if /usr/bin is removed, and that situation seems to be much more serious. What can I do to reconstruct the folder?










share|improve this question














I accidentally removed my ~/bin directory. I have seen plenty of questions asking what to do if /usr/bin is removed, and that situation seems to be much more serious. What can I do to reconstruct the folder?







18.04 delete undelete






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 14 at 22:38









preferred_anonpreferred_anon

1404




1404













  • Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

    – andrew.46
    Jan 14 at 22:40






  • 2





    ~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:41






  • 1





    @preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

    – andrew.46
    Jan 14 at 22:45








  • 1





    If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:45






  • 1





    @ElderGeek Alright. I'll write an answer then.

    – Sergiy Kolodyazhnyy
    Jan 14 at 23:12



















  • Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

    – andrew.46
    Jan 14 at 22:40






  • 2





    ~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:41






  • 1





    @preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

    – andrew.46
    Jan 14 at 22:45








  • 1





    If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

    – Sergiy Kolodyazhnyy
    Jan 14 at 22:45






  • 1





    @ElderGeek Alright. I'll write an answer then.

    – Sergiy Kolodyazhnyy
    Jan 14 at 23:12

















Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

– andrew.46
Jan 14 at 22:40





Something simple like the following should help: mkdir ~/bin . But of course this will not resurrect any scripts that have been lost...

– andrew.46
Jan 14 at 22:40




2




2





~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

– Sergiy Kolodyazhnyy
Jan 14 at 22:41





~/bin is for user's own scripts and executables. It's not system-critical. If you had your own scripts/programs there, you could try recovering them, see How to recover deleted files?. If it was empty - forget about it, just mkdir ~/bin. If you had backup of scripts/files - also no need to worry about it.

– Sergiy Kolodyazhnyy
Jan 14 at 22:41




1




1





@preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

– andrew.46
Jan 14 at 22:45







@preferred_anon Well, you could look at your most recent backup :). But as Sergiy has mentioned this is your own folder that usually is not populated by an Ubuntu install so anything there has been placed by yourself...

– andrew.46
Jan 14 at 22:45






1




1





If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

– Sergiy Kolodyazhnyy
Jan 14 at 22:45





If you're going to recover files, also see unix.stackexchange.com/q/80270/85039 I've heard photorec works well, which is also mentioned there. As for finding out what was there, debugfs should help with that. See the accepted answer on the linked post.

– Sergiy Kolodyazhnyy
Jan 14 at 22:45




1




1





@ElderGeek Alright. I'll write an answer then.

– Sergiy Kolodyazhnyy
Jan 14 at 23:12





@ElderGeek Alright. I'll write an answer then.

– Sergiy Kolodyazhnyy
Jan 14 at 23:12










1 Answer
1






active

oldest

votes


















8














What is ~/bin and why does it exist ?



~/bin is for user's own scripts and executables. It's not system-critical and not specified by any standard, unlike /usr/bin. To quote Debian documentation:




/bin/



Essential command executable (binaries) for all users (e.g., cat, ls, cp)
(especially files required to boot or rescue the system)



...



/usr/



Secondary hierarchy for shareable, read-only data (formerly from UNIX source repository, now from UNIX system resources)
(files that are not-required to boot or rescue the system)



/usr/bin/ : Same as for top-level hierarchy




See also Categorize the File Hierarchy System.



The directory is added to user's PATH variable (which is what is referenced when you call commands by name instead of full pathname, e.g. bash vs /bin/bash). The purpose is to allow user call their own private scripts and executables by name. Specifically, that's handled in ~/.profile:



# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi


The ~/.profile is read and executed ( and therefore the directory is added ) when the shell is used as login shell or according to geirha's answer when logging into GNOME-based desktop.



Mostly, what it contains is defined by the users themselves. It is quite possible that 3rd party software could place scripts there, though I've not come across such cases yet.



What to do about the deleted ~/bin ?



As mentioned before, the directory is not system critical. Unless you yourself placed something system-significant there (which is probably a bad idea and not practical), it could cause issues within the scope of what was actually done. Otherwise, there's essentially no effect, just like when you remove any other non-critical directory. If it was empty or you have backup of files it contained, there's no need to do anything else. You can recreate it either via file manager or command-line with mkdir ~/bin.



If you had your own scripts/programs there, you could try recovering them. See How to recover deleted files?, Tool for recovering deleted data from a flash drive, and Unix/Linux undelete/recover deleted files. There are multiple selections of utilities. Note, that it is assumed you have default ext4 filesystem. In case you have something else, the filesystem may have its own specific utilities for recovering files, such as for btrfs. For future, you can consider doing backups of the directories and files. See What's a good back-up strategy for 1 desktop PC?






share|improve this answer

























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109762%2faccidentally-removed-home-bin%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    8














    What is ~/bin and why does it exist ?



    ~/bin is for user's own scripts and executables. It's not system-critical and not specified by any standard, unlike /usr/bin. To quote Debian documentation:




    /bin/



    Essential command executable (binaries) for all users (e.g., cat, ls, cp)
    (especially files required to boot or rescue the system)



    ...



    /usr/



    Secondary hierarchy for shareable, read-only data (formerly from UNIX source repository, now from UNIX system resources)
    (files that are not-required to boot or rescue the system)



    /usr/bin/ : Same as for top-level hierarchy




    See also Categorize the File Hierarchy System.



    The directory is added to user's PATH variable (which is what is referenced when you call commands by name instead of full pathname, e.g. bash vs /bin/bash). The purpose is to allow user call their own private scripts and executables by name. Specifically, that's handled in ~/.profile:



    # set PATH so it includes user's private bin if it exists
    if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
    fi


    The ~/.profile is read and executed ( and therefore the directory is added ) when the shell is used as login shell or according to geirha's answer when logging into GNOME-based desktop.



    Mostly, what it contains is defined by the users themselves. It is quite possible that 3rd party software could place scripts there, though I've not come across such cases yet.



    What to do about the deleted ~/bin ?



    As mentioned before, the directory is not system critical. Unless you yourself placed something system-significant there (which is probably a bad idea and not practical), it could cause issues within the scope of what was actually done. Otherwise, there's essentially no effect, just like when you remove any other non-critical directory. If it was empty or you have backup of files it contained, there's no need to do anything else. You can recreate it either via file manager or command-line with mkdir ~/bin.



    If you had your own scripts/programs there, you could try recovering them. See How to recover deleted files?, Tool for recovering deleted data from a flash drive, and Unix/Linux undelete/recover deleted files. There are multiple selections of utilities. Note, that it is assumed you have default ext4 filesystem. In case you have something else, the filesystem may have its own specific utilities for recovering files, such as for btrfs. For future, you can consider doing backups of the directories and files. See What's a good back-up strategy for 1 desktop PC?






    share|improve this answer






























      8














      What is ~/bin and why does it exist ?



      ~/bin is for user's own scripts and executables. It's not system-critical and not specified by any standard, unlike /usr/bin. To quote Debian documentation:




      /bin/



      Essential command executable (binaries) for all users (e.g., cat, ls, cp)
      (especially files required to boot or rescue the system)



      ...



      /usr/



      Secondary hierarchy for shareable, read-only data (formerly from UNIX source repository, now from UNIX system resources)
      (files that are not-required to boot or rescue the system)



      /usr/bin/ : Same as for top-level hierarchy




      See also Categorize the File Hierarchy System.



      The directory is added to user's PATH variable (which is what is referenced when you call commands by name instead of full pathname, e.g. bash vs /bin/bash). The purpose is to allow user call their own private scripts and executables by name. Specifically, that's handled in ~/.profile:



      # set PATH so it includes user's private bin if it exists
      if [ -d "$HOME/bin" ] ; then
      PATH="$HOME/bin:$PATH"
      fi


      The ~/.profile is read and executed ( and therefore the directory is added ) when the shell is used as login shell or according to geirha's answer when logging into GNOME-based desktop.



      Mostly, what it contains is defined by the users themselves. It is quite possible that 3rd party software could place scripts there, though I've not come across such cases yet.



      What to do about the deleted ~/bin ?



      As mentioned before, the directory is not system critical. Unless you yourself placed something system-significant there (which is probably a bad idea and not practical), it could cause issues within the scope of what was actually done. Otherwise, there's essentially no effect, just like when you remove any other non-critical directory. If it was empty or you have backup of files it contained, there's no need to do anything else. You can recreate it either via file manager or command-line with mkdir ~/bin.



      If you had your own scripts/programs there, you could try recovering them. See How to recover deleted files?, Tool for recovering deleted data from a flash drive, and Unix/Linux undelete/recover deleted files. There are multiple selections of utilities. Note, that it is assumed you have default ext4 filesystem. In case you have something else, the filesystem may have its own specific utilities for recovering files, such as for btrfs. For future, you can consider doing backups of the directories and files. See What's a good back-up strategy for 1 desktop PC?






      share|improve this answer




























        8












        8








        8







        What is ~/bin and why does it exist ?



        ~/bin is for user's own scripts and executables. It's not system-critical and not specified by any standard, unlike /usr/bin. To quote Debian documentation:




        /bin/



        Essential command executable (binaries) for all users (e.g., cat, ls, cp)
        (especially files required to boot or rescue the system)



        ...



        /usr/



        Secondary hierarchy for shareable, read-only data (formerly from UNIX source repository, now from UNIX system resources)
        (files that are not-required to boot or rescue the system)



        /usr/bin/ : Same as for top-level hierarchy




        See also Categorize the File Hierarchy System.



        The directory is added to user's PATH variable (which is what is referenced when you call commands by name instead of full pathname, e.g. bash vs /bin/bash). The purpose is to allow user call their own private scripts and executables by name. Specifically, that's handled in ~/.profile:



        # set PATH so it includes user's private bin if it exists
        if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
        fi


        The ~/.profile is read and executed ( and therefore the directory is added ) when the shell is used as login shell or according to geirha's answer when logging into GNOME-based desktop.



        Mostly, what it contains is defined by the users themselves. It is quite possible that 3rd party software could place scripts there, though I've not come across such cases yet.



        What to do about the deleted ~/bin ?



        As mentioned before, the directory is not system critical. Unless you yourself placed something system-significant there (which is probably a bad idea and not practical), it could cause issues within the scope of what was actually done. Otherwise, there's essentially no effect, just like when you remove any other non-critical directory. If it was empty or you have backup of files it contained, there's no need to do anything else. You can recreate it either via file manager or command-line with mkdir ~/bin.



        If you had your own scripts/programs there, you could try recovering them. See How to recover deleted files?, Tool for recovering deleted data from a flash drive, and Unix/Linux undelete/recover deleted files. There are multiple selections of utilities. Note, that it is assumed you have default ext4 filesystem. In case you have something else, the filesystem may have its own specific utilities for recovering files, such as for btrfs. For future, you can consider doing backups of the directories and files. See What's a good back-up strategy for 1 desktop PC?






        share|improve this answer















        What is ~/bin and why does it exist ?



        ~/bin is for user's own scripts and executables. It's not system-critical and not specified by any standard, unlike /usr/bin. To quote Debian documentation:




        /bin/



        Essential command executable (binaries) for all users (e.g., cat, ls, cp)
        (especially files required to boot or rescue the system)



        ...



        /usr/



        Secondary hierarchy for shareable, read-only data (formerly from UNIX source repository, now from UNIX system resources)
        (files that are not-required to boot or rescue the system)



        /usr/bin/ : Same as for top-level hierarchy




        See also Categorize the File Hierarchy System.



        The directory is added to user's PATH variable (which is what is referenced when you call commands by name instead of full pathname, e.g. bash vs /bin/bash). The purpose is to allow user call their own private scripts and executables by name. Specifically, that's handled in ~/.profile:



        # set PATH so it includes user's private bin if it exists
        if [ -d "$HOME/bin" ] ; then
        PATH="$HOME/bin:$PATH"
        fi


        The ~/.profile is read and executed ( and therefore the directory is added ) when the shell is used as login shell or according to geirha's answer when logging into GNOME-based desktop.



        Mostly, what it contains is defined by the users themselves. It is quite possible that 3rd party software could place scripts there, though I've not come across such cases yet.



        What to do about the deleted ~/bin ?



        As mentioned before, the directory is not system critical. Unless you yourself placed something system-significant there (which is probably a bad idea and not practical), it could cause issues within the scope of what was actually done. Otherwise, there's essentially no effect, just like when you remove any other non-critical directory. If it was empty or you have backup of files it contained, there's no need to do anything else. You can recreate it either via file manager or command-line with mkdir ~/bin.



        If you had your own scripts/programs there, you could try recovering them. See How to recover deleted files?, Tool for recovering deleted data from a flash drive, and Unix/Linux undelete/recover deleted files. There are multiple selections of utilities. Note, that it is assumed you have default ext4 filesystem. In case you have something else, the filesystem may have its own specific utilities for recovering files, such as for btrfs. For future, you can consider doing backups of the directories and files. See What's a good back-up strategy for 1 desktop PC?







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 14 at 23:49

























        answered Jan 14 at 23:41









        Sergiy KolodyazhnyySergiy Kolodyazhnyy

        71.4k9147313




        71.4k9147313






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1109762%2faccidentally-removed-home-bin%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            How to change which sound is reproduced for terminal bell?

            Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

            Can I use Tabulator js library in my java Spring + Thymeleaf project?