Here I put the final solution. I tried many methods on my mac M1, the best method is re-install homebrew.

Step1:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall.sh)"

Step2: Install homebrew

cd /opt 
mkdir homebrew # if not exist, just create one.
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

Then, the problem solved.

Answer from Frank on Stack Overflow
🌐
Apple Community
discussions.apple.com › thread › 254910900
Terminal zsh:killed - Apple Community
June 7, 2023 - I don't know what macOS sets for a default, but nothing would be better at this point. Delete it and research how to customize it for what you need. ... The shell is still telling you that you have not entirely setup the Zsh shell yet. However, the first thing I would remove would be that homebrew eval statement in your ~/.zshrc file.
🌐
Medium
medium.com › @fraycs › how-to-solve-zsh-killed-on-macos-ventura-5c1b01d1ed8a
How to solve zsh: killed on MacOS Ventura | by Sebastían Pulido | Medium
February 1, 2023 - #if you have something like this in your .zshrc export PATH="$HOME/bin:/usr/local/bin:$PATH" # just comment out that line by adding a # at the beginning # export PATH="$HOME/bin:/usr/local/bin:$PATH" # if you have this message # MacPorts Installer addition on 2022-07-12_at_22:37:02: adding an appropriate $ export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts.
Discussions

zsh: killed - Apple Community
Hello. I've got some problems with doing anything in the Terminal on my Mac m1. For any command I get sign 'zsh: killed'. I'm newbie in all this staff and it's quite difficult for me to understand. Please help me to fix the terminal. More on discussions.apple.com
🌐 discussions.apple.com
zsh: killed
Why is this sitting on your desktop? Did you download this properly from the App Store? More on reddit.com
🌐 r/mac
20
11
April 13, 2024
macos - ZSH Killed my executable file in mac m1 while running the iOS project using script - Ask Different
ZSH Killed my executable file in mac m1 machine. I am using the mac m1 machine to run my iOS project. Here while running the app it gets killing my executable script in the m1 machine. I have fastl... More on apple.stackexchange.com
🌐 apple.stackexchange.com
November 5, 2021
Mac os server - zsh killed ./ManagerServer
Hello all, I’ve installed the arm server version for mac and tried to opened in via terminal, but nothing worked, i also disabled the unverified developers in the setting and using the command: sudo spctl --master-disable after running ./ManagerServer it gives me this zsh: killed ./ManagerServer ... More on forum.manager.io
🌐 forum.manager.io
13
0
February 10, 2024
🌐
Apple Community
discussions.apple.com › thread › 253726078
zsh: killed - Apple Community
sudo does not provide full access, it provides root access, and which is (on macOS) rather less than complete system access. sudo is also best deployed with some care, as it can provide sufficient access to wipe out tracts of user data. Please follow my instructions in the reply above to temporarily rename the scripts out of your login, restart Terminal app, and see if you can log in and get the ssh usage info. ... And yeah, homebrew can alter PATH, and potentially other parts of the environment. ... I wanted to see zsh login and logout files, so I wrote $HOME, but I got 'zsh: permission denied'.
🌐
Super User
superuser.com › questions › 1793132 › zsh-killed-in-terminal
macos - zsh: killed in Terminal - Super User
July 2, 2023 - This is most likely due to macOS attribute flags protecting the user from running a binary in a protected folder, and/or due to permission setting on that binary. You can inspect the binary's attributes with xattr -laF@ and you'll likely see ...
🌐
Super User
superuser.com › questions › 1733858 › terminal-commands-which-dirname-curl-and-more-are-all-being-killed-by-zsh-a
Terminal commands (which, dirname, curl, and more) are all being killed by Zsh and don’t work in macOS on an M1-based Mac - Super User
July 27, 2022 - I think you're misinterpreting the ZSH output. It just informs you that the command was killed, not who did it. // The error message is pretty clear and should get you good results if researched. ... What do you mean by "beta OS to macOS"?
Find elsewhere
🌐
Manager Forum
forum.manager.io › t › mac-os-server-zsh-killed-managerserver › 51630
Mac os server - zsh killed ./ManagerServer - Manager Forum
February 10, 2024 - Hello all, I’ve installed the arm server version for mac and tried to opened in via terminal, but nothing worked, i also disabled the unverified developers in the setting and using the command: sudo spctl --master-disable after running ./ManagerServer it gives me this zsh: killed ./ManagerServer ...
🌐
Stack Exchange
apple.stackexchange.com › questions › 460623 › most-terminal-commands-are-killed
macos - most terminal commands are killed - Ask Different
It would help to know which macOS version you are running. If you are fine with doing so, change your default shell to bash and see if the problem goes away. You can always change it back. ... This is not zsh getting killed, it's zsh telling you that the program it started was killed with SIGKILL (signal 9).
🌐
Apple Developer
developer.apple.com › forums › thread › 698167
ZSH Won't Run an M1 Command Line T… | Apple Developer Forums
January 11, 2022 - The trusted execution system killed your tool and zsh is reporting that. which is a basic Swift Package so there's no … Code Signing involved · Code signing is always involved, at least on Apple silicon, where macOS requires that code be at least ad hoc signed.
🌐
Apple Community
discussions.apple.com › thread › 255154958
zsh killing some commands but not others - Apple Community
September 26, 2023 - Last login: Mon Sep 25 19:02:09 on ttys000 zsh: killed mkdir -m 700 -p "$SHELL_SESSION_DIR" zsh: killed ... You are using the homebrew installed GNU coreutils (ls, mkdir) in /usr/local/bin instead of the same utilities distributed by macOS in /bin.
🌐
Reddit
reddit.com › r/macos › installed homebrew programs return "zsh: killed"
r/MacOS on Reddit: Installed homebrew programs return "zsh: killed"
May 11, 2022 -

When I type brew, I get the output:

zsh: killed     brew

Writing out the whole path still gives the same output, so it doesn't seem like a path problem.

Furthermore, running /bin/bash gives the output:

zsh: killed     /bin/bash

I changed the names of .zshrc and .zprofile, yet the problem still persisted.

To add on, this problem also occurs with programs like pyenv.

🌐
Apple Community
discussions.apple.com › thread › 254010763
“zsh: killed” — problem in shell, or my o… - Apple Community
July 1, 2022 - > which texsyn /usr/local/bin/texsyn > echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin > /usr/local/bin/texsyn zsh: killed /usr/local/bin/texsyn > ls -l /usr/local/bin/texsyn -rwxr-xr-x 1 cwr admin 937960 Jun 29 10:28 /usr/local/bin/texsyn
🌐
YouTube
youtube.com › watch
How to Resolve zsh: killed code . Command Issue on MacOS M1 Chip - YouTube
Resolve the frustrating `zsh: killed code .` command issue on MacOS Monterey machines, especially for Visual Studio Code users. Follow our step-by-step guide...
Published   April 15, 2025
Views   7
🌐
Cockos Incorporated Forums
forum.cockos.com › showthread.php
[SOLVED] What is this? zsh:killed reaper - Cockos Forums
November 6, 2022 - It appears JavaScript is not enabled for your browser. If you already have an account on this system, you can log-in directly here: · Otherwise, in order to verify you are not a bot, you will need to temporarily enable JavaScript and reload this page. Thank you for your understanding
🌐
Reddit
reddit.com › r/ubuntu › zsh killed shell when installing linux in mac
r/Ubuntu on Reddit: zsh killed shell when installing linux in mac
December 5, 2023 - The community for everything related to Apple's Mac computers! Members · Online · upvotes · · comments · "ZSH: Killed" Error immediately after every command on M1 MacBook · r/youtubedl • · r/youtubedl · youtube-dl, and yt-dlp are a command-line program to download videos from YouTube.com, as well as many other media streaming websites.
🌐
Reddit
reddit.com › r/youtubedl › "zsh: killed" error immediately after every command on m1 macbook
r/youtubedl on Reddit: "ZSH: Killed" Error immediately after every command on M1 MacBook
February 11, 2021 -

Hi, I'm pretty new to homebrew and the whole command line thing on the Mac, so please be kind ;) Every time I try to use YouTube-DL this happens:

youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA" zsh: killed youtube-dl --verbose "https://www.youtube.com/watch?v=lKeUCkBO8QA"

I spend hours googling for help, but I couldn't find anything. Can someone please explain to me what's going on there and wtf is killing that process?

Btw I got Vidl installed also.