Transfer files between computers with netcat

You can use netcat (nc) to copy file from one computer/server to another.

On destination computer

Run netcat in listening mode.

Example

On Source computer

This is the computer from where you copying file from. To copy a file, run

Example

Saving iptables firewall rules

To save iptables firewall rules, run

This will print the firewal rule. You can save it to a file. For example

For IPv6, you can use

xinetd

To run xinetd in forground in debug mode, run

Nginx Disable Access log

On a high traffic web site, i want to disable access log as we are hitting I/O Limit. Since we don’t use this access log for anything now, there is no point keep writing it to a file. To disable, you need to add following to server entry for your web site.

Here is an example nginx config with access logs disabled.

Displaying /proc/PID/cmdline with space

On linux, the file /proc/PID/cmdline shows the command line for the process. If you check content of this file, you will see the command, but arguments are not seperated by space.

To display the command line with space, run

Or

Example

apt-key keyserver receive failed: No dirmngr

When running apt-key command, i get following error.

To fix this, run

apt install dirmngr

Find MongoDB version

To find MongoDB version, login to MongoDB server using command

Now run

MongoDB delete Database

To delete a database in MongoDB, run

Restore MongoDB database

To restore MongoDB database, run