Rename dir3 to backup_dir and verify. (Use mv and ls to check)

Run the following command:

bashCopyEditmv ~/dir3 ~/backup_dir

Step 2: Verify the Renaming

bashCopyEditls -l ~

Expected Output:

sqlCopyEditdrwxr-xr-x  2 user user 4096 Mar 29 12:34 backup_dir
drwxr-xr-x  2 user user 4096 Mar 29 12:34 dir1
drwxr-xr-x  2 user user 4096 Mar 29 12:34 dir2
  • dir3 should no longer be listed.

  • backup_dir should be present instead.

Explanation:

  • mv (move) is used for both moving and renaming files/directories.

  • Since we specified the same location (~), it renames dir3 to backup_dir.

0
Subscribe to my newsletter

Read articles from Ravi Vishwakarma directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ravi Vishwakarma
Ravi Vishwakarma