Filenames and metadata
On this page
Your notes are in a file called meeting notes.txt. You type cat meeting notes.txt, and cat complains about two missing files. The file is there; the command did not receive its name as you intended.
By the end, you can address names containing spaces or a leading hyphen, inspect what a file contains without trusting its extension, and read its size, ownership, and recorded times.
Before you start
Section titled “Before you start”Finish Removing files deliberately (B06.2). Keep your existing ~/lab from B04.1’s setup, including the original notes and report.
Work only in ~/lab/b06/inspection. Leave the earlier project, archive, handoff, and removal exercises intact. Run this setup once; use Reset this lesson before repeating it.
Single quotes in the setup keep a filename’s spaces together. The next section shows what happens without them. ./ means “in this directory”, as in B05.2; its use before -draft.txt is explained below.
cd ~/lab/b06mkdir -p inspectioncd inspectioncp ../../Documents/notes.txt 'meeting notes.txt'cp ../../Documents/notes.txt photo.jpgcp ../../Documents/report.txt ./-draft.txtcp ./-draft.txt release-notes.txthead -c 2048 /dev/zero > padding.binpwdls -1/home/learner/lab/b06/inspection-draft.txt'meeting notes.txt'padding.binphoto.jpgrelease-notes.txtThe copies preserve the source files. From inspection, ../../Documents goes up through b06 to lab, then into Documents.
The head line prepares a file with a known size. -c 2048 reads 2,048 bytes, units of stored data, instead of a number of lines. /dev/zero supplies zero-valued bytes; > saves them in padding.bin, as > saved text in B04.1. This creates data, not readable notes.
ls -1 prints one name per line. Its displayed quotes around the spaced name are not part of the filename. Your prompt ends in ~/lab/b06/inspection$; every relative path below starts here.
Give cat one pathname
Section titled “Give cat one pathname”Before running the broken command, predict which paths cat will try to open:
cat meeting notes.txtRun it, then compare with your guess
cat: meeting: No such file or directorycat: notes.txt: No such file or directoryThe messages name meeting and notes.txt separately. Without quotes, the space separates two arguments. Neither path exists in this directory.
Put single quotes around the whole name:
cat 'meeting notes.txt'Buy printer paperRenew lab VM snapshotBash uses the quotes to pass meeting notes.txt as one argument. The quotes themselves are not passed to cat. This is quoting: keeping characters together and literal. Single quotes are enough for these names, which contain no single quote themselves. The broader rules belong to B08.
Tab completion (B04.2) handles the space for you by inserting a backslash, so cat meet followed by Tab becomes cat meeting\ notes.txt. A backslash keeps the single character after it literal, so the space does not split the name. It is another form of quoting; B08 covers the full rules.
cat meeting\ notes.txtBuy printer paperRenew lab VM snapshotDistinguish a hyphen from an option
Section titled “Distinguish a hyphen from an option”A hyphen inside a name needs no special treatment:
cat release-notes.txtQuarterly lab reportThe first character is r, so this argument does not look like an option. A leading hyphen is different. Even quoting the name is not enough:
ls '-draft.txt'ls: invalid option -- '.'Try 'ls --help' for more information.Bash passed one argument, but that argument still starts with -. ls tries to read its characters as options and rejects .. Quotes solve Bash’s separation of words; they do not tell a utility to stop reading options.
For GNU ls, put -- before the filename:
ls -- '-draft.txt'-draft.txt-- marks the end of options: the arguments after it are treated as names. Many utilities, including the ls, file, and stat used here, support it. It is a utility convention, not a universal Bash feature; check the command’s documentation.
Another way is to start the path with ./:
cat ./-draft.txtQuarterly lab reportThe path still names -draft.txt in the current directory, but the argument starts with . instead of -. Both corrections inspect the existing file without renaming it.
Check the contents behind the extension
Section titled “Check the contents behind the extension”You need to decide what kind of file you are inspecting before choosing a program to open it:
file 'meeting notes.txt'meeting notes.txt: ASCII textfile examines the file and reports an identification. ASCII text means text using a character set that includes these English letters, spaces, and newlines.
Now predict what file reports for photo.jpg. Does its extension make it a JPEG image?
file photo.jpgRun it, then compare with your guess
photo.jpg: ASCII textIt is text too. The setup copied the notes and gave the copy a name ending in .jpg. That extension, the suffix after the final dot, did not turn the contents into an image.
For a download, a mismatch is a reason to stop and investigate before opening it in the program its extension suggests. A matching identification is not a guarantee of safety: file classifies data; it does not certify that the file is harmless.
Read the file’s recorded details
Section titled “Read the file’s recorded details”You know what the note contains. Now ask about the file itself:
stat 'meeting notes.txt' File: meeting notes.txt Size: 40 Blocks: 8 IO Block: 4096 regular fileDevice: 0,93 Inode: 38079 Links: 1Access: (0644/-rw-r--r--) Uid: ( 1001/ learner) Gid: ( 1001/ learner)Access: 2026-11-11 08:28:17.043006176 +0000Modify: 2026-11-11 08:28:13.000824361 +0000Change: 2026-11-11 08:28:13.000824361 +0000 Birth: 2026-11-11 08:28:12.998533269 +0000stat displays metadata, information about the file rather than its text. These are captured values, not values to reproduce. Your dates, time zone, inode and device numbers, numeric user/group IDs, and allocation details can differ. The replay is another recorded run; its metadata need not match a run on your computer. On the course VM, the numeric user and group IDs are usually 1000, and the time zone follows the VM’s settings.
Start with the fields that answer everyday questions:
- Size: 40 is the content length in bytes. It includes spaces and newline characters, not only visible letters.
- Uid identifies the owning user; Gid identifies the owning group. Both show the name
learnerhere, alongside numeric IDs. Groups let permission rules apply to several accounts, as in B03.3. - The first Access: line contains permission settings. Leave its numbers and letters for B11; this lesson does not change them.
The date rows answer different questions:
| Row | Common name | What the time records |
|---|---|---|
| Access | atime | Last recorded access to the contents, such as reading |
| Modify | mtime | Last content modification, or a time explicitly set by a tool such as touch |
| Change | ctime | Last inode status change, including content or metadata changes |
| Birth | birth time | Creation time, when the filesystem and tools provide it |
ctime is not creation time. Changing ownership, for example, changes status without rewriting the contents. Birth time is available in this capture; another filesystem or interface may not supply it, and stat can show a dash instead. Do not substitute ctime for a missing birth time.
Access times are not an exact log of every read: filesystem settings can delay or suppress updates. Do not infer a reliable sequence of events merely because two rows differ, or assume that reading always changes the displayed time.
Inode is the number identifying the file’s metadata record within its filesystem. Keep that field in mind for B06.4’s links. Device identifies the filesystem’s device; Links counts hard-link names. Those relationships are the next lesson’s subject.
learner@rootvolt:~/lab/b06/inspection$ cat 'meeting notes.txt'Buy printer paper
Renew lab VM snapshotlearner@rootvolt:~/lab/b06/inspection$ file 'meeting notes.txt'meeting notes.txt: ASCII textlearner@rootvolt:~/lab/b06/inspection$ stat 'meeting notes.txt' File: meeting notes.txt
Size: 40 Blocks: 8 IO Block: 4096 regular file
Device: 0,93 Inode: 38079 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1001/ learner) Gid: ( 1001/ learner)
Access: 2026-11-11 08:28:17.043006176 +0000
Modify: 2026-11-11 08:28:13.000824361 +0000
Change: 2026-11-11 08:28:13.000824361 +0000
Birth: 2026-11-11 08:28:12.998533269 +0000learner@rootvolt:~/lab/b06/inspection$ Steps (9)
- Type
cat 'meeting notes.txt' - Press Enter
- Output:
Buy printer paper Renew lab VM snapshot - Type
file 'meeting notes.txt' - Press Enter
- Output:
meeting notes.txt: ASCII text - Type
stat 'meeting notes.txt' - Press Enter
- Output:
File: meeting notes.txt Size: 40 Blocks: 8 IO Block: 4096 regular file Device: 0,93 Inode: 38079 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 1001/ learner) Gid: ( 1001/ learner) Access: 2026-11-11 08:28:17.043006176 +0000 Modify: 2026-11-11 08:28:13.000824361 +0000 Change: 2026-11-11 08:28:13.000824361 +0000 Birth: 2026-11-11 08:28:12.998533269 +0000
In words: cat prints the two note lines, file reports ASCII text, and stat reports a 40-byte file owned by learner, with its recorded times. The static transcript preserves the same information without playback.
Compare bytes with a readable size
Section titled “Compare bytes with a readable size”Inspect the padding file from setup:
stat padding.bin File: padding.bin Size: 2048 Blocks: 8 IO Block: 4096 regular fileDevice: 0,93 Inode: 38076 Links: 1Access: (0644/-rw-r--r--) Uid: ( 1001/ learner) Gid: ( 1001/ learner)Access: 2026-11-11 08:28:15.018769488 +0000Modify: 2026-11-11 08:28:15.022844135 +0000Change: 2026-11-11 08:28:15.022844135 +0000 Birth: 2026-11-11 08:28:15.018769488 +0000Its Size is 2,048 bytes. Blocks describes allocated storage, and IO Block a transfer-size hint; neither replaces Size as the content length.
Compare the long listing with -h added:
ls -lh 'meeting notes.txt' padding.bin-rw-r--r-- 1 learner learner 40 Nov 11 08:28 'meeting notes.txt'-rw-r--r-- 1 learner learner 2.0K Nov 11 08:28 padding.bin-l is the long format from B04. -h makes sizes human-readable, using powers of 1,024: 2.0K represents 2,048 bytes. The 40-byte note stays 40. The two learner columns are owner and group; the date is modification time, shown with less detail than stat. Your dates will differ.
Try it yourself
Section titled “Try it yourself”Goal: Inspect a handoff file whose name starts with a hyphen and contains a space.
Prepare a disposable copy:
cp -- release-notes.txt '-arrival notes.dat'Without renaming it, identify its content type, read its metadata, and print its contents. Explain why the name needs both space handling and option handling. State its byte size, owner/group, and which timestamp is status-change time. Say whether .dat proves anything about its contents.
Expected: Three successful inspections of the same file, with no missing-path or invalid-option error.
Hint
Quotes preserve the space. They do not remove the leading hyphen. Use an end-of-options marker supported by the inspection utility, or prefix the quoted path with ./.
Solution
file -- '-arrival notes.dat'stat -- '-arrival notes.dat'cat './-arrival notes.dat'-arrival notes.dat: ASCII text File: -arrival notes.dat Size: 21 Blocks: 8 IO Block: 4096 regular fileDevice: 0,93 Inode: 38075 Links: 1Access: (0644/-rw-r--r--) Uid: ( 1001/ learner) Gid: ( 1001/ learner)Access: 2026-11-11 08:28:23.351748437 +0000Modify: 2026-11-11 08:28:22.827489128 +0000Change: 2026-11-11 08:28:22.827489128 +0000 Birth: 2026-11-11 08:28:22.823685898 +0000Quarterly lab reportThis is a 21-byte text file owned by user learner and group learner in the capture. Change is ctime, not creation time. The extension does not prove a type. Quotes make one argument; -- or ./ prevents its leading hyphen from being read as an option. The displayed metadata values vary as described above.
Reset this lesson
Section titled “Reset this lesson”The inspections preserve the file contents. To restore the initial five-file layout, including removing the challenge copy, return to the parent and inspect the target:
cd ~/lab/b06ls -AR inspection-A includes hidden entries and -R includes subdirectories. After the solution:
inspection:'-arrival notes.dat' 'meeting notes.txt' photo.jpg -draft.txt padding.bin release-notes.txtrm -r ~/lab/b06/inspectionIt succeeds silently. Run the setup under Before you start again. If the directory is already absent, skip removal and run setup. This restores the names and contents; it creates fresh files, so timestamps and inode numbers need not match the previous run.
- Single quotes keep a spaced pathname together as one argument; the quotes are not part of the name.
- A leading hyphen can look like an option. Use
--where the utility supports it, or a path beginning with./. - Extensions do not prove content type.
filereports an identification, not a safety guarantee. statshows metadata;Sizecounts bytes, andls -lhuses readable units. Owner and group identify who the file belongs to.- Access, modification, and status-change times describe different events. ctime is not creation time; birth time may be unavailable.
Next, Hard links and symbolic links (B06.4) follows names to inodes or target paths and checks what survives removal.