Are you a Command-Line or Shell connoisseur or New to Command-Line? in MacOS? If so, or you’re interested in learning more about using shell to interact with your MacOS ecosystem, here’s a list of 30 super-handy bash commands for macOS to level-up your terminal game.

These commands are super, SUPER, handy and will give you a lot of flexibility for managing files, monitoring system performance, and working with networks on your Mac. Let me know which ones you want to dive into, or if you need help with examples or automation ideas! 😊

System & File Management:

  1. killall Dock
    • Purpose: Refresh the Dock or resolve display issues.
    • Usage: killall Dock
  2. ls
    • Purpose: List files and directories.
    • Usage: ls -l (detailed list)
  3. cd
    • Purpose: Change directories.
    • Usage: cd /path/to/folder
  4. mkdir
    • Purpose: Create a new directory.
    • Usage: mkdir new_folder
  5. touch
    • Purpose: Create an empty file.
    • Usage: touch file.txt
  6. rm
    • Purpose: Remove files or directories.
    • Usage: rm file.txt (files), rm -r folder (directory)
  7. cp
    • Purpose: Copy files or directories.
    • Usage: cp file.txt /path/to/destination
  8. mv
    • Purpose: Move or rename files/directories.
    • Usage: mv old_name.txt new_name.txt
  9. cat
    • Purpose: Display the content of a file.
    • Usage: cat file.txt
  10. open
    • Purpose: Open files, apps, or URLs.
    • Usage: open file.txt (file), open -a "App Name" (app)

System Monitoring & Control:

  1. top
    • Purpose: Monitor system processes and performance.
    • Usage: top
  2. htop (if installed)
    • Purpose: Advanced system monitoring with an interactive interface.
    • Usage: htop
  3. ps
    • Purpose: Show currently running processes.
    • Usage: ps aux
  4. df
    • Purpose: Check disk space usage.
    • Usage: df -h
  5. du
    • Purpose: Check disk usage of files and directories.
    • Usage: du -sh folder_name
  6. uptime
    • Purpose: Display system uptime.
    • Usage: uptime
  7. whoami
    • Purpose: Show the current logged-in user.
    • Usage: whoami
  8. hostname
    • Purpose: Show the computer’s hostname.
    • Usage: hostname

Network Commands:

  1. ifconfig
    • Purpose: Show network interface configuration.
    • Usage: ifconfig
  2. ping
    • Purpose: Check network connectivity to a server.
    • Usage: ping google.com
  3. traceroute
    • Purpose: Show the path packets take to a network host.
    • Usage: traceroute google.com
  4. netstat
    • Purpose: Display network statistics.
    • Usage: netstat -an
  5. curl
    • Purpose: Transfer data from a server (often used to test web servers).
    • Usage: curl https://example.com
  6. scp
    • Purpose: Securely copy files between systems.
    • Usage: scp file.txt user@remote:/path/to/destination
  7. ssh
    • Purpose: Log into a remote system via SSH.
    • Usage: ssh user@hostname

File & Text Manipulation:

  1. grep
    • Purpose: Search for patterns in files.
    • Usage: grep "search_term" file.txt
  2. find
    • Purpose: Search for files and directories.
    • Usage: find /path -name "file.txt"
  3. sed
    • Purpose: Stream editor for editing text.
    • Usage: sed 's/old_text/new_text/g' file.txt
  4. awk
    • Purpose: Process and analyze text files.
    • Usage: awk '{print $1}' file.txt (prints first column)
  5. tar
    • Purpose: Compress or extract files.
    • Usage: tar -czf archive.tar.gz folder (compress), tar -xzf archive.tar.gz (extract)

If you're interested in learning more, see our 30 Advanced Command-Line Utilities List.  There you'll find 30 more, more advanced utilities, to support your growing skillset. 

Primary Category
Sub-Domain
Confidentiality
No