The Swiss Army knives for Linux and Mac - they’ve thought of everything
This is a guided tour of Linux utilities, presented in as logical a sequence as I can imagine.
MacOS/Mac OS X uses the BSD version command line tools, which are different from the Linux version, while they are both compliant with POSIX standards.
6:35 up 9 days, 11:56, 7 users, load averages: 2.09 2.08 2.06
Load averages lists calcuations of the average system load over three period of times: the last one-, five-, and fifteen-minute periods. Each process using or waiting for CPU (the ready queue or run queue) increments the load number by 1. In a system with four CPUs, a load average of 3.73 would indicate that there were, on average, 3.73 processes ready to run, and each one could be scheduled into a CPU.
To list the top hungry processes, and refersh the screen:
To cancel the display, press control+C.
That works with any process you want to kill.
So that we can kill it for fun, create a background process (by specifying &) which sleep for 999 seconds:
sleep 999 &
Get the process identifier:
List background processes:
+ Running sleep 999 &
The + shows the focus.
To list all processes with a niceness (NI) column:
Expand the terminal window width to avoid line wrapping.
UID PID PPID F CPU PRI NI SZ RSS WCHAN S ADDR TTY TIME CMD 501 2752 2749 4006 0 31 0 4320804 44 - Ss 0 ttys001 0:00.19 /Users/wilsonmar
### Niceness of priority
Default niceness of zero, but can be -20 to +19.
PROTIP: A niceness of +19 is a priority of 99, which is lowest.
nice -n 5 sleep 1000&
root permissions are needed to set nice below zero.
renice -n 5 sleep 1000&
To kill a single program by name:
To kill several progams by name:
Get the set of utilities from GNU Linux, but for Mac:
brew install coreutils
Then you can:
ln -s /usr/local/bin/gtac /usr/local/bin/tac
Cron Launchd Background Jobs
This mentions that Apple has deprecated cron in favor of launchd (a daemon running under the System context). to automatically start (after reboots) service programs at boot time.
If the system is turned off or asleep, cron jobs do not execute until the next designated time occurs.
However, a launchd job will run when the computer wakes up if the computer was asleep when the job should have run (if the StartCalendarInterval key has been set).
Since it’s a background process, launchd doesn’t present a user interface. So you get “launchd cannot be run directly.” when you run launchd like other commands.
The standard way now to run a service on Mac OS X is to use launchd , a program that starts, stops and manages daemons and scripts in Apple OS X environments.
An XML document named with file extension .plist defines its properties.
The sample file below defines the Nexus Repository Manager from Sonatype.com installed in
The above is the
com.sonatype.nexus.plist file in
Change its ownership and access rights:
sudo chown root:wheel /Library/LaunchDaemons/com.sonatype.nexus.plist sudo chmod 644 /Library/LaunchDaemons/com.sonatype.nexus.plist
PROTIP: Consider setting up a different user to run the repository manager and adapt permissions and the RUN_AS_USER setting in the nexus startup script.
To manually start it after the configuration:
sudo launchctl load /Library/LaunchDaemons/com.sonatype.nexus.plist
Install appium_console gem
gem uninstall -aIx appium_lib gem uninstall -aIx appium_console gem install --no-rdoc --no-ri appium_console
Install flaky gem:
gem uninstall -aIx flaky gem install --no-rdoc --no-ri flaky
More on OSX
This is one of a series on Mac OSX:
- MacOS Versions
- MacOS Keyboard tricks
- MacOS Hardware and accessories
- 1password on MacOS
- MacOS Setup automation with Ansible
- Text editors and IDEs on MacOS
- Utilities for MacOS
- MacOS Configuration dotFiles
- MacOS Homebrew installers
- Backups on MacOS
- Windows on Apple MacOS
- PHP on MacOS
- Java on MacOS
- Maven on MacOS
- Ruby on MacOS
- Python on MacOS
- Node on MacOS installation