How to move a file to another folder or directory in Linux?

Published July 24, 2021

To move a file to another folder or directory, we can use the mv command followed by the source path of the file and then the destination path in Linux.

For example, let's say we have a file called myFile.txt which we need to move to a directory called myDirectory, to do that we can use the mv Linux command like this,

# Move "myFile.txt" to "myDirectory" directory
mv myFile.txt myDirectory
  • In the above command after the mv command we have defined the source path of the file which is the myFile.txt and after that the destination path which is the myDirectory directory where the file needs to be moved to.

  • Executing the above command will move the myFile.txt file to the myDirectory directory or folder.

See the execution of the above command live in repl.it.

That's all 😃!

Feel free to share if you found this useful 😃.


Share on: Facebook Twitter