WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES

How to Rename a Directory Via Command Line in Ubuntu

Topic: Ubuntu / LinuxPrev|Next

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.


Related FAQ

Here are some more FAQ related to this topic:

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties