Linux Labs

First steps / Stage 5 of 15

Navigation and paths

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 8 · on a machine · 4 min

Find a file by name

You know the file's name but not where it lives. find walks the directory tree for you and prints every match.

bash
find /etc/nginx -type f -name nginx.conf

The first word after find is where to look: that directory with everything inside it. -type f keeps only regular files, and -name sets the name. find prints each match on its own line, as a path from the directory it started in.

Start the search in a directory where the file can be. A search from / walks the whole system: on the training machine that takes a few seconds and prints hundreds of Permission denied lines about other users' directories.

Put a path with a space in quotes, all of it: cat 'release notes.txt'. Without quotes the shell splits it into two words, and cat looks for two files, release and notes.txt. The quotes themselves are not part of the path.

Exercise · look

Find the live configuration

There are two site.conf files under ~/path-lab. Find both with the command below, then read each with cat using the path found. You need the one with mode=active.

Sign in and start The machine is available after signing in
Ubuntu 24.04
Loading…