Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Mar 2, 2011

Clients and Servers on the Terminal: Simple File Transfers

I just stumbled across an interesting shell command: nc

It's used for simple client/server interactions from the shell. With it, you can do interesting things like take output from one machine, send it over the network to another machine that pipes this input into other commands. Here's an example:
# On the destination machine
nc -l -p 2345 | tar xv
# On the source machine
tar c PATH_TO_FILES > /dev/tcp/IP.OF.DESTINATION/2345
Which will tar PATH_TO_FILES, on the source machine and transmit it over the network on port 2345. The destination will receive the data and pipe it into a command that will extract the tar.

This is so useful, I had to jot it down!

Jul 15, 2010

Linux Equivalent of ipconfig renew and ipconfig release on Windows

I've looked this up 3 times so I finally decided to jot it down so I don't forget it.

Problem

Can't remember the Linux commands equivalent to:
ipconfig renew
ipconfig release

Symptoms

  • Your IP is assigned via DHCP on a Linux box
  • You've unplugged from one network and plugged into another and the old IP address hasn't cleared out
  • Don't want to shutdown/restart the interface you just want to refresh the DHCP settings

Solution

sudo /sbin/dhclient -r is equivalent to ipconfig release
sudo /sbin/dhclient is equivalent to ipconfig renew
sudo /sbin/ifconfig is equivalent to ipconfig
The dhclient command broadcasts a DHCP message to your DHCP server, resulting in a new lease. A slower way to achieve the same result is to shutdown the interface and bring it back up via (assuming your target interface is eth0):
sudo /sbin/ifdown eth0
sudo /sbin/ifup eth0
This same, slower approach can also be done graphically on RedHat by clicking System > Administration > Network, choosing your interface (eth0) and clicking deactivate followed by activate.