You can also use the mv command to rename files. For example, if you want to rename the file cats.txt to dogs.txt, you can run the mv cats.txt dogs.txt command:
elliot@ubuntu-linux:~$ mv cats.txt dogs.txt elliot@ubuntu-linux:~$ cat dogs.txt I love cars! I love cats! I love penguins! elliot@ubuntu-linux:~$
If you want to rename the directory big to small, you can run the mv big small command:
elliot@ubuntu-linux:~$ mv big small elliot@ubuntu-linux:~$ ls small cities d1 d2 elliot@ubuntu-linux:~$
In summary, here is how the mv command works:
If the destination directory exists, the mv command will move the source file(s) to the destination directory.
If the destination directory doesn’t exist, the mv command will rename the source file.
Keep in mind that you can only rename one file (or one directory) at a time.