If you're using an Ubuntu laptop or desktop, you can press Ctrl + Alt + T
on your keyboard to open a new terminal window. If you're using a remote Ubuntu server, you can connect using SSH to open a new terminal session.
mv
The mv
command (short for "move") allows you to rename a file. For example, to rename a file called existing.html
to new.html
, you can run:
$ mv existing.html new.html
As its name implies, the command also allows you to move a file from one directory to another. For example, if we have a file in directory /var/www/html/
called existing.html
that we want to move to /home/ubuntu/
, we can run:
$ mv /var/www/html/existing.html /home/ubuntu/
After this command, the file will now be located at /home/ubuntu/existing.html
and /var/www/html/existing.html
will no longer exist.
You can also rename a file while simultaneously moving it from one directory to another. If, in the previous example, you want to rename the file to new.html
in the move to /home/ubuntu/
, you can just specify the new filename in the second argument to the command:
$ mv /var/www/html/existing.html /home/ubuntu/new.html
After this command, the file will now be located at /home/ubuntu/new.html
and /var/www/html/existing.html
will no longer exist.