Giter VIP home page Giter VIP logo

useful-linux-commands's Introduction

useful-linux-commands

For running some of these commands, relevant package may need to be installed. It is recommended to run man <command> if details needed.

Check firewalls

nmap <ip_address>
nmap -Pn <ip_address> # if ping is not allowed

Check sha256 checksum

ref: https://security.stackexchange.com/a/189004/199040

sha256sum <filename>

Check MD5 checksum

md5sum <filename>

Empty a file

: > <filename>
or 
true > <filename>
or
echo > <filename>

Shred a file

shred -vzu secrets.json

List storage space usage

du -sh <directory>
du -sh projects/*

See disk usage on linux and docker

lsblk
df -h
docker system df -v
docker ps -s

See available labels on nodes of docker swarm

ref: https://stackoverflow.com/a/42419060/2137210

docker node ls -q | xargs docker node inspect \
  -f '{{ .ID }} [{{ .Description.Hostname }}]: {{ range $k, $v := .Spec.Labels }}{{ $k }}={{ $v }} {{end}}'

Copy remote/local files with rsync

rsync -vazh <SRC> <DEST>

rsync -vazh [email protected]:/home/gitlab-runner/mongodb/ /home/worker/mongodb

Copy a folder remote/local using scp

Copy all from Local Location/Remote Location scp -r /path/from/destination user@hostname:/path/to/destination

Copy all from Remote Location/Local Location scp -r user@hostname:/path/from/destination /path/to/destination

Recover a "corrupt history file" in zsh

ref: https://superuser.com/a/957924

mv ~/.zsh_history ~/.zsh_history_bad
strings ~/.zsh_history_bad > ~/.zsh_history
fc -R ~/.zsh_history
rm ~/.zsh_history_bad

Get all of the docker container's IP addresses

docker inspect -f '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker ps -aq)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.