- How to change default shell to bash on Macos Catalina/Big Sur
- How to set default shell to bash on Macos Catalina
- List your shell options on Unix
- How to change your zsh to bash on macOS
- Find out your bash version
- How do I update or upgrade bash version?
- Conclusion
- Change the Shell in Mac OS X Terminal
- How to Change Terminal Apps Default Shell in Mac OS X
- Change a User Default Login Shell in Mac OS X
- How to switch back to bash in Terminal on macOS Catalina
- Switch back to bash in Terminal
- Change default shell to bash
- Как переключиться обратно на bash в Терминале на macOS Catalina
- Switch вернуться к Bash в терминале
- Изменить оболочку по умолчанию на bash
- [MacOS] How To Change Default Scripting Language Zsh To Bash
- What is the scripting language?
- Change scripting language via terminal
- Use the system preferences to change the scripting language
How to change default shell to bash on Macos Catalina/Big Sur
I noticed that my default shell set to zsh on Macos Catalina/Big Sur. How do I change my default shell to bash on Macos Catalina or above using the command line or GUI options?
A Unix shell is nothing but a program that accepts Unix commands from the keyboard and executes them. For a long time, the bash was a default shell in macOS. However, Apple replaced Bourne Again SHell with Z shell for licensing reasons. This page explains how to set up bash as your default login shell and interactive shell on macOS Catalina, “Big Sur” and above.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | No |
Requirements | macOS OS and Terminal app |
Est. reading time | 3 minutes |
How to set default shell to bash on Macos Catalina
The procedure is as follows:
- Open the terminal application.
- List available shells by typing cat /etc/shells .
- To update your account to use bash run chsh -s /bin/bash
- Close terminal app.
- Open the terminal app again and verify that bash is your default shell.
List your shell options on Unix
You must only include shells listed in the /etc/shells file. Otherwise, your account will get locked up when an invalid shell name or path is specified. Hence, always verify paths. Simply run the following cat command:
cat /etc/shells
How to change your zsh to bash on macOS
Of course, you are not limited to bash. We can see a list of all other shell installed by using the cat command and then use that shell:
# get a list
cat /etc/shells
# Change to ksh
chsh -s /bin/ksh
## OR fish shell if installed on your Mac ##
chsh -s /usr/local/bin/fish
See “How do I find out what shell I am using on Linux/Unix?” for other commands-line tips and tricks.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Find out your bash version
Type the following command:
bash —version
Sample outputs:
I am using bash version 3.2.57 on macOS.
How do I update or upgrade bash version?
Homebrew installs the apps you need that Apple didn’t include in their base operating system or app store such as cutting edge version of gnu/bash. See how to install Homebrew on macOS to use the brew package manager
Homebrew user can type the following brew command to install the latest version of bash on Catalina:
brew install bash
The newer version of bash is located at /usr/local/bin/bash:
ls -l /usr/local/bin/bash
cat /etc/shells
If not in /etc/shells, append it:
sudo -i
echo /usr/local/bin/bash >> /etc/shells
We can use the which command or type command/command command to locate a command path on macOS or Unix-like operating systems. For instance, get the pathnames of the files (or links) which would be executed in the current environment:
Set default shell to /usr/local/bin/bash, run the following chsh command chsh -s /usr/local/bin/bash
Verify new gnu/bash version:
bash —version
/usr/local/bin/bash —version
Sample outputs:
Conclusion
You learned how to set and use bash as the default shell on your Mac Catalina as Apple changed the default from bash to zsh.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
Change the Shell in Mac OS X Terminal
Tired of bash? Prefer zsh, ksh, tcsh, fish, or sh? You can quickly change the default shell in Terminal app, in addition to changing a users default login shell for when logging in remotely with SSH or otherwise. Here’s how to do both.
How to Change Terminal Apps Default Shell in Mac OS X
This adjusts the new shell that is used upon Terminal app launch, new terminal windows, and new terminal tabs, becoming the new default Mac shell.
- Open Preferences from the Terminal menu, click the “Startup” tab
- Under “Shells open with” choose “Command (complete path)” and set the new shell
Default shell options that can be switched to that are bundled with OS X include the following paths:
/bin/zsh
/bin/ksh
/bin/tcsh
/bin/bash
/bin/sh
Placing any of those in the ‘Command (complete path)’ box will set the new shell as the terminal window default.
Note this changes the default shell used by Terminal app, which is different from the default login shell, that is changed through the following step instead…
Change a User Default Login Shell in Mac OS X
You can also change the default shell through the command line itself using the chsh command, which is shorthand for ‘change shell’. This will be necessary if you want the default shell to be different when logging in with SSH or telnet. You’ll need to authenticate each change as well, the command will ask directly or you can prefix it with sudo. Here’s how to set the default user shell to zsh, bash, tcsh, ksh, sh, or any other shell for that matter.
Change the user login default shell to zsh:
chsh -s /bin/zsh
ksh:
chsh -s /bin/ksh
tcsh:
chsh -s /bin/tcsh
bash (default):
chsh -s /bin/bash
sh:
chsh -s /bin/sh
other shells:
Simply adjust the path for chsh to set, like so:
chsh -s /path/to/alternate/shell/like/fish
We covered the first part of this years ago and it hasn’t changed since, even with OS X Lion and OS X Mountain Lion, and Mavericks.
Источник
How to switch back to bash in Terminal on macOS Catalina
Jul 22, 2019
Comment
The default shell on macOS Catalina has changed from Bash to Zsh. You have to run a command to actually make the change and many think that Zsh is better. If you’ve made the switch and want to change back to Bash as the default shell whenever you open Terminal, it’s an easy change to make. Here’s how you can switch back to bash in Terminal.
Switch back to bash in Terminal
Open the Terminal app and on the menu bar select the Terminal menu item. From the menu, select Preferences. On the Preferences window, go to the General tab. There’s an option called ‘Shells open with’. Select ‘Command (complete path):’. In the field below it, enter the following;
Quit Terminal and open it again. Terminal will now always open in Bash.
Change default shell to bash
The previous section changes which shell the Terminal opens with however it doesn’t actually change the default shell back to bash. It has more or less the same effect but if you want to change the default shell back to bash, run the following command in Terminal. You will have to enter your password.
After this command, you can leave the option in the Terminal preferences set to ‘Default login shell’ under the ‘Shells open with’ option.
Once you update to Catalina, there’s no removing Zsh from the system. Since you can change the shell back to Bash, it doesn’t matter much. The only downside of changing back to Bash is that each time you open a new Terminal window, there will be a message at the top telling you to switch to Zsh and giving you the command to make the switch.
As for which shell you should use, it’s really up to you. There are other shells besides Bash and Zsh available on macOS. If you want to view a list of all the shells that are available run the following command in Terminal.
After that, you can choose any one of the shells and use them either as the shell that Terminal uses or change the default shell. The command is the same except you have to change ‘bin/bash’ to whichever shell you want to set as the default.
If you want to switch to Csh, you’d run the following command;
Likewise, to change the shell that it opens to without changing the default shell, enter this in Terminal’s preferences.
Источник
Как переключиться обратно на bash в Терминале на macOS Catalina
Оболочка по умолчанию в macOS Catalina была изменена с Bash на Zsh. Вы должны выполнить команду, чтобы действительно внести изменения, и многие думают, что Zsh лучше. Если вы произвели переключение и хотите вернуться к Bash в качестве оболочки по умолчанию при каждом открытии терминала, это легко сделать. Вот как вы можете переключиться обратно на bash в Терминале.
Switch вернуться к Bash в терминале
Откройте приложение «Терминал» и в строке меню выберите пункт «Терминал». В меню выберите «Настройки». В окне настроек перейдите на вкладку Общие. Есть опция «Оболочки открываются с». Выберите «Команда (полный путь):». В поле под ним введите следующее;
Выйдите из терминала и откройте его снова. Терминал теперь всегда будет открываться в Баше.
Изменить оболочку по умолчанию на bash
В предыдущем разделе описывается, какая оболочка открывается в Терминале, однако в действительности она не меняет оболочку по умолчанию на bash. Он имеет более или менее тот же эффект, но если вы хотите изменить оболочку по умолчанию обратно на bash, выполните следующую команду в Терминале. Вам нужно будет ввести свой пароль.
После этой команды вы можете оставить параметр в настройках терминала, установленный на «Оболочка входа по умолчанию» в разделе «Оболочки, открытые с».
После обновления до Catalina Zsh не удаляется из системы. Поскольку вы можете изменить оболочку на Bash, это не имеет большого значения. Единственный недостаток перехода обратно на Bash – это то, что каждый раз, когда вы открываете новое окно терминала, вверху будет сообщение, сообщающее вам переключиться на Zsh и дающее вам команду сделать переключение.
Что касается того, какую оболочку вы должны использовать, это действительно ваше дело. Есть и другие оболочки, кроме Bash и Zsh, доступные в macOS. Если вы хотите просмотреть список всех доступных оболочек, выполните следующую команду в Терминале.
После этого вы можете выбрать любую из оболочек и использовать их в качестве оболочки, которую использует Терминал, или изменить оболочку по умолчанию. Команда та же самая, за исключением того, что вы должны изменить «bin / bash» на любую оболочку, которую вы хотите установить по умолчанию.
Если вы хотите переключиться на Csh, вы должны выполнить следующую команду;
Аналогично, чтобы изменить оболочку, в которой она открывается, без изменения оболочки по умолчанию, введите это в настройках терминала.
Источник
[MacOS] How To Change Default Scripting Language Zsh To Bash
When you started using Mac OS in first time, you would find the default scripting language in terminal is Zsh instead of Bash. If you want to change this situation, I can help.
I am more familiar with bash, so I have more scripts wrote by bash, even if zsh and bash are both scripting languages, there is no guarantee that zsh can execute my old scripts.
So, let’s introduce how to change the zsh to bash in the Mac OS terminal! But first, I want to introduce what is the scripting language.
What is the scripting language?
Scripting Language is an interpreted programming language.
The following content is excerpted from Wikipedia.
A scripting language or script language is a programming language for a runtime system that automates the execution of tasks that would otherwise be performed individually by a human operator. [1] Scripting languages are usually interpreted at runtime rather than compiled.
A scripting language’s primitives are usually elementary tasks or API calls [clarification needed] , and the scripting language allows them to be combined into more programs. Environments that can be automated through scripting include application software, text editors, web pages, operating system shells, embedded systems, and computer games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, it is also known as an extension language. Scripting languages are also sometimes referred to as very high-level programming languages, as they sometimes operate at a high level of abstraction, or as control languages, particularly for job control languages on mainframes.
Change scripting language via terminal
First, we can check which scripting languages are supported in the system.
It can be found that there are actually many options besides bash.
Then, if we change zsh to bash, we can use the chsh command.
We can see that the original terminal displays zsh:
After reopening, it will be displayed as bash.
Of course, in addition to operating in the terminal, we can also replace bash in the setting interface.
Use the system preferences to change the scripting language
click apple icon in the upper right corner > System Preferences > Users & Groups > Click the lock to make changes > Right click on the account > Advances Options > switch login shell。
This way can also switch the default scripting language.
The above is a simple tutorial about how to change zsh to bash in terminal on Mac OS.
Источник