>_How the Terminal Works · Lesson 2 of 7
What Happens When You Press Enter
'ls -l' — Enter — output appears. Between those two moments: parsing, an environment-variable treasure hunt, a process being born, and three data streams being wired up. Here's the whole journey.
Before the search, the shell expands your line: $HOME becomes /home/you, *.txt becomes every matching filename, ~ becomes your home directory. The program never sees the wildcard — it receives the already-expanded list. Then the shell asks the OS to fork a child process, exec the program in it with those arguments, and waits for it to exit.
✦ Tip
'Command not found' now debuggable: the shell searched every PATH directory and none contained that name. Installed something and it's not found? Its directory isn't in PATH, or the shell cached an old lookup (hash -r / rehash clears it).
'Command not found' now debuggable: the shell searched every PATH directory and none contained that name. Installed something and it's not found? Its directory isn't in PATH, or the shell cached an old lookup (hash -r / rehash clears it).