Save combined results with nmap -O -sV -oN os_service.txt 127.0.0.1
In this step, we will save the results of our Nmap scan to a file. This is useful for later analysis or for sharing the results with others.
The options used in this step are:
-O
: Enables operating system detection.
-sV
: Enables service version detection.
-oN os_service.txt
: Specifies the output file and format. -oN
specifies normal output, which is human-readable. The output will be saved to the file os_service.txt
in your current directory (~/project
).
127.0.0.1
: This is the loopback address, which refers to your own machine.
Saving the output to a file allows you to review the results later without having to rerun the scan. It also makes it easier to compare the results of different scans.
Now, let's execute the scan and save the results. Open your Xfce terminal.
- Execute the following command:
sudo nmap -O -sV -oN os_service.txt 127.0.0.1
You will likely be prompted for your password. Since the labex
user has sudo
privileges without a password, just press Enter
.
The output will be displayed on the screen as usual, but it will also be saved to the file os_service.txt
in your ~/project
directory.
- To verify that the file was created and contains the scan results, use the
cat
command:
cat os_service.txt
This will display the contents of the os_service.txt
file in the terminal. You should see the Nmap scan results, including the open ports, services, and operating system information.
Example output (the actual output will vary depending on your system configuration):
## Nmap 7.80 scan initiated Mon Aug 8 14:42:30 2022
Nmap scan report for localhost (127.0.0.1)
Host is up (0.000047s latency).
Not shown: 998 closed ports
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.4 (protocol 2.0)
80/tcp open http Apache httpd 2.4.41 ((Ubuntu))
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
OS details: Linux 3.2 - 4.9
Network Distance: 0 hops
## Nmap done: 1 IP address (1 host up) scanned in 5.23 seconds
You can also use the ls -l
command to check the file size and modification date:
ls -l os_service.txt
This will show you the file's permissions, size, and last modification time.