Skip to content

Instantly share code, notes, and snippets.

@aaabramov
Last active January 13, 2024 01:26
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save aaabramov/0f1d963d788bf411c0629a6bcf20114d to your computer and use it in GitHub Desktop.
Save aaabramov/0f1d963d788bf411c0629a6bcf20114d to your computer and use it in GitHub Desktop.
Installing zsh + oh-my-zsh on Amazon EC2 Amazon Linux 2 AMI. (Prepared in the scope of posting https://aaabramov.medium.com/installing-zsh-oh-my-zsh-on-amazon-ec2-amazon-linux-2-ami-88b5fc83109)
sudo yum update
# Installing ZSH
sudo yum -y install zsh
# Check ZSH has been installed
zsh --version
# Install "util-linux-user" because "chsh" is not available by default
# See https://superuser.com/a/1389273/599050
sudo yum install util-linux-user
# Change default shell for current user, most of the times it would be "ec2-user"
# Or use "sudo chsh -s $(which zsh) $(whoami)" to be sure
chsh -s "$(which zsh)"
# Install oh-my-zsh from https://github.com/ohmyzsh/ohmyzsh#basic-installation
# OPTIONAL
# I recommend you to install the following plugins which make your life easier and more colorful
# Assuming you have git installed
# If not, simply do "sudo yum install git -y"
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
# And then add them to "~/.zshrc" file
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
@johndpope
Copy link

to get this working using ssh - and reconnecting -
https://askubuntu.com/questions/131823/how-to-make-zsh-the-default-shell
I needed to connect to server - and change the
/home/ec2-user/.bashrc
exec zsh

@aaabramov
Copy link
Author

aaabramov commented Nov 4, 2021

to get this working using ssh - and reconnecting - https://askubuntu.com/questions/131823/how-to-make-zsh-the-default-shell I needed to connect to server - and change the /home/ec2-user/.bashrc exec zsh

@johndpope Have you executedchsh -s "$(which zsh)"?

@ChuanyuanLiu
Copy link

Install oh-my-zsh before the optional part from 19 onwards by executing the following command.
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

@tbenavides
Copy link

Ran into an issue with executing chsh but found a post on setting a password for the default user ec2-user.

sudo passwd ec2-user

After setting the password the script ran without error.

@g24swint
Copy link

It looks like Amazon Linux 2 AMI installs zsh shell 5.0.2 by default. Is there a channel that can be used to grab a newer zsh install?

@g24swint
Copy link

@tbenavides - I had a similar issue when a "regular user" was trying to change the shell. I was able to run
sudo usermod --shell $(which zsh) the_user_id
and get it changed for him and we did not have to set a blank password

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment