Posts

Running scp through ssh tunnel

G - gateway Step 1: Establish SSH tunnel. Pick a temporary port between 1024 and 32768 (1234 in this example). Port 22 will be used by scp. $ ssh -L 1234:<address of R known to G>:22 <user at G>@<address of G> # Adding "cat -" will keep it running while above will get you connected to G $ ssh -L 1234:<address of R known to G>:22 <user at G>@<address of G> cat - Either way you run it, open another terminal for next step. Step 2: Run scp against port 1234 pretending 127.0.0.1 (localhost) is the remote machine R, and the command will be sent to R. $ scp -P 1234 <user at R>@127.0.0.1:/path/to/file file-name-to-be-copied

curl -XPOST -H "Content-Type:application/x-ndjson" --data-binary @data2.json http://127.0.0.1:9200/schools/_bulk

curl -XPOST -H "Content-Type:application/x-ndjson" --data-binary @data2.json http://127.0.0.1:9200/schools/_bulk {"index":{"_index":"schools", "_type":"school", "_id":"1"}} {"name":"Central School", "description":"CBSE Affiliation", "street":"Nagan","city":"paprola", "state":"HP", "zip":"176115", "location":[31.8955385, 76.8380405],"fees":2000, "tags":["Senior Secondary", "beautiful campus"], "rating":"3.5"} {"index":{"_index":"schools", "_type":"school", "_id":"2"}} {"name":"Saint Paul School", "description":"ICSE Afiliation", "street":"Dawarka", "city":"Delhi", &qu

tar cpzfP $DESDIR/$FILENAME $SRCDIR

to avoid "tar: Removing leading `/' from member names" try this: tar cpzfP $DESDIR / $FILENAME $SRCDIR

Moreutils sponge, parallel https://packages.debian.org/sid/moreutils

https://packages.debian.org/sid/moreutils jq '.version = "'$(git describe --abbrev=0)'"' package.json | sponge package.json

How to generate a bash script with an embeeded tar.gz (self-extract)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 > cat extract.sh #!/bin/bash echo "Extracting file into `pwd`" # searches for the line number where finish the script and start the tar.gz SKIP=` awk '/^__TARFILE_FOLLOWS__/ { print NR + 1; exit 0; }' $0` #remember our file name THIS=` pwd `/$0 # take the tarfile and pipe it into tar tail -n +$SKIP $THIS | tar -xz # Any script here will happen after the tar file extract. echo "Finished" exit 0 # NOTE: Don't place any newline characters after the last line below. __TARFILE_FOLLOWS__ 3) Concatenate The script and the tar file together. 1 2 > cat extract.sh example. tar .gz > example.sh > chmod +x example.sh 4) Now test in another directory. 1 2 3 > cp example.sh /tmp > cd /tmp > . /example .sh

namei -om $PWD - follow a pathname until a terminal point is found

laptop:/tmp/t1/t2/t3/t4$ namei -om $PWD f: /tmp/t1/t2/t3/t4  drwxr-xr-x root  root     /  drwxrwxrwt root  root     tmp  drwxr-xr-x teevi www-data t1  drwxrwxr-- teevi www-data t2  drwxr-xr-x teevi www-data t3  drwxr-xr-- teevi www-data t4

PS1 prod test example with color

PS1='\[\e[1;31m\][test]\[\e[1;32m\][\u@\h \W]\$\[\e[0m\] ' PS1='\[\e[1;35m\][test]\[\e[1;32m\][\u@\h \[\e[1;34m\]\W]\$\[\e[0m\] '