loading...

Ubuntu Server 18.04 – Understanding the Linux shell

How to Change the server name on Windows Server 2019

When it comes to the Linux shell, it’s important to understand what exactly this pertains to. We’ve been using the command-line repeatedly throughout the tutorial, but we haven’t yet had any formal discussion about the actual interface through which our commands are entered.

Essentially, we’ve been entering our commands into a command interpreter known as the Bourne-Again Shell, or simply Bash. Bash is just one of many different shells┬áthat you can use to enter commands. There are other options, such as Zsh, Fish, ksh, and so on. Bash is the default command shell for pretty much every Linux distribution in existence. It’s possible there’s a Linux distribution I have yet to try that defaults to another shell, but Bash is definitely the most common. In fact, it’s even available on macOS in its Terminal, and in Windows by installing the Ubuntu plugin. Therefore, by understanding the basics of Bash, your knowledge will be compatible with other distributions and platform. While it’s fun to learn other shells such as Zsh, Bash is definitely the one to focus the most attention on if you’re just starting.

You may wonder, then, where you configure the shell that your user account will use. If you recall from Chapter 2, Managing Users, we looked at the /etc/passwd file. As I’m sure you remember, this file keeps a list of user accounts available on the system. Go ahead and take a look at this file to refresh yourself:

cat /etc/passwd

See the last field in every entry? That’s where we configure which shell is launched when a user logs in or starts a new Terminal session. Unless you’ve already changed it, the entry for your user account should read /bin/bash. You’ll see other variations in this file, such as /bin/false or /usr/sbin/nologin. Setting the user’s shell to one of these will actually prevent them from being able to log in. This is primarily used by system accounts, those that exist to run a task on the system, but we don’t want to allow this user to open a shell to do other things. The /usr/sbin/nologin shell also doesn’t allow the user to log in, but will provide a polite message letting them know.

The shell program itself is responsible for reading the commands you type and having the Linux kernel execute them. Some shells, Bash notably, have additional features, such as history, that are very useful to administrators.

Comments are closed.

loading...