nc -zv 127.0.0.1 80source
sudo ifconfig // I see that the wired interface is named enp0s31f6 sudo ifconfig enp0s31f6 down sudo ifconfig enp0s31f6 up
nmcli radio wifi off nmcli radio wifi on nmcli radio help nmcli radio wifi help
There's lots of ways with subtle differences:
dig +short www.google.com
getent hosts www.google.com
Some notes on the various subtleties involved:
The dig program uses the OS resolver libraries and, as such, should be preferred over nslookup.
The dig program is also not using the local /etc/hosts file whereas the getent hosts incantation and the host program both do. Depending on your use case you may therefore wish to use dig over getent or host (e.g. when you are trying to troubleshoot what an external client might resolve up to).
wget -q -d -S -O - --auth-no-challenge --http-user=USERNAME --http-password=PASSWORD 'https://example.com/some/path?a=1&b=2'Using curl:
curl -v --user USERNAME:PASSWORD 'https://example.com/some/path?a=1&b=2'
As an added bonus, the verbose output on both incantation reveals (among other things):
I was experimenting with a multipart POST failure and so I wrote the following script to directly send a POST request to some socket and read back the response from the same socket:
#!/usr/bin/env bash if [[ ($# -ne 1) ]] then echo "usage is $0
" else FILE=$1 exec 3<>/dev/tcp/some.server.edu/80 && cat $FILE >&3 && cat <&3 fi
E.g. in my case the request that was failing was:
POST /csccli/getProperties?outputFormat=vot HTTP/1.1 Content-Type: multipart/form-data Content-Length: 332 Host: some.server.cfa.harvard.edu Connection: Keep-Alive User-Agent: Apache-HttpClient/4.5.2 (Java/1.7.0_95) Accept-Encoding: gzip,deflate ---~.-~.-~.-~.-~.-~.-~.-~.-~. Content-Disposition: form-data; name="query" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit SELECT COUNT(*) FROM master_source ---~.-~.-~.-~.-~.-~.-~.-~.-~.--
The above POST request was failing because the server couldn't find the query parameter which seemed weird to me (at that time) as the request clearly includes such a parameter. I eventually discovered that the failure was due to the fact that Content-Type header also has to indicate the boundary in case of multipart requests.
$ ls -a /etc/NetworkManager/system-connections/ $ sudo cat WIFI_SSID_Name | grep psk
A switch is not a proper technical term (the IEEE 802.1D standard does not even mention the word "switch"). So a switch is just a marketing name for a multiport bridge. A bridge, in turn, is a layer 2 (data link) device that splits collision domains but not multicast domains. A hub is level 1 device that doesn't split collision domains (and therefore neither does it split broadcast domains) and knows nothing about MAC addresses. A hub only sees bits as it resides at the physical layer and simply repeats them to all its ports. A bridge is more intelligent in that it only floods initially, but over time, learns the MAC addresses of the computers connected to its ports and will eventually forward frames (the name for Layer 2 packets) only to the right ports.
Use getent hosts. E.g. on my machine:
$ tail -1 /etc/hosts 127.0.0.8 foo $ getent hosts foo 127.0.0.8 foo
curl -X POST -k -v -H 'Authorization:Basic Y3hjbG9naW4tZ2VuZXJpYy1jbGllbnQtYXBwLnVzZXJuYW1lOmN4Y2xvZ2luLWdlbmVyaWMtY2xpZW50LWFwcC5wd2Q=' https://cdatest.cfa.harvard.edu/cxclogin-dbdal-rest/jax-rs/userdb/serviceTicket/aauvc4d1dl4g3ovz3ejt0l5h0wv88iiri409bx5/authuser?useMode=normal
nmcli c sudo nmcli c up uuid <paste uuid here>
scpa file through an intermediate host (a.k.a. jump host)
sudo lsof -P -i -nMore recently, I did the following to find the port an emacs daemon listens to:
ps aux | grep -i emacs | grep -v grep… and then (after having discovered the port number from the previous command):
$ lsof -Pan -p 32605 -i COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME emacs 32605 mperdikeas 5u IPv4 5351989 0t0 TCP 127.0.0.1:58545 (LISTEN)
Yet more recently, I used the netstat program which has the option -l for listening sockets and can further narrow them down by type:
For example, to find the process ids of all Emacs daemons listening on UNIX sockets I did a:
netstat -lxp | grep -i emacs
The ss tool can also provide the same information as the last incantation with:
ss -lpx | grep -i emacs
When recursively copying with scp, symlinks are copied rather than being preserved, and so rsync has to be used instead.
The following incantation has worked for me:
rsync -avz -e ssh esac-rawdar/ firstname.lastname@example.org:/home/user/ESA/RAWDAR… and recursively copied folder "esac-rawdar" to the remote machine while preserving symlinks.
CAVEAT:when the directories to copy over the network include cryptographic
file containers like TrueCrypt it may be the case that the container (for privacy reasons) does not update
the modification timestamp (this is configurable in TrueCrypt) and since the total size of the container
also doesn't change, then the heuristic algorithm that scp uses may fail to copy the file.
In those cases the --ignore-times (or -I) or --checksum flags are necessary. See this SO answer and my comment to it.
nmcli nm wifi off nmcli nm wifi on
nmcli r wifi off nmcli r wifi on
nc -k -l 4444NB: In my Ubuntu system I've tried the above with the nc from the netcat-openbsd package (not the alternative nc is available in the netcat-traditional package).
curl -I -L www.google.com
ssh -L 2095:localhost:2095 email@example.comYou can then point your browser to the address: localhost:2095 (the above instructions work provided your browser was redirected to port 2095 of the remote host to begin with). This will stabilize the IP address the remote system sees your packets coming from.
ifconfig eth0:1 172.31.129.121and is only visible on the same machine and (?) LAN segment. The above incantation produces an eth1 interface with the indicated address. Local servers can then bind on that interface. You can also ping it from a remote machine and watch the MAC address enter that remote machine's arp cache. However it is not currently possible to assign a MAC address to that virtual interface that's different from the real one.
netstat -g /sbin/ip maddress list ifconfig eth0 | grep MULTICAST
NB:There's no such concept as 'joining a multicast group'. The concept is 'joining a multicast group on a particular interface'.
sudo arp -aThis will show known IP and MAC addresses for the hosts you've send packets to. Surprisingly (but perhaps not so since everything is routed and the arp tables only cache values for the LAN segment, i.e. the 1st hop towards the router), you'll see very few hosts there. This is the output on my machine:
$ sudo arp -a kerio_control.neuropublic.gr (172.31.128.252) at 00:0f:20:32:c5:49 [ether] on eth0 iasonaslb1.neuropublic.gr (172.31.128.247) at 00:0f:20:32:c5:49 [ether] on eth0 iasonas.neuropublic.gr (172.31.128.249) at 00:0c:29:48:58:7c [ether] on eth0 ? (172.31.128.140) at 02:bf:ac:1f:80:8e [ether] on eth0
sudo /etc/init.d/networking restart
sudo iwconfig wlan0 power off
sudo iwconfig(and check for 'Power Management:off' under wlan0 to ensure that the power management is turned off).
sudo rmmod -f iwlagn
sudo modprobe iwlagn 11n_disable=1for the change to stick, edit /etc/modprobe.d/iwlagn-disable11n.conf and add the following line:
options iwlagn 11n_disable=1
echo "#disable ipv6" | sudo tee -a /etc/sysctl.conf echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf echo "net.ipv6.conf.default.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf echo "net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf
sudo apt-get install netcat-traditionalThen spawn the nc.traditional binary in a loop (that's ok since the socket opens and dies with every request according to the stateless character of the HTTP protocol):
while true ; do nc.traditional -l -p 8085 ; doneWith the above command we've opened a manual HTTP server listening at port 8085. One can now point the browser to: localhost:8085/foo and we'll see the request on the nc.traditional output. What's more, we'll be able to paste a response and see it in the browser. Moreover, after the exchange the nc.traditional binary won't die but (due to the while true) be available to service the next request coming from the browser. This allows us to test the cookie setting behaviour and parameters. E.g. (see the Netscape spec and this SO discussion for more) we can use this setting to test the cookie behavior when the cookie path attribute is used:
GET /foo HTTP/1.1 Host: localhost:8085 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0) Gecko/20100101 conkeror/1.0pre (Debian-1.0~~pre+git1206072207-~nightly1) Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip, deflate Connection: keep-alive Cookie: JSESSIONID=891d66f2-29fa-4568-9228-c917c5bf1317
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Powered-By: JSF/2.0 Set-Cookie: JSESSIONID=891d66f2-29fa-4568-9228-c917c5bf1317; Path=/; HttpOnly Content-Type: text/html;charset=UTF-8 Content-Length: 16 Date: Tue, 04 Sep 2012 12:22:46 GMT boo(take care with the Content-Length field)
tar cpf - git-jboss/ | nc 172.31.129.12 8877receiver:
nc -l -p 8877 | tar xpvf -
nc -w 5 18.104.22.168 80
sudo mount -t smbfs -o username=SEMANTIX\\mperdikeas,password=mperdikeas,dir_mode=0777,file_mode=0777,uid=mperdikeas,gid=mperdikeas //192.168.0.2/prj /media/athina-prj
log-in to a console and do:
(to find the link you wish to bring down, usually "eth0")
sudo ifconfig eth0 downdo work that has to be executed offline, and then:
sudo ifconfig eth0 up