• Active Directory,  cloud,  Consulting,  iPhone,  Kerio,  Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment,  Microsoft Exchange Server,  Network Infrastructure,  Windows Server

    Dig TTL While Preparing For A Migration

    Any time doing a migration of data from one IP to another where that data has a DNS record that points users towards the data, we need to keep the amount of time it takes to repoint the record to a minimum. To see the TTL of a given record, let’s run dig using +trace, +nocmd to turn off showing the version and query options, +noall to turn off display flags, +answer to still show the answer section of my reponse and most importantly for these purposes +ttlid to toggle showing the TTL on. Here, we’ll use these to lookup the TTL for the https://krypted.com/ A record: dig +trace +nocmd…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Xsan

    Disable Swap Files In OS X

    Every now and then I need to reclaim that space in /var/vm or I need to stop a process from paging to swap files while I’m troubleshooting something else. I in no way endorse disabling swap files (which basically kills using swap files as a part of your overall virtual memory) for extended periods of time. However, it has saved me in the case of stability concerns long enough to get a system patched or something like that. To disable OS X swap files, all you need to do is stop the com.apple.dynamic_pager daemon and restart. Use launchctl to stop: sudo launchctl unload -wF /System/Library/LaunchDaemons/com.apple.dynamic_pager.plist Once restarted, you may need…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu,  Unix,  VMware

    Show Line Numbers When Viewing A File

    The nl command is used to show line numbers when viewing a file (unless you use the -b option along with an n, which seems to be one of the more pointless things to ever do at the command line, but then what do I know…). So if you’d like to see the line numbers for a file called xsbackup.sh: nl xsbackup.sh The output would look like this: 1 # 2 #!/bin/bash 3 # 4 # Script Name: Or at least, that’s how I used to do it. For decades I never noticed that cat had a -b option. So if you’d like to use cat to see line numbers…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Network Infrastructure,  Network Printing,  Ubuntu,  Unix,  VMware

    Use Netstat To Locate What Process Is Using A Port

    You’re installing software on some host. The installation goes well and then you go to access the information you need or connect to the service from another host. Wait, what’s that? Port is already in use? Crap. We’ve all been there. The quick and dirty answer: netstat. Let’s say you’re trying to use port 8080: netstat -tuln | grep 8080 Let’s say the response is httpd. OK, let’s see where that’s located using whereis: whereis httpd And what kind of file is httpd: file /usr/sbin/httpd Which responds with: /usr/sbin/httpd: Mach-O 64-bit executable x86_64 I guess we knew that since it had a port open, but what type of executable is…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment,  Ubuntu,  Unix,  Xsan

    compgen like a boss

    I’ve traditionally used the apropos command to find new commands. But you can also use the compgen command, which looks at the completion matches for given words, to find a list of commands that you can run, simply use compgen with a -c option: compgen -c You can parse information for a single command: compgen -c | grep apropos You can also use -a for aliases, -b for bash built-ins and -k for bash keys, as well as `-A function` for functions. You can then string ’em together: compgen -abckA function I won’t paste the output but I’ll let you pipe it to grep to compgen like a boss. Enjoy!

  • Mac Security

    Was My Snapchat Leaked

    snapchatdb.info, a site run by security researchers has leaked a large number of accounts from Snapchat. Mine is one. Luckily I don’t mind if people know my Snapchat username. Nor do I mind if my number, along with a few million others, is sold to some dastardly scamp who’s gonna’ what, call me and try to sell me crap (that happens anyway, including on my mobile)? Having said that, a lot of people are worried about their privacy. Especially if they’re using a tool like Snapchat to send pictures their wives or husbands might not appreciate them sending (I’m thinking Bobby Petrino here) or something more nefarious. So for those…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Ubuntu,  Unix

    Working With Files Whose Name Starts with a “-“

    Recently I needed to create a bunch of files that had names starting with a dash. If you simply run touch followed by the filename, if the filename starts with a dash, it will throw an error that there’s an illegal option. Therefore, you must escape out the dash by passing a double dash in front of it. For example, to create a file with a dash in the name, use the following syntax: touch -- -man Likewise, to remove that file: rm -- -man You can also use the double dash when passing commands to ssh rather than have ssh interpret them as arguments, making it useful for command…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Mass Deployment,  Ubuntu,  Unix,  VMware,  Xsan

    5 Ways To Manage Background Jobs In A Shell Environment

    When running commands that are going to take awhile, I frequently start them with the nohup command, disown the command from the current session or queue them for later execution. The reason is that if I’m running them from a Terminal or SSH session and the session is broken I want to make sure they complete. To schedule a job for later execution, use at. For example, if I want to perform a simple command, I can schedule it in a minute by running it as an echo piped to at: echo "goldengirlsfix.sh" | at now + 2 minutes Note, if using 1 minute, you’ll need that to be singular.…

  • Mac OS X,  Mac OS X Server,  Mac Security,  Unix,  Xsan

    Migrate Metadata From Xsan to StorNext

    I’ve written about moving Metadata LUNs from one LUN to another with Xsan in the past, available at https://krypted.com//unix/replacing-xsan-metadata-luns. There, we were using sndiskmove, which works when moving Metadata LUNs from Xsan to Quantum appliances as well (e.g. a 440 or 662). However, the drives that Quantum provides in these appliances are much smaller (and much faster) than those in a traditional Xsan environment. Therefore, the sndiskmove approach would fail as you’re moving from a larger to a smaller LUN. Because the amount of space that you’re using on a Metadata LUN, you should be able to gracefully move metadata to a much smaller LUN. To do so, Quantum provides…

  • Mac OS X,  Mac OS X Server,  Mac Security

    OS X & powermetrics

    Powermetrics is a command that shows very specific information about what’s using your systems power. This makes it handy for troubleshooting what processes are taking up CPU, GPU, etc. To run a basic iteration of the command, we’re going to look at a usage summary report, using the –show-usage-summary option: powermetrics -a --show-usage-summary The output is as follows: Machine model: MacBookAir6,2 OS version: 13A598 *** Sampled system activity (Sun Dec 1 23:04:13 2013 -0600) (5006.04ms elapsed) *** *** Running tasks *** Name PID CPU ms/s User% Deadlines (