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:
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:
cat > file.txt
- type in your content
- leave a newline at end of file
- 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:
cat < /dev/null > /dev/tcp/8.8.8.8/53; echo $?
