Apple UNIX

From HaFrWiki42
Revision as of 17:39, 19 August 2016 by Hjmf (talk | contribs)
Jump to navigation Jump to search

The underwater operating system of Apple SnowLeopard is based on Unix. So use the power of Unix in Apple Mac.

Useful Unix Utilities

Program Description Usage Example
bc Basic Calculator, type 2+2 and press return.  
kill Max OS X offers no shortage of ways to cut the cord on programs that seems to be locked up or running amok. Use the Activity Monitor or use kill.

First get the ID number running top.

 
open Launch programs  
ps Process Status (ps) is another way to get a quick look at all running programs. For the best results use the -e and the -f flags. ps -ef
shutdown Shutdown with the -h flags has its advantages, because it gives the user more control. shutdown -h
tar, gzip, zip Compressed Archive files  
top Running top (table of processes) lists every program currently running. top -u
xattr Manage the extended attributes of Mac files, invisible metadata describing all kind of characteristics of every file.  
alias Shortcuts for commands alias la='ls -Al'
nano, emacs, vim editors  
grep Grep is a filter and is used in combination with other programs.  
find Terrible powerful program with a lot of features. find . -name "fn" -type f -print 2>/dev/null
mdfind MedaData find mdfind 'kMDItenFlashOnOff == "1"'
launchd Launching System Programs  
ftp File Transfer Program  

Example Process Finding

If you are running a terminal program, you may wanna find if it is still running using one of the above tools.
Assume you are running the following program which runs in an infinite loop (forever) in a Terminal window. <syntaxhighlight lang="bash"> $ php FormulaExec.php </syntaxhighlight>

To see the program PID you can use: <syntaxhighlight lang="bash"> $ ps -e

 PID TTY           TIME CMD
   1 ??         2:44.97 /sbin/launchd
  46 ??         0:48.23 /usr/sbin/syslogd
 ...
 528 ttys000    0:01.81 login -pfl HaFrMpro /bin/bash -c exec -la bash /bin/bash
 542 ttys000    0:00.08 -bash
3002 ttys000    0:00.01 tail -f -n 64 /Applications/MAMP/logs/php_error.log
 536 ttys001    0:01.76 login -pfl HaFrMpro /bin/bash -c exec -la bash /bin/bash
 644 ttys001    0:00.18 -bash

10842 ttys001 0:00.11 php FormulaExec.php

 537 ttys002    0:01.77 login -pfl HaFrMpro /bin/bash -c exec -la bash /bin/bash
 668 ttys002    0:00.76 -bash

10969 ttys002 0:00.00 ps -e

  ...

$ </syntaxhighlight>

If you use: <syntaxhighlight lang="bash"> $ ps -e | grep -i 'formulaexec' 10842 ttys001 0:00.12 php FormulaExec.php 11001 ttys002 0:00.01 grep -i formulaexec </syntaxhighlight>


See also

top

References

top