Back to Blog

Linux Commands: more vs less - Which File Pager Should You Use? (Beginner Tutorial)

Sandy LaneSandy Lane

Video: Linux Commands: more vs less - Which File Pager Should You Use? (Beginner Tutorial) by Taught by Celeste AI - AI Coding Coach

Watch full page →

Linux Commands: more vs less - Which File Pager Should You Use?

When working with large text files in Linux, viewing content page by page is essential. The 'more' and 'less' commands both serve this purpose, but 'less' offers significantly more functionality for navigating and searching within files.

Code

# Create a sample file with 50 lines
seq 50 > sample.txt

# View the file with 'more' (forward scrolling only)
more sample.txt
# Press Space to scroll forward, Q to quit

# View the file with 'less' (full navigation)
less sample.txt
# Press Space or J to scroll down
# Press K to scroll up
# Press /text to search for "text"
# Press N to find next search result
# Press g to jump to start, G to jump to end
# Press Q to quit

Key Points

  • 'more' allows only forward scrolling through a file, making it simple but limited.
  • 'less' supports both forward and backward navigation, text searching, and jumping to file positions.
  • Use 'more' for quick, linear viewing and 'less' when you need advanced navigation or search features.
  • Keyboard shortcuts in 'less' include Space/J (down), K (up), / (search), N (next match), g (start), G (end), and Q (quit).
  • Most developers prefer 'less' because it combines efficiency with powerful navigation capabilities.