0/1 Lessons

Introduction to Linux Server Operating Systems

• 30min

0 / 3 lessons complete

Linux Server Installation and Lab Setup

• 23min

0 / 6 lessons complete

Working with the Linux Command Line Interface

• 1hr 30min

0 / 12 lessons complete

User and Group Management

• 44min

0 / 7 lessons complete

Linux Storage

• 30min

0 / 6 lessons complete

Linux Administration Basics

• 53min

0 / 8 lessons complete

Linux Networking

• 47min

0 / 8 lessons complete

Course Conclusion

• 5min

0 / 1 lessons complete

Viewing Files


Q&A (0)

Notes (0)

Resources (0)

Saving Progress...


There are no resources for this lesson.

Notes can be saved and accessed anywhere in the course. They also double as bookmarks so you can quickly review important lesson material.

Create note

Reading File Contents

cat (Concatenate and Display)

The cat command is used to display the contents of a file. It can be used to view the entire content of a file at once.

cat filename.txt

more and less (Pager Commands)

more and less are pager commands that allow you to view large files one screen at a time. They provide navigation options for reading through files.

more filename.txt
less filename.txt

head and tail (View Start/End of Files)

head and tail are used to view the beginning and end of files, respectively. They are often used to display a portion of a file.

head -n 10 filename.txt  # Display the first 10 lines
tail -n 20 filename.txt  # Display the last 20 lines

Adding the -f option will cause the tail command continuously displays the latest content of a file in real-time. It's particularly useful for monitoring log files as they receive new entries.

tail -f /var/log/syslog

Press Ctrl + C to exit the command.

grep (Search Text in Files)

The grep command is used to search for specific text patterns in files. It is a powerful tool for text-based searching.

grep "pattern" filename.txt

Below is an example of searching the syslog file in /var/log for all events that happened at 14:17:

grep "14:17:" /var/log/syslog

In this lesson, you learned how to manipulate files on a Linux/Unix system, covering essential commands for creating, reading, and modifying files. We covered a lot of commands so this is a short recap of what we covered:

  1. cat: Display file contents.
  2. more and less: View large files with navigation.
  3. head and tail: View the start and end of files.
  4. grep: Search for patterns in a file or output

Great job getting through this lecture..I'll see you in the next one!

Server Academy Members Only

Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.

0 0 votes
Lesson Rating
Notify of
profile avatar
Inline Feedbacks
View all comments