Ubuntu – Searching for specific magic byte in an ocean of files

command linefiles

I want to know how I can search for a specific file type: I have entered a SSH server and I am trying to search for a .jpg file, but the owner of the server (my teacher) has removed all extensions.

I have tried grep -lr "JFIF" and I have found many directories with the same file name, so I jumped into a random directory which was found with the grep command and I tried to use the cat command on it, but the terminal couldn't show the entire binary.

Also the strings command is blocked on the ssh server, my teacher said that you have to find a jpg file and that this file contains a serial number (SN), but I have no idea where to find it.

If you guys want the SSH cardinals I will be happy to give them out to you, anyway my teacher said that you can use the file command to do that but I don't know how to do it.

BTW : he said (SN)

Best Answer

I'll try to give you some hints so you can solve your HW yourself.

Follow this steps:

  1. read the manual of file by executing man file.
  2. Then try it out by file somefile and see what happens
  3. Try to run file on different file types
  4. By now you should be able to understand how to find out if some file is a jpeg image or not.
  5. now read the manual for find (or use google to find out how to use it to find all files in some directory and all subdirectories)
  6. now find out how to use -exec option of find in order to connect it with previously used file command
  7. Now you should be able to find out the filetypes of all files in needed directory and list them
  8. Now read about pipes | and grep command to find out how to filter only for JPEG files.
Related Question