Site icon Thetechhacker

How to Rename a File in Linux using Command

how-to-rename-a-file-in-linux

You are a beginner to the Linux commands right? No worries, it is extremely easy to rename Linux files using the terminal. All you have to do is to use the ‘mv’ command in the terminal. In this article, we are going to teach you how to use that command to rename a file in Linux using the terminal.

How to Rename a File in Linux using Terminal

Let’s assume that the file that you want to rename is “mydocz.pdf” and you want to rename it as “mydocs.pdf”. To rename it.

  1. Open the terminal by navigating to Applications > Accessories > Terminal.
  2. Type the following command,
    cd /home/techhacker/docs/filesmv mydocz.pdf mydocs.pdf
    Here, in the first line, enter the location of the file. In our case, it was located in /home/techhacker/docs/files directory. Also, replace the file names with yours.
    You can also write this command as,

    mv /home/techhacker/docs/files/mydocz.pdf /home/techhacker/docs/files/mydocs.pdf

  3. After entering them, just press Enter and your file will be renamed instantly.

Using pyRenamer

If you are not friendly to console and looking for an alternative way, this solution is for you. pyRenamer is simple and powerful rename tool which is written Python. You can find this tool on GitHub.

pyRenamer can remove duplicate symbols from filenames, replace any string of text with another, change filenames to uppercase, lowercase or sentence case, and automatically insert or remove spaces and underscores. You can change the name of a file in the main area of the program clicking on rename.

That’s all that you have to do for renaming the files in your Linux system. It is recommended to double check all commands on the terminal especially if you are a beginner. Any mistakes in the command may cause some problems to the files if the mistake matches with some other working commands.

We hope, you got the desired results and had successfully renamed the file. If you faced any difficulties in the process, feel free to leave a comment in the following comment section. We will be happy to help you as soon as possible.

Exit mobile version