You transfer a file to a remote computer via scp:
scp my_favourite_file.tar.gz email@example.com:~
But before the transfer is completed the connection is broken.
How can I continue the transfer from the point it broke?
rsync -P -e ssh my_favourite_file.tar.gz firstname.lastname@example.org:~
This section explains how to create a new init script for your debian based distro.
More information can be found here: https://wiki.debian.org/LSBInitScripts
I want to remove the 1st and the 5th columns of a text file of tab separated values. The file is as follows:
HEAD1 HEAD2 HEAD3 HEAD4 HEAD5 HEAD6
1.0 -3 3.4 2 7 9
-100 -30 -1 0 -80 7
70 7 8 0 3 0
71 4.5 2.1 0.6 37 4
I want to change a txt file codification from UTF-8 to ISO_8859
The iconv utility converts the encondig of characters from one codeset to another.
To show all the supported formats write:
I want to add a random prefix to all the files in a directory
for f in *;do
mv "$f" "$RANDOM-$f"
This will replace the file name for the SHA from its name:
for f in *.mp3;
mv "$f" $(echo "$f" | sha1sum | cut -f1 -d' ').mp3
Sometimes you need to have a simple HTTP server. You want to check connectivity from other machine or whatever sinister reason you can have.
We are going to create a simple HTTP server at port 8000.
You can use the netcat command:
nc -l -p 8000 -c 'echo -e "HTTP/1.1 200 OK\n\nHello $(id -un)\nCurrent time $(date)"
Then you can go to a web browser and write load the url at the port 8000
But this works just for one connection, after that connection you must execute again the nc command, so to accept more connections you must add a while loop:
while [ 1 ];do nc -l -p 8000 -c 'echo -e "HTTP/1.1 200 OK\n\nHello $(id -un)\nCurrent time $(date)"'; done
May be you want to display a simple html file (with no images, ajax or any other HTML element that launchs more HTTP requests) like this one:
This is a simple<br/>
webserver running with
Let’s suppose that you have your html saved in a file called index.html, then you can show it in your netcat server as follows:
while [ 1 ];do nc -l -p 8000 -c 'echo -e "HTTP/1.1 200 OK\n";cat index.html'; done
If you are not able to connect to your netcat server may be you have activated iptables, take a look writing as root:
If you want to remove the iptables that can be blocking this requests write the following commands as root:
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
I have an apache webserver connected to internet and I want to know the number of unique visitors that it receives.
I want to differentiate the visitors by its source IP address.