Skip to content

Instantly share code, notes, and snippets.

@kyriacos
Last active January 4, 2016 14:59
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 kyriacos/8637928 to your computer and use it in GitHub Desktop.
Save kyriacos/8637928 to your computer and use it in GitHub Desktop.
Useful unix commands (practical quick examples)

Find

find files using name in the current directory

find . -name filename.txt

find files ignoring case

find / -type d -name filename

find all rb file with name

find . -type f -name *.rb

find all file with/without 777 permissions

find . -type f -perm 0777 -print

find / -type f ! -perm 777

fnd all executable files

find / -perm /a=x

Find Files with 777 Permissions and Chmod to 644

find / -type f -perm 0777 -print -exec chmod 644 {} \;

find and remove a single file

find . -type f -name "filename.txt" -exec rm -f {} \;

find and remove multiple files

find . -type f -name "*.txt" -exec rm -f {} \;

OR

find . -type f -name "*.mp3" -exec rm -f {} \;

find all empty directories

find /tmp -type d -empty

find all hidden files

find /tmp -type f -name ".*"

Netstat

list all the listening ports of tcp and udp

netstat -a | more

list all tcp/udp port connections

netstat -at

netstat -au

list all listening ports

netstat -l

list all unix listening ports

netstat -lx

display service name with PID

netstat -tp

find listening programs running on a port

netstat -ap | grep http

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment