in

How edit a file in Linux and exit when you finish

Linux is one of the most popular Operating Systems and one that requires a expertise to operate on it. Linux is different from Windows OS in the way that users interact with the system. In windows there are two options, one graphic user interface and the other is command line interface. Where as in Linux users interface only through command line.

If you want to edit a file in linux, first you change the directory to where the file you want to edit exists. Use the following command to get where your file is or in which directory it is.

To check directory: pwd  >> This shows in which directory you are right now.
Then write: cd /directory  >> To get to the directory where the file exists
Then type: ls >> This will list files in your directory
Then type: vi file_name  >>Where file_name is the file you want to edit
Then: hit letter "i" to change the mode to insert

Now you can edit the file like adding content, removing content or changing content.
When you finish editing the file perform the following operation to exit from editing mode.

Step 1: Hit the ESC key to stop editing

Step 2: Write semi colon : followed by q and ! symbol i.e. write :q! to exit the editor

Some other important commands that are used by system administrators are the following:

pwd – to find the current working directory

cd /folder – to change the directory from the current working directory (use cd.. to move one directory up, cd- to move to the previous directory)

ls – to list of files and folders in the current working directory (use ls -R to list all files in the subdirectory as well as the main directory, ls -a to show hidden files, ls -al to list all files and directories with permission)

cat – short for concatenate and it will list the content of a file with a standard out put, you can use it as: cat>myfile.txt

cp – to copy a file from one directory to the other place

mv – to move a file from one directory to the other with out leaving a copy at the original place. eg: mv file1.txt

mkdir – to create a directory either at home or some where else eg: mkdir testfolder

grep – to search through a text in a given file

sudo – Superuser do , helps to perform tasks that require administrative permissions

df – to report system disk usage statistics eg: df -h, df -g (in Gigabyte)

ping – to check network connectivity eg: ping yahoo.com

Written by Editor

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Loading…

0

Arsenal Predicted Lineup Against Crystal Palace

Ten techniques to attract a woman you love