Tech tips & other words

Tag: terminal

Clear Mac OS DNS cache via command line

The method for clearing or flushing the local cache in Mac OS has changed over the years. Here are all the Mac OS versions on one page that details how to clear Mac OS DNS cache via command line.

Clear your DNS cache on macOS Tahoe 26, macOS Sequoia 15, macOS Sonoma 14, macOS Ventura 13, macOS Monterey 12, macOS Big Sur 11, macOS 10.15 Catalina, macOS 10.14 Mojave, macOS 10.13 High Sierra, macOS 10.12 Sierra, OS X 10.11 El Capitan, OS X 10.10 Yosemite, OS X 10.9 Mavericks, OS X 10.8 Mountain Lion, OS X 10.7 Lion, OS X 10.6 Snow Leopard, and OS X 10.5 Leopard using the following Terminal commands:

Continue reading

Change permissions on all files and/or all directories

I recently needed to change the permissions of all files inside a directory (only files but not folders), including subdirectories. From the command line in Mac OS X, I ran this command with success which changed all files recursively to 666 (rw-rw-rw-):

sudo find . -type f -exec chmod 666 {} \;

Likewise, to change only directories to 777 (rwxrwxrwx), I used:

sudo find . -type d -exec chmod 775 {} \;

 

Add MySQL to terminal shell in Mac OS X

Mac OS X 10.6 snow leopard uses the bash shell by default. If you install MySQL from the disk image (dmg) from http://dev.mysql.com/downloads/, you can make it easy to access the mysql binary from the command line by adding it to your bash path.

Here’s how:

Open terminal, and type:

echo 'export PATH=/usr/local/mysql/bin:$PATH' >> ~/.bash_profile

This adds the default location of the MySQL binary to your shell environment.

Then, you need to force the system to reload your .bash_profile file. Again, from terminal, enter:

. ~/.bash_profile

You can check your environment variables by typing in terminal:

env

Now, to access MySQL from the command line, you only need enter:

mysql