How To Create A File In Linux

Table of contents:

How To Create A File In Linux
How To Create A File In Linux

Video: How To Create A File In Linux

Video: How To Create A File In Linux
Video: Linux Creating Files 2024, May
Anonim

Novice Linux users can often quickly find ways to open the various file formats that are available, but have difficulty creating their own. How you create a new file depends on what data you intend to store in it.

How to create a file in Linux
How to create a file in Linux

Necessary

installed OS based on Linux kernel

Instructions

Step 1

In those Linux programs that have a graphical user interface, the process of creating a new file is the same as in Windows. For example, start the text editor OpenOffice.org or Abiword, choose Save As from the menu, and specify a file name. In doing so, two aspects should be taken into account. First, for the document to be read by Windows users, it must be saved in a compatible format (such as DOC). Secondly, you should choose your own user folder as a place to save, the path to which looks like this: / home / username, where username is your local username (login). Within this folder, you can optionally create subdirectories.

Step 2

To create a new file for subsequent opening with a console text editor, you can make a copy of an existing file of the same format, open it with a program, delete all content and replace it with your own. But this method is not very convenient. It is much better to use the built-in function for creating a new document. For example, in Midnight Commander, you can start the editor with an argument of the name of a non-existent file: mcedit filename, where filename is the name of the file (optionally with the required extension). During editing, the file should be saved periodically by pressing the F2 key and then Enter. After the first such procedure, it will appear in the disk folder from which you called the editor (if you have permission to write to this folder).

Step 3

If the console text editor does not support substitution for a file name that does not exist, create a new document with the following command: cat> filename Enter a few characters, then press Enter, followed by Ctrl + C. Open the resulting file with an editor, remove the characters that you entered from it, and enter new text.

Step 4

After creating a file, do not be surprised that it will not immediately run as a script. If it is designed to do just that, first make it executable: chmod 755 filename Then run it like this:./ filename In the Midnight Commander file manager, such files are highlighted in green and have asterisks to the left of their names. To run any of them, move the pointer to it and press Enter.

Recommended: