Skip to content

Instantly share code, notes, and snippets.

@balamaci
balamaci / SCP_examples
Created November 10, 2012 16:27
SCP examples
Copy the file "foobar.txt" from a remote host to the local host:
$ scp your_username@remotehost.edu:foobar.txt /some/local/directory
Copy the file "foobar.txt" from the local host to a remote host:
$ scp foobar.txt your_username@remotehost.edu:/some/remote/directory
Copy the directory "foo" from the local host to a remote host's directory "bar":
$ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar
Copy the file "foobar.txt" from the local host to a remote host using port 2264:
@balamaci
balamaci / SSH tunnel
Last active January 2, 2016 09:08
SSH tunnel for mysql
ssh -p 3333 -L local_port:remote_host:remote_port user@machine
- after a connection to 'machine' is established, all tunneled connections will be directed to the 'remote_host'.
1. ssh -p 3333 -L 3307:localhost:3306 sbalamaci@machine1.ocean.digital
2. ssh -p 3333 -L 3307:82.67.89.3:3306 sbalamaci@machine1.ocean.digital
it matters to which mysql interface the bind is done.
careful with testing the setup with mysql client connecting to 'localhost' as it will bypass network and connect through a socket file. So even if you messed the setup it will connect to a local mysql instance if available.
to be ran on server for desktop publishing.
x11vnc -safer -localhost -nopw -noxdamage -ncache 10 -once -display :0
du -hc --max-depth=1
@balamaci
balamaci / gist:9452786
Last active December 19, 2015 17:42
raspberry
Writting an image to an sdcard:
sudo dd bs=4M if=2014-01-07-wheezy-raspbian.img of=/dev/mmcblk0
Backing up an sdcard
sudo dd if=/dev/mmcblk0 bs=1M | gzip -c > raspbian-2015-12-19.img.gz
@balamaci
balamaci / gist:fe8de7b5db1b52c70c20
Created November 5, 2014 20:32
SSH execute on remote machine
ssh flyby@inita 'bash -s' << 'DELIMITAT'
cd /home/flyby/airprice
/home/flyby/airprice/flyby-agent/command.sh stop
/home/flyby/airprice/flyby/command.sh stop
/home/flyby/airprice/build.sh
/home/flyby/airprice/flyby/command.sh start
/home/flyby/airprice/flyby-agent/command.sh start
DELIMITAT
@balamaci
balamaci / New server
Last active August 29, 2015 14:10
Setup New server
#
useradd -m -d /home/sbalamaci -s /bin/bash sbalamaci
#add to users
sudo usermod -a -G sudo sbalamaci
#generate ssh keys
ssh-keygen -t rsa -C "your_email@example.com"
#java8
@balamaci
balamaci / gist:42e649ac8e787f9b64dd
Created January 2, 2015 17:24
start script outputing pid
#!/bin/bash
MYDIR=$(dirname $0)
STATFILE=$MYDIR/command.pid
COMMAND_MARK="myprocess.jar"
MEMORY_OPTIONS="-Xms32m -Xmx256m"
MISC_OPTIONS="-Djava.awt.headless=true"
LOG_FILE=console.log
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime 0 1
# a swapfile is not a swap partition, so no using swapon|off from here on, use dphys-swapfile swap[on|off] for that
none /var/run tmpfs size=1M,noatime,mode=0755 0 0
none /var/log tmpfs size=1M,noatime,mode=0755 0 0
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
/dev/sda1 /mnt/storage ext4 defaults,nofail 0 2
#show all programs listening TCP ports
lsof -Pan -i tcp
avconv -rtsp_transport tcp -i rtsp://localhost:5554/Streaming/channels/101 -c copy -map 0 -f segment -segment_time 120 "./security/capture2-%03d.mkv"