Manipulating Files

 

  • cp - copy files and directories

The cp program copies files and directories. In its simplest form, it copies a single file:

[me@linuxbox me]$ cp file1 file2

It can also be used to copy multiple files (and/or directories) to a different directory:

[me@linuxbox me]$ cp file... directory

  • mv - move or rename files and directories

The mv command moves or renames files and directories depending on how it is used. It will either move one or more files to a different directory, or it will rename a file or directory. To rename a file, it is used like this:

[me@linuxbox me]$ mv filename1 filename2

To move files (and/or directories) to a different directory:

[me@linuxbox me]$ mv file... directory

  • rm - remove files and directories

The rm command removes (deletes) files and directories.

[me@linuxbox me]$ rm file...

It can also be used to delete directories:

[me@linuxbox me]$ rm -r directory...

  • mkdir - create directories

The mkdir command is used to create directories. To use it, you simply type:

[me@linuxbox me]$ mkdir directory...

 

Manipulating Files