← Back to list

How to Rename a Directory in Linux

In Linux, renaming a directory is done using the mv command. It works by “moving” a directory to a new name within the same location.

VSYS Host · 2026-04-10 12:05 · 3 claps · 0.8 min read
#linux #devops #sysadmin #vsys #infrastructure
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🔓 · Open Source 🎬 · Film & Television 🥊 · Combat Sports

How to Rename a Directory in Linux

In Linux, renaming a directory is done using the mv command. It works by “moving” a directory to a new name within the same location.

Basic Syntax

mv old_directory new_directory

This renames a directory without changing its location.

Example

mv project project_backup

Renames projectproject_backup.

Using Absolute Path

mv /home/user/project /home/user/project_v2

Used when working outside the current directory.

Directory with Spaces

mv "My Folder" "My Folder Backup"

Quotes are required for names with spaces.

Useful Options

Prompt before overwrite:

mv -i old_name new_name

Verbose output:

mv -v old_name new_name

Key Notes

  • mv is used for both moving and renaming
  • Renaming = moving to a new name in the same directory
  • If target exists, it may be overwritten without prompt

Summary

  • Rename directory → mv old new
  • Use full path if needed
  • Quote names with spaces
  • Use -i to avoid overwriting

Full guide 👉 https://vsys.host/how-to/how-to-rename-a-directory-in-linux


메타데이터
post_id
0ff26a00a55f
slug
how-to-rename-a-directory-in-linux-0ff26a00a55f
url
https://medium.com/@vsys.host/how-to-rename-a-directory-in-linux-0ff26a00a55f
canonical_url
https://medium.com/@vsys.host/how-to-rename-a-directory-in-linux-0ff26a00a55f
author_url
https://medium.com/@vsys.host
status
ok
fetched_at
2026-06-21 22:26:41