In the previous tutorial you saw some basic linux commands, now you will see some of the commands that are used to create and manipulate files.


The touch command is used to create a file. Just type touch followed by the filename and your file will be created!

If a file with the same filename already exists then it will update the timestamp(created/modification date) of the file.

Mkdir(make directory)

mkdir is used to create a new directory.

Rmdir(remove directory)

rmdir is used to delete an exiting directory. Remember! rmdir will only removes those directories that are empty. You will see how to delete non-empty directories with the upcoming command rm.


rm is a very powerful command, you can delete almost anything with it, so be very careful while using it. Files/Directories deleted with rm do not go to bin, once deleted they are gone and cannot be recovered.

To delete a file, write rm followed by the filename.


To delete a directory you have to use the -r option. It means that you want to delete all the files recursively.


When you use -i option, before deleting any file it will ask you for a confirmation whether you want to delete it or not. It is useful in the case where you want to delete some files in a directory while keeping the others.



The f here means force delete, it means what ever be the case don’t ask me for any confirmation, just delete it!


The v here means verbose, if you add this option then the rm command will print a summary of all the files/directories that it has deleted.



To copy a file from to a directory write the following command.


To copy one directory into other directory use the -r option, which means recursively copy all the files.

(Copy directory1 into directory2)


Just as you saw while deleting files with rm, -i will explicitly ask you before copying every file. This is useful in the case where you want to copy only some of the files from one directory to the other.


The v means verbose, if you add this option then it will output a summary of all the files that have been copied.


To move a file to another directory write the following command.

You can also rename a directory using the mv command.

To move a directory into another directory.

(Remember if directory2 doesn’t exist then directory1 will be renamed to directory2)


When you use the option -i, mv command, while moving files, will ask you confirmation for overwriting a file whenever there is a file already existing with the same name.

With these linux commands you have enough power to play around with files. Again I would urge you to try these commands on your own, practice to get a good hold onto them. Create a temporary directory and start messing around with it using these commands.


Previous Tutorial : Getting Familiar with Linux Commands – Tutorial 0 – Basic Commands

Leave a Reply

Your email address will not be published.

14 − 11 =