You can use the following commands:
cat > fileName - Create a text file.
> fileName - Create an empty file.
touch fileName - Create an empty file.
Example - Create an empty file
Open a terminal and type the following command to create a file called foo.txt:
To verify your file, enter:
ls -l foo.txt cat foo.txt
Example - Create a text file
Open a terminal and type the following cat command to create a text file called bar.txt:
cat > bar.txt
Add text or lines:
This is a test. To swap out hard drive as an external storage you need to use ^D
You need to press [CTRL] + [D] i.e. hold the control key down, then tap d. The > symbol tells the Ubuntu that what is typed is to be stored into the file called bar.txt. To verify your data, enter:
ls -l bar.txt cat bar.txt