netstat | grep ssh
(mac)
netstat -vanp --tcp | grep 8080
(CentOS)
kill -9 <PID>
git blame foo.js
git blame -L 40,60 foo.js
(lines between)
npm list > /dev/null
list modules, redirect stderr to black hole
npm list --depth=0 --prod
Top level modules only
time node index.js
time a process
rm outfile*.txt
Remove files matching patterns
rm sequence_1_{2000..2999}.txt
Remove files with numbers in a sequence
cat events.json | sed -e 's/}\,/}/g' > eventsNoCommas.json
Substitute pattern using sed
cat events.json | sed -e 's/}\,/}/g' -e 's/foo/bar/' > eventsNoCommas.json
Substitute 2 patterns in same script
csplit --prefix=event eventsNoCommas.json '/{/' '{*}'
Split file into new files with the prefix 'event', using a pattern (first arg = matches the line from which the selection will be matched)
aws ec2 start-instances --instance-ids i-07a8794a416aaef84
aws ec2 describe-instance-status --instance-ids i-07a8794a416aaef84
Command | Desc |
---|---|
^ a | Move to start of line |
^ e | Move to end of line |
^ r | Command back search |
Command | Desc |
---|---|
docker container ls | list running containers |
docker ps | list running containers |
docker container ls -a | list all containers |
docker image ls | list all images |
docker rm <contaner_name/id> | remove a stopped container |
docker rm --force <contaner_name/id> | dorce stop and remove a running container |
Command | Desc |
---|---|
docker build -t <image_name> . | create an image from a Dockerfile in cwd |
Command | Desc |
---|---|
docker run <image_name> | run an image |
docker run [OPTIONS] IMAGE [COMMAND] [ARG...] | Run an image |
docker run -d training/webapp python app.py | Run an image and use python command to run the app |
docker run --name <desired_container_name> <image_name> | run an image and name the container |
docker run -d <image_name> | run an image in detached mode |
docker run -p 4000:80 <image_name> | map your local 4000 port to port 80 |
docker start <container_name> | start a container |
docker stop <container_name/id> | stop a container |
docker exec -it <contaienr_name> | run a command in a started container |
docker exec -it puppet bash | attach tty terminal to a running puppet container |
docker run -it --link some-redis:redis --rm redis redis-cli -h redis -p 6379 |