matthew@seymour:~$ mv oldfilename newfilename
To rename a file as you move it from ~/documents to ~/archive, you
could use this:
Click here to view code image
matthew@seymour:~$ mv documents/oldfilename archive/newfilename
Or from anywhere using an absolute path, you could use the following
command:
Click here to view code image
matthew@seymour:~$ mv /home/matthew/documents/oldfilename
/home/matthew/archive/newfilename
Or from anywhere using a path shortcut, you could use this:
Click here to view code image
matthew@seymour:~$ mv ~/documents/oldfilename ~/archive/newfilename
Copying a File with cp
Copying works similarly to moving, but it retains the original in the original
location. Assuming that you are the user matthew, to copy a file named
filename from ~/documents to ~/archive, use this command:
Click here to view code image
matthew@seymour:~$ cp documents/filename archive
Notice that the filename is not included in the destination. The destination
here must be an existing directory. If it is not, the file is renamed to the term
used. Some examples will make this clear.
To copy a file that is in your current directory, you could use the following,
and it will work exactly the same as mv, except that both files will exist
afterward:
Click here to view code image
matthew@seymour:~$ cp oldfilename newfilename
To rename a file as you copy it from ~/documents to ~/archive, you
could use this:
Click here to view code image
matthew@seymour:~$ cp documents/oldfilename archive/newfilename
Or from anywhere using an absolute path, you could use the following
command: