← Linux & the Command Line tutorial

Linux & the Command Line

Viewing & Editing Files

cat file dumps a whole file's contents to the screen, fine for short files, unwieldy for long ones. less file opens a scrollable, searchable viewer for longer files.

Example: choosing the right tool for the file's size

$ cat README.txt
$ less deploy.log
$ nano README.txt

Use cat for something short enough to fit on one screen; switch to less the moment a file is longer than that, it lets you scroll and search (press / then type to search, q to quit) without flooding your terminal with hundreds of lines at once. nano opens a simple in-terminal text editor for quick edits, when a full IDE is overkill or simply unavailable, as is often the case when connected to a remote server.

Example
$ cat README.txt
$ nano README.txt
Output
cat prints the file's full contents immediately; less opens it for scrollable, searchable reading; nano opens it for interactive editing directly in the terminal.
Ready to go further?

These free tutorials are a preview, our Cybersecurity cohort covers it in depth, with a real project and a cohort alongside you. Active

Enroll in Cybersecurity
Don't miss out

Ready to build something real?

Create a free account to enroll in a track, and get notified the moment a cohort opens.

Create free account