0

Why when I run sudo cat swapfile I get a bunch of unknown characters. What do these characters mean? Plus my keyboard then types these unknown characters. As a side note this is an active swap file. A little snippet of these characters can be seen as:

����� @�p9�f��SWAPSPACE2
wjandrea
  • 14,109
  • 4
  • 48
  • 98
NerdOfCode
  • 2,408
  • 4
  • 16
  • 33
  • 4
    And what you expect? It is raw data for/from RAM. But if you want more pretty output you may use `sudo hexdump -C swapfile` :) – N0rbert Nov 26 '17 at 16:57
  • Very unhelpful... I was wondering more of what the data meant not what your opinion was... – NerdOfCode Nov 26 '17 at 17:16
  • 3
    @NerdOfCode N0rbert just told you... It's raw memory. Edit: Oh wait, did some comments get deleted? Sorry, that always trips me up. – wjandrea Nov 26 '17 at 18:15
  • 2
    After reading this: https://www.centos.org/docs/5/html/5.2/Deployment_Guide/ch-swapspace.html you will know WHAT swap is and then I think you can answer your own question. –  Nov 26 '17 at 18:55
  • Worth noting that � is a replacement for a character that cannot be rendered, so it doesn't tell us what character is acutally in the swapfile. You could use `hexdump` instead of `cat` to get the actual data. – wjandrea Nov 28 '17 at 20:46

2 Answers2

3

The output of running sudo cat swapfile is

����� @�p9�f��SWAPSPACE2

…at least on your system at that time and with this specific terminal configuration.

Sorry, couldn't resist to give this terrible literal answer to the terrible question. Please restate your question to ask what you actually want to know.

David Foerster
  • 35,754
  • 55
  • 92
  • 145
3

Swapfiles, you already probably know, contain data swapped out from RAM. So whatever data there is, it belongs to some process. What exactly that may be - depends on multiple factors and what process that data belongs to originally.

Swap files and partitions do have certain filesystem in place there, so considering the fact that we see SWAPSPACE2 string, this can either be part of that filesystem header or some process had that string in their memory which was swapped out.

Sergiy Kolodyazhnyy
  • 103,293
  • 19
  • 273
  • 492