Skip to main content
Engineering LibreTexts

05-C.6: Working with Files and Directories - cat Command

  • Page ID
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    2.3 Given a scenario, create, modify, and redirect files.
    3.1 Given a scenario, apply or acquire the appropriate user and/or group permissions and ownership.

    Linux File and Directory Commands

    It is easy to get overwhelmed by the sheer number of Linux commands. Depending on which list you look at you will find anywhere from about 125 to over 600 (the 600 number includes a lot of commands from various distributions).

    This portion will cover some of the commands that will be useful for managing files and directories.

    The cat Command

    The cat (short for concatenate) command is a fairly simple tool designed to concatenate and write file(s) to your screen, which is known as standard output (stdout). The simplest use of cat is to show the contents of a file. One of the most common ways to use the cat command is for viewing configuration files, such as those in the /etc directory. The cat command will display a file without risking damage to it. Opening a critical configuration file using an editor such as Vi or Nano could inadvertently make unwanted changes to the file. The cat command is not an editor and therefore poses no risk of making changes to a file's content.


    cat [filename]

    Command Options:

    Option Option Meaning
    -A Equivalent to -vET.
    -b Number nonempty output lines.
    -e Equivalent to -vE.
    -E Display $ at end of each line.
    -n Number all output lines.
    -s Suppress repeated empty output lines.
    -t Equivalent to -vT.
    -T Display TAB characters as ^I.
    pbmac@ubuntu $ cat temp
    Not like the brazen giant of Greek fame,
    With conquering limbs astride from land to land;
    Here at our sea-washed, sunset gates shall stand
    A mighty woman with a torch, whose flame
    pbmac@ubuntu $

     In the example the cat command is used to display the contents of the file temp.

    05-C.6: Working with Files and Directories - cat Command is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by LibreTexts.