Challenge - 5 Problems
Touch Command Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate1:30remaining
What is the output of this command sequence?
You run these commands in a Linux terminal:
What will the
touch file1.txt
ls -l file1.txtWhat will the
ls -l file1.txt command show about file1.txt?Linux CLI
touch file1.txt ls -l file1.txt
Attempts:
2 left
💡 Hint
The touch command creates an empty file or updates the timestamp if it exists.
✗ Incorrect
The touch command creates an empty file if it doesn't exist, so the file size is 0 bytes. The timestamp is set to the current time.
💻 Command Output
intermediate1:30remaining
What happens when you run touch on an existing file?
Suppose
You run:
What changes after this command?
example.txt already exists with some content.You run:
touch example.txtWhat changes after this command?
Linux CLI
touch example.txt
Attempts:
2 left
💡 Hint
Touch updates timestamps without changing file content.
✗ Incorrect
Touch updates the modification and access timestamps to current time without changing the file content or size.
📝 Syntax
advanced1:30remaining
Which touch command creates multiple empty files at once?
You want to create three empty files named
Which command does this correctly?
a.txt, b.txt, and c.txt in one command.Which command does this correctly?
Attempts:
2 left
💡 Hint
Touch accepts multiple filenames separated by spaces.
✗ Incorrect
The touch command can take multiple filenames separated by spaces to create multiple files at once.
💻 Command Output
advanced1:30remaining
What error occurs when using touch on a directory without permissions?
You try to run:
But you are a normal user without root permissions.
What is the expected output?
touch /root/secret.txtBut you are a normal user without root permissions.
What is the expected output?
Linux CLI
touch /root/secret.txt
Attempts:
2 left
💡 Hint
Normal users cannot write files in root-owned directories.
✗ Incorrect
Without permission, touch cannot create or update files in /root and shows a permission denied error.
🚀 Application
expert2:00remaining
How to create an empty file only if it does not exist using touch?
You want to create an empty file named
Which command achieves this without changing the timestamp if the file exists?
log.txt only if it does not already exist.Which command achieves this without changing the timestamp if the file exists?
Attempts:
2 left
💡 Hint
The -c option prevents creating a new file if it doesn't exist.
✗ Incorrect
The touch -c option updates timestamps only if the file exists; it does not create a new file.