How can I change the Session Manager shell to bash on EC2 Linux instances?

3 minute read

I want to change the Session Manager default shell on my Amazon Elastic Compute Cloud (Amazon EC2) Linux instance. How can I do that?

Short description

Session Manager sessions on Amazon EC2 Linux instances use the Bourne shell (sh) by default. However, bash is the default shell in major Linux distributions. If you’re more comfortable using bash than sh, you can change the default Session Manager shell to bash using configurable shell profiles. Shell profiles allow you to customize preferences within sessions when you use Session Manager, including:

  • Shell preferences
  • Environment variables
  • Working directories
  • Running multiple commands when a session starts

You can enable configurable shell profiles using the Systems Manager console or the AWS Command Line Interface (AWS CLI).



To enable shell profiles, you must use SSM Agent version or later. Check the SSM Agent version number on your instance. If necessary, update SSM Agent. For more information, see Automating updates to SSM Agent.

To see the available shells on the instance, run the following command:

$ sudo cat /etc/shells

Note: You can use any of the shells returned using this command.

Enable configurable shell profiles (console)

To enable configurable shell profiles and change the shell to bash using the Systems Manager console, follow these steps:

1.    Open the Systems manager console, and then choose Session Manager from the navigation pane.

2.    Choose the Preferences tab, and then choose Edit.

3.    For "linux" under "shellProfile", enter the following:


4.    Choose Save.

Enable configurable shell profiles (AWS CLI)

Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.

For instructions to enable configurable shell profiles and change the shell to bash using the AWS CLI, see Create Session Manager preferences (command line).

Other shell profile configuration options

By default, Session Manager starts in the “/usr/bin” directory. You can add a command to your shell profile to change the /usr directory on Linux instances. For example:

cd /home/ec2-user

You can also use the shell profile to load specific environment variables, or to run a script at the start of the session. For example, to add the PYTHONPATH environment variable, add the following command to your shell profile:

export PYTHONPATH=/usr/lib/python2.7

When you are logged in, you can run the following command to verify that the environment variable is correctly set:

$ sudo env

Related information

Enable configurable shell profiles

Grant or deny user permissions to update Session Manager preferences Specify an idle session timeout value

AWS OFFICIALUpdated 3 years ago