Board index Linux Linux - Commands and Tools

Moderator: chandranjoy

MAC - OS X Command Line tricks

Postby chandranjoy » Wed Nov 30, 2011 6:36 am


A gem found in many unix distros, and every version of OS X, SSH allows you to remotely and securely administrate your (or any other) system. A basic usage would be "ssh -l admin". The "" being the IP or domain you wish to connect to, "-l" meaning the next word is the login name, "admin" being the username. It will then prompt you for a password and voila, you are connected! For more ssh examples and functions, check out this Mac ssh article.


Top is one of my personal favorite commands. Since OS X is based on *nix, top is obviously an included utility. It allows you to view all running processes, system resource usage, and much more. Give it a try, just type “top” into the Terminal.


ifconfig is another great unix utility which allows you to view information regarding your network connections. It is by far the easiest and quickest way to get MAC addresses’s, IP addresses’s, and any other kind of networking info. Try it out, just type "ifconfig" into the Mac Terminal.


This utility allows you to perform the same function as Software Update… in the Apple menu. But instead it is done inside of the terminal rather then using the GUI. Type "softwareupdate -i -a" to install all available updates for your Mac, or just "softwareupdate -i -r" to install recommended updates only.

These of course, are only some of my favorite command line utilities. You can type "bash" to start the bash shell and you will have access to all the bash utilities. Here is a comprehensive list of functions and utilities available on the Mac.

Code: Select all
  alloc     List used and free memory
  awk       Find and Replace text within file(s)
  basename  Convert a full pathname to just a filename
  bash      Bourne-Again SHell
  bless     Set volume bootability and startup disk options.
  bzip      Compress or decompress files
  cal       Display a calendar
  cat       Display the contents of a file
  chflags   Change a file or folder's flags
  chgrp     Change group ownership
  chmod     Change access permissions
  chown     Change file owner and group
  chroot    Run a command with a different root directory
  cksum     Print CRC checksum and byte counts
  clear     Clear terminal screen
  cmp       Compare two files
  comm      Compare two sorted files line by line
  cp        Copy one or more files to another location
  cron      Daemon to execute scheduled commands
  crontab   Schedule a command to run at a later date/time
  cut       Divide a file into several parts
  date      Display or change the date & time
  dc        Desk Calculator
  dd        Data Dump - Convert and copy a file
  defaults  Set preferences, show hidden files
  df        Display free disk space
  diff      Display the differences between two files
  diff3     Show differences among three files
  dig       DNS lookup
  dirname   Convert a full pathname to just a path
  diskutil  Disk utilities - Format, Verify, Repair
  ditto     Copy files and folders
  dot_clean Remove dot-underscore files
  drutil    Interact with CD/DVD burners
  dscacheutil Query or flush the Directory Service/DNS cache
  dscl      Directory Service command line utility
  du        Estimate file space usage
  ed        A line-oriented text editor (edlin)
  env       Set environment and run a utility
  expand    Convert tabs to spaces
  expect    Programmed dialogue with interactive programs
            Also see AppleScript
  expr      Evaluate expressions
  false     Do nothing, unsuccessfully
  fc        Fix command (history)
  fdisk     Partition table manipulator for Darwin UFS/HFS/DOS
  file      Determine file type
  find      Search for files that meet a desired criteria
  fmt       Reformat paragraph text
  fold      Wrap text to fit a specified width
  fsck      Filesystem consistency check and repair
  fsaclctl  Filesystem enable/disable ACL support
  fs_usage  Filesystem usage (process/pathname)
  ftp       Internet file transfer program
  GetFileInfo Get attributes of HFS+ files
  getopt    Parse positional parameters
  goto      Jump to label and continue execution
  grep      Search file(s) for lines that match a given pattern
  groups    Print group names a user is in
  gzip      Compress or decompress files
  head      Display the first lines of a file
  hdiutil   Manipulate iso disk images
  hostname  Print or set system name
  id        Print user and group names/id's
  info      Help info
  install   Copy files and set attributes
  join      Join lines on a common field
  kextfind  List kernel extensions
  kickstart Configure Apple Remote Desktop
  kill      Stop a process from running
  l         List files in long format (ls -l)
  last      Indicate last logins of users and ttys
  launchctl Load or unload daemons/agents
  ll        List files in long format, showing invisible files (ls -la)
  less      Display output one screen at a time
  lipo      Convert a universal binary
  ln        Make links between files (hard links, symbolic links)
  locate    Find files
  logname   Print current login name
  login     log into the computer
  lpr       Print files
  lprm      Remove jobs from the print queue
  lpstat    Printer status information
  ls        List information about file(s)
  lsregister Reset the Launch Services database
  lsbom     List a bill of materials file
  lsof      List open files
  man       Help manual
  mdfind    Spotlight search
  mdutil    Manage Spotlight metadata store
  mkdir     Create new folder(s)
  mkfifo    Make FIFOs (named pipes)
  more      Display output one screen at a time
  mount     Mount a file system
  mv        Move or rename files or directories
  net       Manage network resources
  netstat   Show network status
  networksetup Network and System Preferences
  nice      Set the priority of a command
  nohup     Run a command immune to hangups
  ntfs.util NTFS file system utility
  onintr    Control the action of a shell interrupt
  open      Open a file/folder/URL/Application
  osacompile Compile Applescript
  osascript Execute AppleScript
  passwd    Modify a user password
  paste     Merge lines of files
  pbcopy    Copy data to the clipboard
  pbpaste   Paste data from the Clipboard
  pico      Simple text editor
  ping      Test a network connection
  pkgutil   Query and manipulate installed packages
  plutil    Property list utility
  pmset     Power Management settings
  pr        Convert text files for printing
  printenv  Print environment variables
  ps        Process status
  pushd     Save and then change the current directory
  quota     Display disk usage and limits
  rcp       Copy files between machines
  reboot    Stop and restart the system
  rev       Reverse lines of a file
  rm        Remove files
  rmdir     Remove folder(s)
  rpm       Remote Package Manager
  rsync     Remote file copy - Sync file tree (also RsyncX)
  say       Convert text to audible speech
  screen    Multiplex terminal, run remote shells via ssh
  screencapture Capture screen image to file or disk
  sdiff     Merge two files interactively
  security  Administer Keychains, keys, certificates and the Security framework
  sed       Stream Editor
  setfile   Set attributes of HFS+ files
  shutdown  Shutdown or restart OS X
  sleep     Delay for a specified time
  softwareupdate System software update tool
  sort      Sort text files
  split     Split a file into fixed-size pieces
  stop      Stop a job or process
  su        Substitute user identity
  sudo      Execute a command as another user
  sum       Print a checksum for a file
  sw_vers   Print Mac OS X operating system version
  system_profiler  Report system configuration
  systemsetup Computer and display system settings
  tail      Output the last part of files
  tar       Tape ARchiver
  tee       Redirect output to multiple files
  textutil  Manipulate text files in various formats (Doc,html,rtf)
  time      Measure Program Resource Use
  touch     Change file timestamps
  tr        Translate, squeeze, and/or delete characters
  traceroute Trace Route to Host
  true      Do nothing, successfully
  tty       Print filename of terminal on stdin
  ufs.util  Mount/unmount UFS file system
  umask     Users file creation mask
  umount    Unmount a device
  uname     Print system information
  unexpand  Convert spaces to tabs
  uniq      Uniquify files
  units     Convert units from one scale to another
  users     Print login names of users currently logged in
  uuencode  Encode a binary file
  uudecode  Decode a file created by uuencode
  uuidgen   Generate a Unique ID (UUID/GUID)
  uucp      Unix to Unix copy
  vi        Text Editor
  wc        Print byte, word, and line counts
  where     Report all known instances of a command
  which     Locate a program file in the user's path
  who       Print all usernames currently logged on
  whoami    Print the current user id and name (`id -un')
  write     Send a message to another user
  xargs     Execute utility - passing arguments
  yes       Print a string until interrupted

Let me know if you have any suggestions, i will add/correct as needed.
Be Sociable, Share!

Site Admin
Posts: 283
Joined: Fri Oct 23, 2009 11:19 pm

Return to Linux - Commands and Tools

Who is online

Users browsing this forum: No registered users and 1 guest