nerdexam
Linux_Foundation

LFCS · Question #832

Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?

The correct answer is A. file /tmp/myfile.txt. The file command only reads file metadata and content to determine its type, thus it does not alter the file or its modification timestamp. All other options involve writing or explicitly touching the file, which updates the timestamp.

Submitted by amina.ke· Apr 18, 2026Essential Commands

Question

Which of the following commands will NOT update the modify timestamp on the file /tmp/myfile.txt?

Options

  • Afile /tmp/myfile.txt
  • Becho "Hello" >/tmp/myfile.txt
  • Csed -ie "s/1/2/" /tmp/myfile.txt
  • Decho -n "Hello" >>/tmp/myfile.txt
  • Etouch /tmp/myfile.txt

How the community answered

(45 responses)
  • A
    91% (41)
  • B
    2% (1)
  • D
    4% (2)
  • E
    2% (1)

Why each option

The `file` command only reads file metadata and content to determine its type, thus it does not alter the file or its modification timestamp. All other options involve writing or explicitly touching the file, which updates the timestamp.

Afile /tmp/myfile.txtCorrect

The `file` command is used for identifying file types and only reads the file's content and metadata without making any modifications. Therefore, executing `file /tmp/myfile.txt` will not update the modification timestamp of the file.

Becho "Hello" >/tmp/myfile.txt

Redirecting output with `echo "Hello" >/tmp/myfile.txt` truncates and writes new content to the file, which is a modification and updates the modification timestamp.

Csed -ie "s/1/2/" /tmp/myfile.txt

The `sed -ie "s/1/2/" /tmp/myfile.txt` command with the `-i` option modifies the file in place, changing its content and consequently updating its modification timestamp.

Decho -n "Hello" >>/tmp/myfile.txt

Appending output with `echo -n "Hello" >>/tmp/myfile.txt` modifies the file by adding content, which updates its modification timestamp.

Etouch /tmp/myfile.txt

The `touch /tmp/myfile.txt` command's primary function is to update the access and/or modification timestamps of a file to the current time.

Concept tested: Linux file timestamp modification

Source: https://man7.org/linux/man-pages/man1/file.1.html

Topics

#File management#Timestamps#Linux commands#Filesystem

Community Discussion

No community discussion yet for this question.

Full LFCS Practice