The command MV for renaming a file or folder under Linux can be renamed and moved to a file or folder.
Example: Rename directory A to B
MV A B
Example: Move the/a directory down to/b, and rename to C
mv/a/b/c
In fact, in the text mode to rename the file or directory is also very simple, we only need to use MV command on it,
For example, if we were to rename a file named ABC to 1234, we could write it this way: MV ABC 1234, but note that
If there is a 1234 file in the current directory, we will overwrite it with this file.
Note that moving a file changes the file name, but keeping the same index node and timestamp, moving a file that has a soft link to it can be problematic, with a hard link.
root@wl-ms-7673:/home/wl/Desktop/shell/test# Touch test1
root@wl-ms-7673:/home/wl/desktop/shell/test# ls
test1
root@wl-ms-7673:/home/wl/Desktop/shell/test# ln test1 test2
root@wl-ms-7673:/home/wl/Desktop/shell/test# ls-il
total dosage 0
3161381-rw-r--r--2 Root 0 March 6 21:09 test1
3161381-rw-r--r--2 root root 0 March 6 21:09 te St2
root@wl-ms-7673:/home/wl/Desktop/shell/test# ln-s test1 test3 root@wl-ms-7673:/home/wl/
desktop/shell/test# ls- Il
total dosage 0
3161381-rw-r--r--2 root root 0 March 6 21:09 test1
3161381-rw-r--r--2 root root 0 March 6 21:09 test2
3161398 lrwxrwxrwx 1 root 5 March 6 21:10 test3
-> test1 root@wl-ms-7673:/ home/wl/Desktop/shell/test# mv test1 test4
root@wl-ms-7673:/home/wl/Desktop/shell/test# ls-il
total dosage 0
3161381- rw-r--r--2 Root 0 March 6 21:09 test2
3161398 lrwxrwxrwx 1 root root 5 March 6 21:10 test3-> Test1
3161381-rw-r--r--2 root 0 March 6 21:09 test4
root@wl-ms-7673:/home/wl/Desktop/shell/test#
Test2 is a hard link to test1, mobile test1 test3 test2 and test3 still maintain the same index node, and soft link test3 point to the test1 that no longer exists at this time.