Use the touch command:

The touch utility sets the modification and access times of files to the
current time of day. If the file doesn't exist, it is created with
default permissions.

A FILE argument that does not exist is created as an empty file by the
touch command, unless the -c option is supplied.

Example:

touch newfile
Answer from Isaiah on askubuntu.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ linux-unix โ€บ touch-command-in-linux-with-examples
Creating an Empty File in Linux | Touch Command - GeeksforGeeks
Itโ€™s one of the simplest and most commonly used commands for file management. The touch command creates a new, empty file if the file does not already exist.
Published ย  December 8, 2025
Discussions

How do I create a new empty file in a bash script? - Unix & Linux Stack Exchange
Question: How would I create an empty file within a bash script? If one simply tries perl script1.pl -o filename.txt, the script gives an error that the file doesn't exist. ... Use touch command. More on unix.stackexchange.com
๐ŸŒ unix.stackexchange.com
February 8, 2017
How to create a new file in unix? - Stack Overflow
How do I create a new file in a different directory? If the file exists it should also create a new file. I am using the command: Touch workdirectory/filename.txt More on stackoverflow.com
๐ŸŒ stackoverflow.com
linux - Create empty multiple files in Unix that contain 0 bytes using awk or bash? - Stack Overflow
I am trying to create multiple empty files on Unix but I do not know if AWK command can do that or do I have to do it in bash? if yes could you help me, please? At this moment I use this command: ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
linux - shell script to create empty files with all possible permissions - Stack Overflow
How to write a shell script that creates empty files with all possible permissions. File names should be, for example, rwxrw_r__.txt. I know how to do it manually. As an example: #!/bin/bash touch... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
nixCraft
cyberciti.biz โ€บ nixcraft โ€บ howto โ€บ linux โ€บ how to create empty file in linux
How to create empty file in Linux - nixCraft
February 21, 2022 - Me thinks that touch command is the easiest way to create new, empty files on Linux or Unix-like systems including macOS.
๐ŸŒ
BrandCrock gmbh
brandcrock.com โ€บ home โ€บ blog โ€บ how to create an empty file in linux command line
Create an empty file in Linux Command Line - BrandCrock
January 16, 2025 - Each method has its pros and cons, depending on the context of usage. Below are the most common and reliable ways to create empty files. ... touch command is the most common and simplest method to create an empty file in Linux.
Find elsewhere
๐ŸŒ
Warp
warp.dev โ€บ terminus โ€บ linux-create-file
Warp: How To Create Files In Linux
April 25, 2024 - For example, this command will create a new empty file named test_script.sh in the current working directory:
๐ŸŒ
Vultr
docs.vultr.com โ€บ how-to-create-an-empty-file-in-linux-using-the-touch-command
Create Empty Files in Linux with the touch Command Guide | Vultr Docs
November 21, 2023 - The above command sets the access and modification time of file1.txt to January 1, 1990, 00:00 AM. ... Create log files in a Bash script using touch. Create a sample script log_script.sh using a text editor such as Nano ... Add the following contents to the file. ... Save and close the file. ... The above script creates five empty log files in your working directory using the format logfile_1.log to logfile_5.log.
๐ŸŒ
Wikihow
wikihow.com โ€บ computers and electronics โ€บ operating systems โ€บ 4 ways to create a file in unix - wikihow
4 Ways to Create a File in Unix - wikiHow
April 29, 2025 - Open a terminal window, type โ€œtouch newfilename,โ€ and hit enter to create a new blank file. Or, type โ€œcat > newfilename,โ€ hit enter, and enter some text to create a text file with cat.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-create-a-blank-file-in-Linux-from-command-line
How to create a blank file in Linux from command line - Quora
Answer (1 of 14): [code]$ touch file.extension [/code]^ The proper way [code]cat > file.extension [/code]cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to concatenate files. [wikipedia]. You are displaying not...
๐ŸŒ
Computer Hope
computerhope.com โ€บ issues โ€บ ch001314.htm
How to Create an Empty or Blank File
June 1, 2025 - The ^Z represents pressing Ctrl+Z on the keyboard when at a command prompt. After pressing this shortcut, a 1 file copied message should appear. ... Use the touch command, as shown below, to create an empty file.
Top answer
1 of 3
3

Do a loop:

for ((i=0; i < 512; i++)); do 
    mod=$(printf "%03o" "$i"); 
    touch ${mod}.txt; chmod $mod $mod.txt; 
done

Rather than trying to construct the names, if you want the names to look like the output of ls -l, just do something like

for ((i=0; i < 512; i++)); do
    mod=$(printf "%03o" "$i") 
    touch ${mod}.txt
    chmod $mod $mod.txt
    n=$(ls -l $mod.txt | cut -b1-10)
    mv -- $mod.txt "$n.txt"
done
2 of 3
3

It's just a permutations problem.

p=( --- --x -w- -wx r-- r-x rw- rwx ) # the set of permissions
for u in "${p[@]}"; do for g in "${p[@]}"; do for o in "${p[@]}"; do
  f="task5/$u$g$o.txt"; touch -- "$f" && chmod "u=${u//-/},g=${g//-/},o=${o//-/}" -- "$f";
done; done; done

NOTE

  • thanks to @kvantour for pointing out I was passing dashed to chmod, and that it doesn't know what to do with them. I am surprised I wasn't getting errors.

Let's break it down and look at what's happening.

If you have any questions about what permissions sets mean or how chmod works, see here.

So for each of the user, group, or other, there are eight possible symbolic representations (representing the values of one octal digit, 0-7).

We set those into a simple array we can loop over.

p=( --- --x -w- -wx r-- r-x rw- rwx ) # the set of permissions 

You can access any element with it's octal digit (technically the decimal equivalent, but that doesn't matter unless you go over 7) so ${p[5]} is r-x. Indexing with @ returns the whole array, so the loops walk through them sequentially with ${p[@]}.

To get every possible permutation, we loop over them for each of user/group/other.

for u in "${p[@]}"; do # assign each permission set for the user
for g in "${p[@]}"; do # assign each permission set for the group
for o in "${p[@]}"; do # assign each permission set for the other

This is just simple iterations in nested loops to hit every permutation.

  f="task5/$u$g$o.txt" # assign the permissions string AS the filename

By putting the path and filename info into a variable, we can maintain any changes in one place, and it makes the rest of the line shorter and easier to read.

  touch -- "$f" && # create the file and test for success

touch will create an empty file. Because the filenames could sometimes begin with a dash (any time the permissions disallow user read), we give touch a first argument of --, which is a *NIX standard idiom meaning "options are done now, anything left is arguments"; otherwise it would try to interpret a leading dash as an invalid option set and fail. This won't be a problem while you are putting "task5/" at the beginning of the filename, but if you end up using the filename bare it would.

The && is a boolean test to see whether touch succeeded. If it did not, then we silently skip trying the chmod (touch should have emitted an error message for your debugging, but if that fails, you probably got a ton of them, and will need to fix whatever ...)

  chmod "u=${u//-/},g=${g//-/},o=${o//-/}" -- "$f" # change the permissions

This uses chmod's symbolic mode. We have the permissions of each section from the nexted loops - just apply them. Again, we use the -- to tell chmod when we are done passing options so that leading dashes in filenames won't be a problem later if you refactor just just cd into the directory and create the files locally, though even then you could always prefix ./ or $PWD/ on it.

We have to get rid of thew dashes in the symbolic file modes, though, as (thanks agains @kvantour) chmod doesn't recognize those. An inline string edit works beautirully: in "u=${u//-/},g=${g//-/},o=${o//-/}", the // inside the variable spec is a replacement of all occurrences, replacing - with the nothing between the following / and }.

done; done; done # these just close each of the loops

We could (and probably should) put each of these on separate lines, but the interpreter doesn't care since we used semicolons. It lets us compact the code to put the loop nesting and closures on lines together, so long as you are comfortable with the ONE thing that's changing being obvious enough.

Anything you still have questions about that I didn't cover?

Alternate

Another version, because I like going through a loop once instead of nested shenannigans...

p=( --- --x -w- -wx r-- r-x rw- rwx ) # the set of permissions
for dec in {0..511}; do oct="$(printf "%03o" "$dec")"
  u="${p[${oct:0:1}]}"; g="${p[${oct:1:1}]}"; o="${p[${oct:2:1}]}";
  f="task5/$u$g$o.txt"; touch "$f"; chmod "u=${u//-/},g=${g//-/},o=${o//-/}" "$f";
done

This walks through the combinations numerically, converts decimal to octal with printf, slices each digit out of the octal permission set with basic substring parsing and uses it to look up the relevant string from the array, assign the segments, assign the resulting filename, touch/create the file, then apply the scrubbed permissions strings with chmod. It's once-through and faster, if a little harder to understand.

u="${p[${oct:0:1}]}" # grabs 1 byte from offset 0 of $oct as index to $p

As suggested, to skip the decimal to octal conversion step, replace:

for dec in {0..511}; do oct="$(printf "%03o" "$dec")"

with

for oct in {0..7}{0..7}{0..7}; do 
๐ŸŒ
ManageEngine
manageengine.com โ€บ home โ€บ troubleshooting
How to create a file in Linux
May 26, 2025 - Use the touch command followed by the file name to create an empty file.
๐ŸŒ
Tutorial Republic
tutorialrepublic.com โ€บ faq โ€บ how-to-create-an-empty-file-from-command-line-in-ubuntu.php
How to Create an Empty File from Command Line in Ubuntu
PHP Array Functions PHP String Functions PHP File System Functions PHP Date/Time Functions PHP Calendar Functions PHP MySQLi Functions PHP Filters PHP Error Levels ... You can use the touch command to create a new and empty file from the command ...
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ touch-command-in-linux-with-examples
How to Create an Empty File in Linux | Touch Command - GeeksforGeeks
The touch command is a standard command used in the UNIX/Linux operating system which is used to create, change and modify the timestamps of a file. Basically, there are two different commands to create a file in the Linux system which are as ...
Published ย  July 12, 2024
๐ŸŒ
Unix Community
community.unix.com โ€บ shell programming and scripting
Creating Empty File - Shell Programming and Scripting - Unix Linux Community
November 25, 2011 - Hi, I want to create EMPTY File through Shell Script but not using touch Command, Please let me know any work around.. Thanks, Samadhan
๐ŸŒ
SwCarpentry
swcarpentry.github.io โ€บ shell-novice โ€บ 03-create.html
The Unix Shell: Working With Files and Directories
1 week ago - The touch command allows you to efficiently generate a blank text file to be used by such programs. ... To avoid confusion later on, we suggest removing the file youโ€™ve just created before proceeding with the rest of the episode, otherwise future outputs may vary from those given in the lesson.
๐ŸŒ
CyberPanel
cyberpanel.net โ€บ blog โ€บ how-to-empty-a-file-in-linux
Learn How To Empty a File in Linux: Clear Content, Not Files
April 23, 2025 - To create an empty file in Linux using the Vim text editor, open the terminal, go to the desired directory, launch Vim, replace โ€œempty_file.txtโ€ with your chosen file name, enter insert mode, and then save and exit Vim. Launch a terminal on your Linux machine. Use the cd command to go to the folder you want.
๐ŸŒ
Quora
quora.com โ€บ How-do-I-create-a-file-in-UNIX
How to create a file in UNIX - Quora
vi command (or nano): You can use any editor to create a file. It will create an empty file and open it in edit mode where you can write anything and save, in directory specified.