Creating Files & Directories
Shell·3 min read·Jan 1, 2025
On Unix-like operating systems, the two most common types of files are regular files and directories.
Regular files are raw files used to store all kinds of data such as text, images, audio, video, scripts, programs, etc.
Directories, also called folders, are a filesystem structure which contains references to other files and possibly other directories, generally called entries.
Creating regular files
To create one or more empty regular files, you can use the touch command as follows:
$ touch file ...Where file ... is a list of paths to the files you want to create, separated by a space character.
Example
For example, this command will create a new empty regular file named index.html into the current directory:
$ touch index.htmlThis command will create a new empty regular files named guests.txt into the Documents directory:
$ touch ~/Documents/guests.txtAnd this command will create two new empty regular files named login.js and signup.js into the controllers directory:
$ touch ./controllers/login.js ./controllers/signup.jsFile extensions in Unix
Unlock the CLI & Scripting with Bash module
Learn how to gain advanced control over the OS and automate complex routine tasks prone to manual errors with the CLI and Bash scripting.
You get immediate access to:
- 34 focused lessons across the CLI and Bash
- 4 real-world projects with commented solutions
- Ongoing updates to this bundle
- Lifetime access to this bundle