File and directory manipulation
While using GNU/Linux, there will be times that creating, manipulating and deleting files will be needed. These can be done from the GUI too, but dealing with tons of files with the GUI can be really frustrating. In this section, manipulation of files and directories will be discussed.
Creating new files
New files can be simply created using the touch command. After entering the touch filename command a new file will be created. Multiple files can also be created by the touch command by giving multiple arguments.
Deleting files
Files can be deleted by using the rm command. After entering rm filename command the file will be deleted. Deleted files will not come back so caution is important. Multiple files can be deleted by giving multiple arguments. If a file can't be deleted, the -f option can be used in order to delete it forcefully.
Creating new directories
New directories can be simply created using the mkdir command. After entering the mkdir directoryname command a new directory will be created. Multiple directories can also be created by the mkdir command by giving multiple arguments.
Deleting directories
Deleting directories is a little bit complex than deleting files. To delete a directory without any content in it the rmdir command can be simply used. To delete a directory with content in it the rmdir command will not be enough. The -r option of the rm command can actually be used for recursively deleting the contents with the directory. Although this option provides an easy way to delete entire directories, sometimes valuable data can be missed. The -i option can be used in order to make the command ask for confirmation everytime it comes across a file.
Viewing text files
Text files can be viewed using the less command. With the less command big text files can be viewed without missing any data. To quit press the q key.
Moving and copying files
Files can be moved with the mv command. After writing the mv srcfile dstfile command the file will be moved to the destination. It can also be used for renaming files. The cp command can also be used for copying files, used as the same way with the mv command, cp srcfile dstfile.