What does the touch command do in UNIX?

What does the touch command do in UNIX?

a) Creates a new, empty file
b) Changes file permissions
c) Displays file content
d) Moves files between directories

Answer:

a) Creates a new, empty file

Explanation:

The touch command in UNIX is used to create a new, empty file. When you run touch filename, it creates a file with the specified name if it doesn’t already exist. If the file already exists, it updates its timestamp without modifying the content.

For example, running touch newfile.txt creates an empty file named newfile.txt in the current directory. This command is often used to quickly create placeholder files or to update the modification time of existing files without editing them.

Understanding the touch command is helpful for file creation and management. It’s a simple but powerful tool for setting up new files or refreshing timestamps in UNIX environments.

Reference:

Top 50 Unix MCQ Questions & Answers

Scroll to Top