Working on Linux Files - Basic Commands
In this article we will be seeing some basic commands while working on files in Linux.
In Linux there are more applications to create and edit a file. Some of them are Vi editor, Vim editor(extended version for vi), Nano, Emacs, etc..,. These text editors are applicable in minimal installation.
In GUI we can use Gedit, Sublime text, etc.,.
Creating a File:
You can create a empty file using touch command,
To add contents to the file use echo command,
To add more contents use >> symbol which will append the new content on the preceding line,
You can use cat or less command to see the content of the file, It only prints the content of the file.To edit the file you can open the file with any of the text editors as mentioned earlier,
The output of the file we created will be,
Copying a File:
For copying use cp command,
Renaming a File:
Use mv command to rename a file,
Listing the Files:
To list all the files in a directory we can use ls command,
Deleting a File:
We can use rm command to delete a file, rm command will ask for a confirmation if the file is write protected but rm -rf will delete the file at once when its executed. So using rm command is preferable for deleting files.
Feel free to ask if you have any questions.
Comments