How to move one file to a folder using terminal?











up vote
37
down vote

favorite
7












I want to move one file to a folder using terminal. How do I do this?










share|improve this question
























  • linuxcommand.org/learning_the_shell.php Check out the mv command.
    – dan08
    May 14 '14 at 16:11












  • use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
    – Panther
    May 14 '14 at 16:13






  • 2




    Possible duplicate of How to copy or move a file from a folder to desktop?
    – muru
    Jul 6 '17 at 13:43










  • @muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
    – David Foerster
    Jul 7 '17 at 0:56















up vote
37
down vote

favorite
7












I want to move one file to a folder using terminal. How do I do this?










share|improve this question
























  • linuxcommand.org/learning_the_shell.php Check out the mv command.
    – dan08
    May 14 '14 at 16:11












  • use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
    – Panther
    May 14 '14 at 16:13






  • 2




    Possible duplicate of How to copy or move a file from a folder to desktop?
    – muru
    Jul 6 '17 at 13:43










  • @muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
    – David Foerster
    Jul 7 '17 at 0:56













up vote
37
down vote

favorite
7









up vote
37
down vote

favorite
7






7





I want to move one file to a folder using terminal. How do I do this?










share|improve this question















I want to move one file to a folder using terminal. How do I do this?







command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 6 '17 at 13:43









muru

134k19283484




134k19283484










asked May 14 '14 at 16:09









Louise Avon

3062512




3062512












  • linuxcommand.org/learning_the_shell.php Check out the mv command.
    – dan08
    May 14 '14 at 16:11












  • use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
    – Panther
    May 14 '14 at 16:13






  • 2




    Possible duplicate of How to copy or move a file from a folder to desktop?
    – muru
    Jul 6 '17 at 13:43










  • @muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
    – David Foerster
    Jul 7 '17 at 0:56


















  • linuxcommand.org/learning_the_shell.php Check out the mv command.
    – dan08
    May 14 '14 at 16:11












  • use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
    – Panther
    May 14 '14 at 16:13






  • 2




    Possible duplicate of How to copy or move a file from a folder to desktop?
    – muru
    Jul 6 '17 at 13:43










  • @muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
    – David Foerster
    Jul 7 '17 at 0:56
















linuxcommand.org/learning_the_shell.php Check out the mv command.
– dan08
May 14 '14 at 16:11






linuxcommand.org/learning_the_shell.php Check out the mv command.
– dan08
May 14 '14 at 16:11














use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13




use the mv command. It might be more complicated as you may have problems with ownership / permissions if you have moving a file outside of $HOME.
– Panther
May 14 '14 at 16:13




2




2




Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43




Possible duplicate of How to copy or move a file from a folder to desktop?
– muru
Jul 6 '17 at 13:43












@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56




@muru: That question is distinctly different because it's asking how to move files to the desktop specifically.
– David Foerster
Jul 7 '17 at 0:56










2 Answers
2






active

oldest

votes

















up vote
47
down vote



accepted










mv [file] [directory]


For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/





As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.



If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:



sudo mv info.txt config/


BIG IMPORTANT NOTE:

Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.






share|improve this answer



















  • 1




    depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
    – Panther
    May 14 '14 at 16:13


















up vote
3
down vote













You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:



mv info.txt config/information.txt


This would move the file and change its name.






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',
    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%2f465877%2fhow-to-move-one-file-to-a-folder-using-terminal%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    47
    down vote



    accepted










    mv [file] [directory]


    For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/





    As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.



    If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:



    sudo mv info.txt config/


    BIG IMPORTANT NOTE:

    Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.






    share|improve this answer



















    • 1




      depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
      – Panther
      May 14 '14 at 16:13















    up vote
    47
    down vote



    accepted










    mv [file] [directory]


    For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/





    As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.



    If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:



    sudo mv info.txt config/


    BIG IMPORTANT NOTE:

    Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.






    share|improve this answer



















    • 1




      depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
      – Panther
      May 14 '14 at 16:13













    up vote
    47
    down vote



    accepted







    up vote
    47
    down vote



    accepted






    mv [file] [directory]


    For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/





    As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.



    If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:



    sudo mv info.txt config/


    BIG IMPORTANT NOTE:

    Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.






    share|improve this answer














    mv [file] [directory]


    For example, to move info.txt from the actual directory into the config/ directory, type mv info.txt config/





    As was pointed out in a correct comment, the above will fail if the user running the command doesn't have write access to either the file or the folder.



    If you prefix the command with sudo, you are telling the system to run the command as the root user (similar to an Admin account). Example:



    sudo mv info.txt config/


    BIG IMPORTANT NOTE:

    Only use sudo if you are sure you know what you're doing - Ubuntu protects things for a reason. Using sudo you can break your OS, forcing a reinstall, if you move (or delete or whatever) important files.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Dec 13 '17 at 8:11









    derHugo

    2,25921428




    2,25921428










    answered May 14 '14 at 16:12









    David Oneill

    5,634104366




    5,634104366








    • 1




      depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
      – Panther
      May 14 '14 at 16:13














    • 1




      depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
      – Panther
      May 14 '14 at 16:13








    1




    1




    depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
    – Panther
    May 14 '14 at 16:13




    depends on the ownership and permissions of the destination. Might need to use sudo or discuss ownership / permissions.
    – Panther
    May 14 '14 at 16:13












    up vote
    3
    down vote













    You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:



    mv info.txt config/information.txt


    This would move the file and change its name.






    share|improve this answer

























      up vote
      3
      down vote













      You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:



      mv info.txt config/information.txt


      This would move the file and change its name.






      share|improve this answer























        up vote
        3
        down vote










        up vote
        3
        down vote









        You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:



        mv info.txt config/information.txt


        This would move the file and change its name.






        share|improve this answer












        You can use the same command for renaming files. A rename is essentially moving a file to the same location but with a new name. Using the previous example:



        mv info.txt config/information.txt


        This would move the file and change its name.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 14 '14 at 16:20









        mbrookes1304

        311




        311






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f465877%2fhow-to-move-one-file-to-a-folder-using-terminal%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

            Mont Emei

            Province de Neuquén

            Journaliste