Q:

How to Rename a Directory Via Command Line in Ubuntu

0

How to Rename a Directory Via Command Line in Ubuntu

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Use the mv Command

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 current_name to new_name in your current working directory, you can simply use the following command:

mv -T current_name new_name

The -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:

mv -T sample sample_new

Alternatively, you can provide absolute path like this:

mv -T /var/www/sample /var/www/sample_new

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 cd command.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Ubuntu / Linux Frequently Asked Questions

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
How to Copy the Contents of a Folder to Another Fo... >>
<< How to Change Current Working Directory in Ubuntu ...