Goals
To understand the basic file management functions in your Linux system. After completed, you will be able to manage the files and system resources from the system back end.
(These instructions are same for both Ubuntu and CentOS. If any changes required, you can find the note below that instruction. )
The “vi” or “vim” editor.
There are several file editing tools available in Linux. Here we are going to follow the usage of the “vi” or “vim” editor. It is a powerful editing tool found in almost all Linux distributions. ( If not installed by default, you can install it using “apt-get” in Ubuntu and “yum” in CentOS. )
1) To open a a file to edit using “vim” you can use the following command.
vim <file name or full file path>
2) If its a new file, then you will get the following.
3) To edit, press “i” or “insert” ( Then you can insert in to or delete from that file )
4) If you again press “i” or “insert” you will get back to “Replace mode” and now you can replace the characters.
5) You can use “esc + u “ for undo and can use “esc + shift + : + q + !” to quit the file without saving.
6) You can use “esc + shift + : + x” to save the file and quit
7) Now you know how to create a file, edit and update a file using “vi” or “vim” editor.
( Tip : Vim5 and later versions support syntax highlighting. Means you can see special colouring and highlighting in files while editing using vim. But this option is disabled in Ubuntu systems by default, if you want to enable this, open the file “/etc/vim/vimrc” and uncomment the line “syntax on”. Then save the file. That will enable syntax highlighting in your Ubuntu system)
Copy file
To copy a file, you can use the below command. (You can copy the content in a different name if required )
cp <file name> <destination>
Move File
To move a file, you can use the following command. ( You can also use this command to rename the file )
mv <filename> <destination>
Remove file
To remove a file or folder, you can use the following command. ( if you want to remove the content forcefully, you can add “-rf” after rm )
rm <filename/ foldername>
Conclusion
Now you know the basic file operation that you can perform in your Linux system. Now you can create, edit, copy, move and delete the files in your system. If you encountered any issues with this guide, please also note that there is additional information available in our Wiki database at http://myhosting.com/kb. Finally, we encourage you to contact our technical support team by email at vps@myhosting.com, or calling us at 1-866-289-5091 with any questions or concerns.