14
Chapter 1
When you press
enter
, Linux will go into
interactive mode and wait for
you to start entering content for the file. This can be puzzling because
the prompt disappears, but if you simply begin typing, whatever you enter
will go into the file (in this case,
hackingskills). Here, I entered
Hacking
is the most valuable skill set of the 21st century!
. To exit and return to
the prompt, I press
ctrl
-D. Then, when I want to see what’s in the file
hackingskills, I enter the following:
kali >
cat hackingskills
Hacking is the most valuable skill set of the 21st century!
If you don’t use the redirect symbol, Linux will spit back the contents of
your file.
To add, or
append, more content to a file, you can use the
cat
command
with a double redirect (
>>
), followed by whatever you want to add to the end
of the file. Here’s an example:
kali >
cat >> hackingskills
Everyone should learn hacking
Linux once again goes into interactive mode, waiting for content to
append to the file. When I enter
Everyone should learn hacking
and press
ctrl
-D, I am returned to the prompt. Now, when I display the contents of
that file with
cat
, I can see that the file has been appended with
Everyone
should learn hacking
, as shown here:
kali >
cat hackingskills
Hacking is the most valuable skill set of the 21st century! Everyone should
learn hacking
If I want to
overwrite the file with new information, I can simply use the
cat
command with a single redirect again, as follows:
kali >
cat > hackingskills
Everyone in IT security without hacking skills is in the dark
kali >
cat hackingskills
Everyone in IT security without hacking skills is in the dark
As you can see here, Linux goes into interactive mode, and I enter the
new text and then exit back to the prompt. When I once again use
cat
to see
the content of the file, I see that my previous words have been over written
with the latest text.