When working in Linux, it is common to navigate across multiple directories and perform various tasks using the terminal.
As a result, it can be beneficial to copy and move certain files and folders from one directory to another.
Note that moving a file/folder will delete it from its source while copying it will not.
To copy/move a file or folder in another directory to your current working directory, you can use the following terminal commands:
cp path_source .
mv path_source .
path_source
is the path to the source directory, and .
represents the current working directory.
To copy/move a file in the present working directory to another directory in your file system, you can use the following commands:
cp name destination_path
mv name destination_path
Where name
is the name of the file/folder to move/copy, and destination_path
is the destination directory.
To copy/move a file in a non-current working directory to another non-current working directory in your file system, you can use the following commands:
cp source_path destination_path
mv source_path destination_path
Where source_path
is the file’s path to be moved from its current location to a different location, destination_path.