krypted.com

Tiny Deathstars of Foulness

You can query whether a process is running by name. You can do this with ps and pipe the output to grep. It’s not hard, but you can do this more quickly with pgrep. You can also kill that process with pkill. Which includes the ability to send a signal.

So, let’s look at closing down iTunes with pkill:

pkill iTunes

Or we can send it with a signal (9):

pkill -9 iTunes

Or you could just grab the pid of a process by name:

pgrep Safari

It might display:

797

And that’s it. Easy Peasy.

August 2nd, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Mass Deployment

Tags: , , , ,

Leave a Comment

Safari has a bookmarks bar. Some people want to hide it. A lot of people used to do stuff like this by modifying the default user template in OS X. Not something we’ll be doing much in the future. So to do so with a script:

defaults write com.apple.Safari ShowFavoritesBar -bool false

To turn it back on:

defaults write com.apple.Safari ShowFavoritesBar -bool true

July 31st, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Mass Deployment

Tags: , , , , ,

Leave a Comment

You can easily accept user provided input in bash by using the read command in bash for Linux and OS X. Here, we’ll echo out a choice to a user in a script, read the output into a variable called yn and then echo out the response:

echo "Please enter y or n: "
read yn
echo "You chose wrong: $yn"

Here, we used echo to simply write out what was chosen in the input. But we could also take this a little further and leverage a case statement to then run an action based on the choice selected:

read -p "Should the file extension change warning be disabled (y/n)? " yn
case ${yn:0:1} in
y|Y )
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
echo "The warning has been disabled"
;;
* )
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool true
echo "The warning has been enabled"
;;
esac

The options when scripting are pretty much infinite and chances are, if you’ve written any scripts, you’ll know of a better way to do this than how I’ve always done it. One of the great things about scripting is the fact that there’s always a better way. So feel free to throw any of your examples into the comments!

July 28th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Ubuntu, Unix

Tags: , , , , , , , ,

Leave a Comment

I mess computers up a lot. And that means I have to reload operating systems a lot. I’ve also been having terrible issues caused by autocorrect. So… Let’s disable it. By sending the NSAutomaticSpellingCorrectionEnabled key as a false boolean into NSGlobalDomain:

defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool false

July 27th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security

Tags: , , , , ,

Leave a Comment

Sometimes when I’m writing a script, I need something to phone home to something in the script. For example, this can tell another daemon where to ssh into when I invoke it remotely. So, let’s say I want to grab my WAN address in a script. I can use curl with a number of 3rd party sites (sites that often change. But, one that we can use here is ipecho.net. Here, we’ll look at their plain output page here:

curl ipecho.net/plain

This can then get output into a variable or file for processing in other parts of a script. For example, the output here is basically the same thing but the command is in backticks, as you might put it in when scripting:

echo `curl ipecho.net/plain`

July 26th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Ubuntu, Unix

Tags: , ,

Leave a Comment

The caffeinate command is pretty cool. It keeps your computer from going to sleep. It can run in a couple of different ways. There’s a timer that prevents sleep for a little while. You can also run another command from within caffeinate that keeps the system awake until the other command is finished. Here, we’ll scp a file called source file to a host called servername and keep the system from going to sleep until the process is finished:

caffeinate -s scp sourcefile me:servername/targetfile

Here, we’ll just use the boring command to tell the computer not to go to sleep for an hour:

caffeinate -t 3600 &

July 24th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security

Tags: , , , , ,

Leave a Comment

July 24th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, personal

Leave a Comment

By default in OS X, when you change an extension for a file, you get a warning. This is somewhat annoying to me, as I do this pretty frequently and have never almost accidentally done so. So to disable, send a FXEnable ExtensionChangeWarning key into com.apple.finder as false:

defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false

To then undo, simply run with a true key:

defaults write com.apple.finder FXEnableExtensionChangeWarning -bool true

July 22nd, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security

Tags: , , , ,

One Comment

As of OS X 10.9 (and in many cases more importantly in OS X Server for 10.9 and higher), OS X now performs ARP cache validation when trying to pass traffic over a router. If you are double NAT’d/use redundant gateways then the traffic can be interpreted as network redirection and cause some pretty bad packet loss/latency. You can disable this feature by turning off net.link.ether.net.arp_unicast_lim using sysctl:

sysctl -w net.link.ether.inet.arp_unicast_lim=0

That will only disable unicast arp validation until the next reboot. If it fixes a latency problem you’re having then you can go ahead and make it permanent by adding the following line into /etc/sysctl.conf:

net.link.ether.inet.arp_unicast_lim=0

If you’re still having issues with latency, you should turn it back on. To enable it again, repeat, swapping the 0 with a 1.

July 19th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Mass Deployment

Tags: , , , , , , ,

Leave a Comment

So a few months ago, closing in on 3,000 posts, the database got too big and krypted.com started suffering from innodb corruption, resulting in database outages. While I was able to get the site up, it was using a read-only database that kept me from doing any new articles or updates. It was a strange time in my life, like suddenly being single after living with someone since Y2K (when I started the site). But I got through it and was able to repair the relation… er, site. Now, with a new database that is free from corruption we’re ready to get to 6,000 posts!

Also, I had a little feedback on the usability of the site. I had thought people would scroll down to find the search box. Apparently there’s a reason most sites put it at the top. It’s now there here. I also made a couple of new pages (in addition to the articles I’ve been posting since it came back up) and removed a couple of pages. Most of the pages have gotten fresh information and had at least something retired. No changes to articles in all of this, just pages.

Finally, I know I’ve made this offer in the past, but I welcome any guest authors that would love a place to store their stuff. Talk about anything technical you’d like, from Arduino to BRU to Casper to Munki to OpenMDM to Linux to PowerShell. It should just be technical…

July 17th, 2015

Posted In: Mac OS X, Mac OS X Server, Mac Security, Mass Deployment

Tags:

One Comment

Next Page »