The touch command is used to create a new empty file from the Linux command line. It is commonly used when working with files through SSH, especially during website development, testing, or server administration.
The command creates the file immediately if it does not already exist.
Table of Contents
How the command works
To create a new file, use:
touch filename.txt For example:
touch /yourdomain.com/public_html/page.html This command creates an empty HTML file named page.html inside the public_html directory of your website.
When to use touch
The touch command is useful when you need to:
- Create a new file before editing it.
- Generate configuration or log files.
- Prepare website files directly from the terminal.
- Test file permissions or application behavior.
Practical considerations
If the specified file already exists, the command will not overwrite its contents. Instead, the file’s modification timestamp may be updated.
The file is created in the directory from which the command is executed unless a full path is provided. If you are unsure of your current location, use the pwd command to display the current directory path before creating files.
Before you begin
You need SSH access enabled on your hosting account to use command-line tools. If SSH access is not yet active, refer to the guide for enabling SSH access in the mybox panel.