This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Find a directory (Linux/MacOS) | |
sudo find / -type d -name 'dirname' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Flush DNS cache on MacOS (Yosemite and later) | |
sudo killall -HUP mDNSResponder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Recursively set directory and file permissions (replace $mydir with a target directory) | |
find $mydir -type d -exec chmod 755 {} \; | |
find $mydir -type f -exec chmod 644 {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# replace 4567 with a target port number of the process | |
# run lsof with sudo if the process was spawned by the root user | |
kill -9 $(lsof -ti tcp:4567) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace all occurrences of a string in any file on MacOS | |
# Substitute "html" with a target file extension | |
# using find (built-in) | |
find . -name '*.html' -print0 | xargs -0 sed -i "" "s/replaceme/withthis/g" | |
# using fd (https://github.com/sharkdp/fd) | |
fd -e html --print0 | xargs -0 sed -i "" "s/replaceme/withthis/g" |