Linux Labs

First steps / Stage 3 of 15

Working comfortably in the terminal

Not running Starting usually ~20 s
Leave the lesson

Step 5 of 8 · on a machine · 3 min

Read long text in less

A long file runs off the top of the screen, and its beginning is gone from view. In less you page through such a file and search it for a word.

less is a pager: it shows text one screen at a time. While it is open, it reads the keys:

Key What it does
Space, b one screen forward, one screen back
↑ ↓ one line back, one line forward
g, G to the start, to the end of the text
/word, then Enter search forward
n next match
q quit

All the keys are lowercase letters except G, which you type with Shift. (END) at the bottom means you are at the end of the text — you still quit with q. Viewing does not change the file.

Exercise · look

Find the second match

In ~/terminal-practice, open the log terminal-notes.txt in less: type less term and complete the name with Tab. Search for the lines with TARGET — there are two — and read the value in the second match. Quit less.

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