In this post we’re going set PowerShell as your default Linux shell.
What is a shell?
In Linux systems you’re given options, tons of options, you can set, reconfigure, add/remove almost anything that you want. And one of those options is your shell. The shell is the thing that you interact with when you’re typing commands at the command line. Different shells have different behaviors and characteristics. It’s a very personal choice. For ages I’ve been a fan of bash.
PowerShell is…a shell!
One thing that people seem to forget about PowerShell is that it’s…a shell not just a scripting language! So we can use it as our primary command line interface to interact with our system if we choose. This is the key point as to why this is so significant, one shell…many platforms. Don’t forget Microsoft brought bash to Windows too ;)
Changing Your Default Shell
In this post I’m going to show you how to change your default shell on your Linux system. It’s a pretty simple change, Linux systems of course give you several options, chsh is one of them.
If you want to use cash you’re going to need to add /usr/bin/powershell to the list of shells in /etc/shells…so let’s crack open that file and add that line. /etc/shells is a protected file, so you’ll need to elevate your privileges with vi…
sudo vi /etc/shells
Here’s the content of my /etc/shells on a RHEL 7.2after making the edit.
chsh -s /usr/bin/powershell
mbp:~ aen$ ssh email@example.com
Last login: Sat Aug 20 11:42:23 2016 from 172.16.94.1
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
What Just Happened?
PS /home/aen> Get-Content /etc/passwd
You can see for the user psdemo the shell is now /usr/bin/powershell. Our demo user’s shell is set to /bin/bash.
If you’re up for it you can edit /etc/passwd directly, to do that you’ll need super user rights. Which you may or may not have. Using chsh you won’t need super user rights. It uses a concept called setuid which allows a user to execute a command with escalated privileges.