macOS and linux commands:

basic 100 commands :

Here are 100 macOS terminal commands with examples:

  1. ls: List directory contents.

    ls
  2. cd: Change directory.

    cd /path/to/directory
  3. pwd: Print working directory.

    pwd
  4. mkdir: Make directory.

    mkdir new_directory
  5. rmdir: Remove directory.

    rmdir empty_directory
  6. rm: Remove files or directories.

    rm file.txt
  7. cp: Copy files or directories.

    cp source.txt destination.txt
  8. mv: Move or rename files or directories.

    mv old_name.txt new_name.txt
  9. touch: Create an empty file or update the timestamp.

    touch newfile.txt
  10. cat: Concatenate and display file content.

    cat file.txt
  11. echo: Display a line of text.

    echo "Hello, World!"
  12. man: Display the manual page for a command.

    man ls
  13. grep: Search for patterns within files.

    grep "search_term" file.txt
  14. find: Search for files in a directory hierarchy.

    find /path -name "*.txt"
  15. chmod: Change file modes or Access Control Lists.

    chmod 755 script.sh
  16. chown: Change file owner and group.

    chown user:group file.txt
  17. sudo: Execute a command as another user, typically root.

    sudo shutdown -h now
  18. ps: Report a snapshot of current processes.

    ps aux
  19. top: Display dynamic real-time view of system processes.

    top
  20. kill: Send a signal to a process.

    kill -9 PID
  21. df: Report file system disk space usage.

    df -h
  22. du: Estimate file space usage.

    du -sh *
  23. ifconfig: Configure network interfaces.

    ifconfig
  24. ping: Send ICMP ECHO_REQUEST to network hosts.

    ping google.com
  25. ssh: OpenSSH SSH client (remote login program).

    ssh user@hostname
  26. scp: Secure copy (remote file copy program).

    scp file.txt user@hostname:/path/to/destination
  27. curl: Transfer data from or to a server.

    curl http://example.com
  28. wget: Non-interactive network downloader.

    wget http://example.com/file.zip
  29. tar: Archive files.

    tar -cvf archive.tar file1 file2
  30. gzip: Compress files.

    gzip file.txt
  31. gunzip: Decompress files.

    gunzip file.txt.gz
  32. zip: Package and compress files.

    zip archive.zip file1 file2
  33. unzip: Extract compressed files.

    unzip archive.zip
  34. which: Locate a command.

    which python
  35. whereis: Locate the binary, source, and manual page files for a command.

    whereis ls
  36. alias: Create an alias for a command.

    alias ll='ls -la'
  37. unalias: Remove an alias.

    unalias ll
  38. export: Set environment variables.

    export PATH=$PATH:/new/path
  39. env: Show the environment variables.

    env
  40. history: Show the command history.

    history
  41. clear: Clear the terminal screen.

    clear
  42. nano: Simple text editor in terminal.

    nano file.txt
  43. vi/vim: Powerful text editor in terminal.

    vi file.txt
  44. open: Open a file or URL in the default application.

    open file.txt
  45. defaults: Command line interface to the user defaults system.

    defaults write com.apple.finder AppleShowAllFiles YES
  46. diskutil: Disk utilities.

    diskutil list
  47. hdiutil: Create and manipulate disk images.

    hdiutil create -volname MyDisk -srcfolder /path/to/folder -ov -format UDZO MyDisk.dmg
  48. say: Convert text to audible speech.

    say "Hello, World!"
  49. spctl: Security policy control.

    spctl --status
  50. softwareupdate: System software update tool.

    sudo softwareupdate -i -a
  51. brew: Homebrew package manager.

    brew install wget
  52. system_profiler: System hardware and software configuration information.

    system_profiler SPHardwareDataType
  53. ioreg: Show the I/O Kit registry.

    ioreg -l
  54. pmset: Power management settings.

    pmset sleepnow
  55. networksetup: Network settings.

    networksetup -getinfo Wi-Fi
  56. airport: Wireless diagnostics.

    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I
  57. csrutil: System Integrity Protection configuration.

    csrutil status
  58. nvram: Manipulate firmware NVRAM variables.

    nvram -p
  59. mdfind: Spotlight search from the command line.

    mdfind "keyword"
  60. mdutil: Manage Spotlight indexing.

    sudo mdutil -E /
  61. sips: Scriptable image processing system.

    sips -z 800 600 input.jpg --out output.jpg
  62. textutil: Manipulate text files of various formats.

    textutil -convert txt file.rtf
  63. pkgutil: Query and manipulate installer packages.

    pkgutil --pkgs
  64. tccutil: Manage the privacy database.

    tccutil reset Camera
  65. diskutil: Disk utilities (again for another use case).

    diskutil eraseDisk HFS+ NewDisk /dev/disk2
  66. dscacheutil: Query and manage the Directory Service cache.

    dscacheutil -flushcache
  67. launchctl: Interface with launchd to manage services.

    launchctl list
  68. sudo shutdown: Shut down the system.

    sudo shutdown -h now
  69. sudo reboot: Reboot the system.

    sudo reboot
  70. sudo halt: Halt the system.

    sudo halt
  71. uptime: Tell how long the system has been running

. sh uptime

  1. date: Display or set the system date and time.

  2. cal: Display a calendar.

  3. whoami: Print the effective userid.

  4. id: Print real and effective user and group IDs.

  5. groups: Show which groups the user is a member of.

  6. passwd: Change user password.

  7. crontab: Schedule periodic jobs.

  8. at: Schedule a command to be run at a later time.

  9. bg: Resume a suspended job in the background.

  10. fg: Resume a suspended job in the foreground.

  11. jobs: List active jobs.

  12. killall: Kill processes by name.

  13. nohup: Run a command immune to hangups, with output to a non-tty.

  14. nice: Run a command with modified scheduling priority.

  15. renice: Alter priority of running processes.

  16. say: Text to speech.

  17. osascript: Execute AppleScripts and other OSA language scripts.

  18. diskutil: Disk utilities (yet another use case).

  19. sudo periodic: Run system maintenance scripts.

  20. sudo lsof: List open files.

  21. dtrace: Dynamic tracing framework.

  22. iotop: Display I/O usage by processes.

  23. htop: Interactive process viewer.

  24. vm_stat: Show virtual memory statistics.

  25. du: Disk usage.

  26. df: Disk free space.

  27. ioreg: I/O registry.

  28. pmset: Power management settings.

  29. csrutil: System Integrity Protection status. sh csrutil status


linux commands

Last updated