Firstly, to see what ports are opened, use the following command:
The above command will give an output of something like this:
Then, to close a port, simply run the following command:
nmap localhost
or:nmap <my_ip>
and replace "my_ip" with your IP.The above command will give an output of something like this:
Then, to close a port, simply run the following command:
fuser -k <port>/tcp
Obviously, replacing "port" with the port you would like to close. So for instance, if you want to close port 80 (HTTP), you would run the following command:fuser -k 80/tcp