Skip to content

Instantly share code, notes, and snippets.

@headquarters
Last active May 25, 2025 18:39
Show Gist options
  • Select an option

  • Save headquarters/428b7cfa93a9588f4ac10681a465178b to your computer and use it in GitHub Desktop.

Select an option

Save headquarters/428b7cfa93a9588f4ac10681a465178b to your computer and use it in GitHub Desktop.
Linux/macOS Commands and Tips
# Find things listening on ports on Mac
lsof -n -i4TCP:$PORT | grep LISTEN
# Find a process PID
ps ax | grep ruby
# ...and kill it
kill -9 <PID>
# Alternatively, kill all of them with a name
pkill node
# Flush DNS
# Yosemite:
sudo discoveryutil udnsflushcaches
# Windows:
ipconfig /flushdns
# Ubuntu:
sudo /etc/init.d/nscd restart
# OR
sudo /etc/init.d/named restart
# Extract, configure, and make:
gzip -d < filename.tar.gz | tar -xpvf -
cd filename
./configure && make
make check
make install
# Symlink a file
ln -s /path/to/file /path/to/symlink
# Symlink a directory
ln -sF /path/to/dir/ /path/to/symlink
# Add vboxsf as supplementary group for apache
sudo usermod -a -G groupName userName
sudo usermod -a -G vboxsf xubuntu
sudo usermod -a -G vboxsf www-data
env EDITOR=nano crontab -e
min hour day_of_month month day_of_week /absolute/path/to/script
# Make read only system read-write in single user mode
/sbin/mount -uw /
# Make a global .gitignore file
nano ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_global
# Add an Environment Variable:
echo "export name=value" >> ~/.bash_profile
source ~/.bash_profile
# Add to path:
echo "export PATH=/new/path:$PATH" >> ~/.bash_profile
source ~/.bash_profile
# Reset PRAM: Command-Option-P-R before chime
# Reset SMC: Left Shift-Option-Ctrl-Power Button while off and plugged in
# Ubuntu VM (Vagrant)
# Add `cd /vagrant` to user's ~/.bashrc file to automatically go to that folder when the user logs in via SSH.
# Fix SSH timeouts when VM boots (Vagrant)
sudo cp /etc/network/interfaces /etc/network/interfaces.backup
sudo nano /etc/network/interfaces
# >>> Delete any extra eth# ports that you don't use
# >>> Save
# >>> Exit
vagrant reload
# Verify apache config is correct
apachectl configtest
# Windows Symbolic Link (hard)
mklink /J C:\Program\ Files\ (x86)\Steam\SteamApps E:\Games\SteamApps
# Multiple password-less SSH keys:
# http://stackoverflow.com/a/11251797/360509
# Get IP address on macOS and copy to clipboard (en0=ethernet, en1=wireless)
ipconfig getifaddr en0 | pbcopy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment