温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.muo.com/linux-login-shells-explained/
点击访问原文链接

What Is a Login Shell in Linux?

What Is a Login Shell in Linux? Menu Sign in now Close PC & Mobile Submenu Windows2 Linux Android Apple Technical Submenu Tech Explained Security Software Submenu Productivity Internet Creative Screen Submenu Entertainment Streaming Home Submenu Smart Home Home News Sign in Newsletter Menu Follow Followed Like More Action Sign in now Productivity Android Smart TVs Networking Windows 11 Entertainment Close
What Is a Login Shell in Linux? No attribution needed -- Pexels
URL: https://www.pexels.com/photo/close-up-shot-of-keyboard-buttons-2882566/ By  David Delony Published Aug 20, 2022, 6:00 PM EDT David is a freelance writer based in the Pacific Northwest, but originally hailing from the Bay Area.  A journalist by training who has been writing professionally since 2009, he discovered the power of Unix-like operating systems and the command-line interface while learning how to edit video on macOS. It also helped that he'd originally cut his computing teeth on MS-DOS in the '90s.

He has been using Linux regularly in some form since 2006. David has been able to combine his passion for computing and writing in his career as a freelance writer. His writing has appeared in Techopedia, TMCnet, and Walyou, among others.

David holds a B.A. in communication from California State University, East Bay. A dedicated lifelong learner, he's been using Linux-based CAS tools like SymPy and Sage on Linux to make sure he remembers what he learned in his math classes and maybe even pick up a few new concepts along the way. Linux and open source have allowed him to explore advanced topics like calculus and linear algebra more easily than he could with pencil and paper. Sign in to your MakeUseOf account

You might use the Linux shell every day, but how you use it determines a lot about its behavior. You might have heard about the difference between a login shell and a non-login shell. And while it may not come off as obvious at first, there are several differences between the two shell types.

Here's everything you need to know about login shells on Linux.

What Is a Login Shell?

A login shell is exactly that: a shell that launches when you directly log in to the Linux machine. When you log into your system from a virtual console or over SSH, the shell that starts is a login shell.

By contrast, if you start up a terminal window, that shell session is typically not a login shell. The same goes when you launch a subshell by typing the name of the shell at the command line. This shell is just an interactive shell.

The key difference between the two is in the behavior of the shell. The shell will often only read certain files on startup. Bash will read the /etc/profile, then the .bash_profile, .bash_login, and .profile files in your home directory only if it's invoked as a login shell.

How to Tell if You’re Using a Login Shell

It's easy to see if you're running a login shell or not. If you launched your shell from the desktop terminal application, you most likely aren't, unless you're in another terminal environment like WSL or the macOS terminal.

Screenshot by David Delony -- own screenshot

You can check if you're running a login shell with this command;

echo $0

If you're using a login shell, you'll see the name of the shell preceded by a hyphen (-). If not, you'll just see the name of the shell.

Setting Your Login Shell on Linux

To set your login shell, use the chsh command. You can set your login shell to the absolute path of any shell listed in /etc/shells.

To start any shell as a login shell, you can usually use a command-line option. For example, to start Bash as a login shell:

bash --login

If you're using a Linux desktop, you can often specify which command is run when you open a terminal window. If you want your shell to run as a login shell, you can put that option there.

Now You Know About Login Shells

You should now understand what login shells are. Launching your shell, either directly from the console or from a terminal window, will determine how it will behave.

If you're new to Linux, you may wonder which shell is best. You can stick with the default Bash, or you can explore the special features offered by alternate shells like Fish or Zsh.

Close
Recommended Which Linux Shell Is Best? 5 Common Shells Compared The June Android security update is one of the biggest this year and most users haven't installed it yet This underrated Claude Code mode makes it a real IDE rival This is the only version of Windows 11 I install on new PCs now Join Our Team Our Audience About Us Press & Events Media Coverage Contact Us Follow Us Advertising Careers Terms Privacy Policies MakeUseOf is part of the Valnet Publishing Group Copyright © 2026 Valnet Inc.

What Is a Login Shell in Linux?,AI智能索引,全网链接索引,智能导航,网页索引

    Linux launches a login shell when a user logs in to their account. So what are login shells, and how can you find out if you