No menu items!
More
    HomeTutsUbuntuHow to Copy, Move Files and Directories in Ubuntu

    How to Copy, Move Files and Directories in Ubuntu

    The cp command will copy files and directories or copy multiple sources to a destination directory and mv command will move or rename files or directories, or can move multiple sources to a destination directory.

    Copy Files and Directories Ubuntu

    cp [options] source destination

    Multiple files and directories to destination directory

    cp [options] source1 source2 [...] destination_directory

    Common options used with the cp command

    -a – archive, never follow symbolic links, preserve links, copy directories recursively
    -f – if an existing destination file cannot be opened, remove it and try again
    -i – prompt before overwriting an existing file
    -r – copy directories recursively

    Example

    Copying a single file to a destination directory

    cp file.txt /var/tmp/

    Copying a directory and all contents

    cp file-1.txt file-2.csv /var/tmp/

    Copying multiple files to a destination directory

    $ cp -r /etc/directory /var/tmp/directory/

    Moving Files and Directories Ubuntu

    mv [options] source destination

    Multiple files and directories to destination directory

    mv [options] source1 source2 [...] destination

    Common options used with the mv command:
    -f – do not prompt before overwriting
    -i – prompt before overwrite
    -u – move only when the source file is newer than the destination file or when the destination file is missing

    Example

    mv var/www/example/ /etc/example2

    LEAVE A REPLY

    Please enter your comment!
    Please enter your name here