• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

mv: command not found

by admin

The mv command moves files and directories to other locations. It is similar to the cp command but does not leave the initial object in place. Therefore, mv is more like a cut and paste operation. The Bash shell does not have a dedicated rename command but instead uses mv to accomplish that function. The act of “moving” a file or directory and supplying a new name as the destination essentially renames that object.

Syntax

The syntax of the mv command is:

$ mv [options] {file/directory name to move} {file/directory name destination}

For example, to move ~/file1 to /opt/file1:

$ mv ~/file1 /opt/mylist

For renaming purposes, the syntax is:

$ mv [options] {old file/ directory name} {new file/directory name}

mv Command Options

The following table lists some of the options for the mv command.

Option Description
-i Interactive mode. Ask before overwriting destination files.
-f Force the move. If a destination file exists, overwrite it unconditionally.

If you encounter the below error while running the mv command:

mv: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
OS X brew install coreutils
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
Raspbian apt-get install coreutils

mv Command Examples

1. Move a file to an arbitrary location:

# mv source target

2. Move files into another directory, keeping the filenames:

# mv source1 source2 source3 target_directory

3. Do not prompt for confirmation before overwriting existing files:

# mv -f source target

4. Prompt for confirmation before overwriting existing files, regardless of file permissions:

# mv -i source target

5. Do not overwrite existing files at the target:

# mv -n source target

6. Move files in verbose mode, showing files after they are moved:

# mv -v source target

Filed Under: Linux

Some more articles you might also be interested in …

  1. ltrace: command not found
  2. kdocker: command not found
  3. What is the purpose of utmp, wtmp and btmp files in Linux
  4. kwriteconfig5 Command Examples in Linux
  5. dbus-daemon Command Examples in Linux
  6. pacman-mirrors Command Examples in Linux
  7. http_load Command Examples in Linux
  8. blkid: command not found
  9. How To Force User/Group Ownership Of Files On A Samba Share
  10. CentOS / RHEL 5 : dm-multipath file /etc/sysconfig/mkinitrd/multipath explained

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright