While working with files and directories in Unix and Linux, you will need to use copy paste or move commands which can help you to manage the files more easily.

Working with Files and Directories in Unix and Linux_bashcodes

Copying Files

$ cp option source target

-i: Prevents from accidently overwriting of existing file, gives a yes or no prompt.

-r: Include the contents of directory and sub-directory. When you copy a directory.

Moving files

$ mv -i source target

moves files from source to target and – I gives a yes or no prompt. If the large file is not present the mv command will return an error.

Creating empty files

$ touch filename

Creating directories

$ mkdir  directoryname

To create a directory in a directory

$ mkdir- p path name/ directory-name

If the directory name include a pathname, use the mkdir command with – p option.

Renaming files and directories

$ mv filename renamedfilename
$ mv directory-name  renameddirectoryname

Removing files

$ rm –option filename

-i: prompts for  yes or no before removing

$ rm dir directory

to remove a directory

$ rmdir -ir directory

-r: will remove contents and sub directory

-i: prompts yes or no before removing.

Symbolic links

Symbolic links are a pointer that contain the path name to another file or directory. The link makes the file or directory easier to access if it has a long path name. This is considered as a shortcut for a file or directory in a Windows.

Symbolic  link is identified by the letter L in the file type field.

$ ln -s sourcefile targetfile

The source file refers to the file you use to create the link to , while the target-file  variable refers to the symbolic link name.

$ ls -l filename

to view the link file.

$ rm linkname

used to remove a symbolic link file.

You can feel free to respond us @Twitter, Facebook and Google Plus.