rename a directory in linux code example

Example 1: rename folder bash

mv /home/user/oldname /home/user/newname

Example 2: rename folder command line linux

mv old-name new-name

Example 3: how to rename the directory in terminal

mv [oldDirPath] [newDirPath]

Example 4: how to rename working directory in linux

$ mv <source_directory> <target_directory>

Example 5: how to rename a file in linux

To use mv to rename a file type mv , a space, the name of the file, a space, and the new name you wish the file to have.
Then press Enter. You can use ls to check the file has been renamed
eg. mv demo.py demo1.py

Tags:

Misc Example