Skip to content

Instantly share code, notes, and snippets.

@InsulaVentus
Last active January 31, 2019 11:30
Show Gist options
  • Save InsulaVentus/c3816395481868ea2e57 to your computer and use it in GitHub Desktop.
Save InsulaVentus/c3816395481868ea2e57 to your computer and use it in GitHub Desktop.

Convert input into args

$ find -name "W*.java" | xargs -r cat

Redirect stdout and stderr to /dev/null and run command in background

$ ./deploy/startstop.sh > /dev/null 2>&1 &

Copy file to server

$ scp file.extention user@server.com:/a/remote/directory

Download file from server

$ scp user@server.com:/a/remote/directory/file.txt /a/local/directory

Rename / move file

$ mv old_name new_name

List all environment variables

$ printenv
#or
$ env

Unzip

$ unzip compressed-file.zip

Empty a file without deleting it

$ > file.log

Print last X lines of a file

$ tail -X file.log

See disc usage with dept X

$ du -h -dX

See free disc space

$ df -h

Tcpdump

$ tcpdump -n -s 0 -i eth0 -w /tmp/file_name.pcap

Find files by regex and delete them

$ find . -type f -regextype sed -regex '.*/dpa-events.[a-z0-9\-]*.[0-9]*.log' -delete

Tunnel trafic from a localhost port

#8989 is the local port, xx.xx.xx.xx:8080 is the remote ip and port
$ ssh -N -C -v -L8989:xx.xx.xx.xx:8080 user@aserver.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment