ByVivek GITEOn October 16,200 7 ·23 comments
Q. I'm new to Linux and installed centos on my laptop. How do I create a file from Bash prompt without using GUI tools?
A.Linux/Unix offer commands line tools and text editors for creating text files. you can use VI or Joe text editor. it is a terminal-based text editor for Linux/Unix systems, available under the GPL. it is designed to be easy to use.
Create a text file using cat command
To create a text file called foo.txt, enter:
$ Cat> foo.txt
Output:
This is a test. Hello world! PressCTRL + dTo save file
To display file contents, Type
$ Cat foot.txt
Create a text file using Joe Text Editor
Joe is text editor. To create a file called foo.txt, type:
$ Joe-help foo.txt
You will see help menu on screen. Next type something. To save the file and leave Joe, by typing ^ kx (press Ctrl + K + x ).
Create a text file using vi/Vim Text Editor
VI/Vim is another text editor. To create a file called bar.txt, type:
$ VI bar.txt
Press 'I' to insert new text. To save the file and Leave Vi, type ESC ++: + x (Press ESC key, type: followed by X and [enter] key ).
Further readings
- Learn more about Joe here: Introduction to the Joe Text Editor
- Learn more about VI here: Download mastering the VI editor PDF version.