How to rename file on Linux using the mv command

August 8, 2023 / Servers, Hosting & Email

This guide explains how to rename file on Linux using the mv command.

Let us follow the steps:

  1. If you want to rename a file, you can run the below command-
    mv oldnamefile1 newnamefile1
  2. Let us assume that you are located in the directory, there is a file named fileA.txt, and you wish to change the name to fileB.txt. Execute the following command-
    mv fileA.txt fileB.txt
  3. If you are not in the directory, you can execute the below command-
    cd /home/user/docs/files
    mv fileA.txt fileB.txt

That is it! Hope you liked our KB. If you have any doubt, please do not hesitate to get in touch with our support staff.

Spread the love