touch command. This is often not very useful, except for some programs that only check the existence of a file in order to do something.To create an empty file, execute the following terminal command [how?]:
touch empty-file.txt
This will create an empty file called empty-file.txt in the current working directory. See [How to Refer to Files and Folders using the Terminal on Linux Mint] for how to write this filename argument.
Tip: if you want to create an empty text file to edit it, in many cases using touch won't be necessary, because text editors on Linux can open a non-existing filepath for editing. For example, you can execute xed new-file.txt to edit it in the default text editor on Linux Mint even if new-file.txt doesn't exist. When you save the file in xed, it will create a new file automatically. The same works in terminal-based text editors like nano and vi.
Tip: touch can create multiple files at once if you pass it more than one argument. For example: touch a b c d e f will create 6 files.
Questions and Answers
Can You Create an Empty Image with Touch?
Files created by touch have zero bytes. This means the whole file is empty, and this only makes sense for plain text files. You can't create an empty image file of certain resolution in pixels using touch. To create an empty image, you would need a program like ImageMagick's convert utility.
What Happens If You touch a symlink?
If the target of touch is a symlink, the file is created at the filepath the symlink points to [How Symlinks Work].
What Happens if You touch a File That Already Exists?
If the target of touch already exists, the file won't be modified. In other words, nothing happens. This contrasts with how it works on many other operations.
For example, if you use cp to copy a file and the target already exists, it will be overwritten; if you echo "" > new-file.txt and new-file.txt already exists, it will be overwritten.
It's only touch that does nothing when the file already exists.