1) mv = renames a file or moves it from one directory to another directory

Syntax

mv [-f] [-i] oldname newname  (to rename)

mv [-f] [-i] filename newdirectory

-f mv will move the file(s) without prompting even if it is writing over an existing target. Note that this is the default if the standard input is not a terminal.
-i Prompts before overwriting another file.
oldname The oldname of the file renaming.
newname The newname of the file renaming.
filename The name of the file you want to move directory – The directory of were you want the file to go.

Examples

mv myfile.txt newdirectory/ – moves the file myfile.txt to the directory newdirectory.

mv myfile.txt ../ – moves the file myfile.txt back one directory (if available).

.

2) cp = copies files from one location to another

Examples

cp file1.txt newdir

Copies the file1.txt in the current directory to the newdir directory.

cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak

Copies the mylog.txt file in the public_html directory into the public_html/backup directory as mylog.bak. The files are identical however have different names.

cp *.txt newdir

Copy all files ending in .txt into the newdir directory.

cp -r /home/hope/files/* /home/hope/backup

Copies all the files, directories, and subdirectories in the files directory into the backup directory.

.

3) rm : deletes a file without confirmation (by default).

rm myfile.txt

Remove the file myfile.txt without prompting the user.

rm -r directory

Remove a directory, even if files existed in that directory. It will prompt for every single file

rm -rf directory

Remove a directory, even if files existed in that directory.It will not ask for confirmation for each file.

To remove a file whose name starts with a `-‘, for example `-foo’, use one of these commands:

rm -foo
rm ./-foo

.

4) mkdir = to create a new directory

mkdir filename

.

5) rmdir = deletes a directory

rmdir mydir – removes the directory mydir (it wont work if files existed in the directory)

rm -r directory – would remove a directory, even if files existed in that directory.

there is no -r option for rmdir, therefore to remove a directory with files inside can use rm -r or rm-rf

rmdir -p dir3/dir4/dir5 - remove dir5, dir4 and dir3 if dir5 were empty, dir4 only contained dir5 and dir3 only contained dir4 (which, in turn, contained dir5):