arrow
arrow
arrow
In most Unix-based operating systems, which command is used to create an empty file if the file does not already exist?
Question

In most Unix-based operating systems, which command is used to create an empty file if the file does not already exist?

A.

cp

B.

mkdir

C.

touch

D.

mkfile

Correct option is C

The correct answer is: (c) touch

Explanation:

  • The **touch** command is used in Unix/Linux systems to create an empty file if it does not already exist.
  • If the file exists, touch updates the access and modification timestamps.
  • Syntax: touch filename.txt creates filename.txt if it doesn't already exist.

Information Booster:

  • touch is frequently used in shell scripting and file automation.
  • It’s part of GNU core utilities and found in nearly all Unix-based OSs.
  • It doesn’t modify file content, only timestamps.
  • Useful for generating placeholder files.
  • Common in Linux distributions like Ubuntu, Fedora, and macOS.
  • Does not show output unless an error occurs.

Additional Information:

  • cp – Used to copy files and directories, not create new empty files.
  • mkdir – Used to create directories, not files.
  • mkfile – Used in Solaris OS to create a file of specified size, but not widely used in Linux.

test-prime-package

Access ‘RRB NTPC’ Mock Tests with

  • 60000+ Mocks and Previous Year Papers
  • Unlimited Re-Attempts
  • Personalised Report Card
  • 500% Refund on Final Selection
  • Largest Community
students-icon
176k+ students have already unlocked exclusive benefits with Test Prime!

Free Tests

Free
Must Attempt

RRB Technician Gr.III Full Mock Test 1

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon90 Mins
languageIcon English
Free
Must Attempt

RRB Technician Grade-3 PYP (20 Dec 2024 S2)

languageIcon English
  • pdpQsnIcon100 Questions
  • pdpsheetsIcon100 Marks
  • timerIcon90 Mins
languageIcon English
Free
Must Attempt

General Science Section Test 01

languageIcon English
  • pdpQsnIcon40 Questions
  • pdpsheetsIcon40 Marks
  • timerIcon20 Mins
languageIcon English