# cat

One of the handy Linux utilities I use regularly in my work as a DevOps engineer is cat. I often use it in Linux containers, where a text editor is not always available.

cat is one of those Linux commands almost everybody knows for viewing a text file:

```bash
cat file.txt
```

But it is more than just a file viewer.

In containers, where an editor is often missing, `cat > file` is a quick way to create or update a file:

```bash
cat > file.txt
```

1. type in your content
2. leave a newline at end of file
3. finish with Ctrl+D (or Ctrl+C if you really want to stop it)

And for connectivity troubleshooting it can be handy too, to check whether a port is open:

```bash
cat < /dev/null > /dev/tcp/8.8.8.8/53; echo $?
```

![Cat using the cat command, illustration](https://images.koorevaar.com/linkedin-import/linux-cat-command-tricks.jpg)

---

*Co-authored with Claude.*

If this was useful, [you can buy me a coffee](https://ko-fi.com/p47k0).

New articles: [follow via RSS](https://blog.koorevaar.com/feed.xml).
