Terminal commands cheatsheet
List of handful terminal commands: npm, terminal, and git commands.
NPM commands
Check website performance
npx unlighthouse --site https://
pnpm dlx unlighthouse --site https://Check node.js vulnerability
npx is-my-node-vulnerableView latest version of a packcage
npm view [package-name@version] version View peerDepedencies of a npm package
npm info [package-name@version] peerDependenciesCheck outdated npm packages
npm outdatedDelete all node_modules in your system
npx npkillCheck for npm compromises (audit)
npx npq installPython commands
Python environment manager.
Install Python version
pyenv install 3.12.2List Python versions
pyenv versionsSet global default.
pyenv global 3.12.2Terminal commands
Send ouptut to a new file
command | head -n 10 > output.txt
Append to an existing file
command | head -n 10 >> output.txtDelete recursively a specific file/folder in every folder under a directory
find ~/pr -type d -name "node_modules" -prune -exec rm -rf '{}' +Find heavy files
find ./public -type f -exec du -h {} + | sort -rh | head -n 100Generate a 32 length secret key. For db passwords or env variables passwords.
openssl rand -base64 32
# or
npx auth secretRS256 secret
ssh-keygen -t rsaGet Wifi password
security find-generic-password -wa "The Wifi Name"
security find-generic-password -wa "The Wifi Name" | pb copy # copy to clipboardDelete history of downlaods store in the macos sql (even clean history in Chrome)
sqlite3 ~/Library/Preferences/com.apple.LaunchServices.QuarantineEventsV* 'delete from LSQuarantineEvent'Get your IP address
ifconfig ne0 | grep inetOpen a server that can be accessed from any device
- To access go to the url: http://[this-device-ip]:8000
python3 -m http.server 8000 --bind 0.0.0.0 Git commands
Rename locally old_branch branch to main branch
git branch -m old_branch mainReflect changes on remote
git push --force origin mainLink local main branch with remoteorigin/main for push/pull (no need check out branch).
# git branch -u [remote] [local]
git branch -u origin/main mainDelete remote branch
git push origin --delete branch-nameDelete local branch
git branch -d my-branchMiscellaneous
Navigation
ls -la # List files and directories
pwd # Current directory path
cd # Change directory
tree # Print folder structure as treeFiles and Directories
touch # Create empty file
mkdir # Create new directory
cp # Copy files or directories
mv # Move or rename files
rm # Remove files
rmdir # Remove directoriesRead Files
cat # Show file content
less # Visualize file page by page
head # Show file first lines
tail # Show file last linesFile Permissions
chmod # Change file permissions
chown # Change file owner
sudo # Execute commands as adminFind Files
find # Find files in directories
grep # Find text in filesNetwork Utils
ping # Testing connection
curl # HTTP request
wget # Download files from a URL (have to be installed in macos)System Process
top # Show processes
ps # List active processes
kill # Kill a process
df -h # Show available space in disk
du -sh # Show file and directories size
uptime # Show the system time since powered on
clear # Clear the terminalUtils
echo # Print text in the terminal
history # Show command history
man # Show command manual
nano # Basic Text Editor
vim # Advanced Text Editor