How to Rename a Directory Via Command Line in Ubuntu
Topic: Ubuntu / LinuxPrev|Next
Answer: Use the
You can use the
mv command to rename a folder or directory via command line in Ubuntu.
For instance, if you want to rename the directory
new_name in your current working directory, you can simply use the following command:
-T option generates an error if the directory
new_name already exists at that location.
For example, if your current working directory is
/var/www and you want to rename the directory named
sample inside of it to
sample_new, you can simply use the command:
Alternatively, you can provide absolute path like this:
Both commands will have the same effect, because current working directory doesn't matter when you use absolute path. Any path that starts with a forward slash
/ is an absolute path.
Tip: The current working directory is the directory or folder where you are currently working. To change the current working directory, you need to use the
Here are some more FAQ related to this topic:
- How to change current working directory in Ubuntu terminal
- How to delete a non empty directory from terminal in Ubuntu
- How to unzip a zip file from the terminal in Ubuntu