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

Popular Posts on this blog

Apache Webserver - Installation from source (tar.gz and tar.bz2)

Setting up a Mail server using Roundcube - Part-1 - Centos 7

How to Install LAMP Stack on Linux - Centos 7

Installing Docker-Compose on Ubuntu

Apache Tomcat Installation - Ubuntu - 17.04

Setting up a Mail server using Roundcube - Part-2 - Centos 7

Blog Top Sites

Blog Log