Skip to content

Instantly share code, notes, and snippets.

@scallacs
Last active April 22, 2018 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scallacs/daec75c65f87632913bbc0bd05d63e0d to your computer and use it in GitHub Desktop.
Save scallacs/daec75c65f87632913bbc0bd05d63e0d to your computer and use it in GitHub Desktop.
Bash cheatsheet

File editing

print only a specific line number

sed -n 5p file

To delete

sed -n 5d file

Search

  • Find word 'mydata' inside multiple files recursively grep 'mydata' myfolder -R

  • Find filename

find -name "query"

View all open ports

sudo lsof -i
sudo netstat -lptu
sudo netstat -tulpn

Flush dns cache

sudo /etc/init.d/nscd restart
service nscd restart
service nscd reload

Disk space

df -h /dev/sdc1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment