Identifying Your Current Shell
To check which shell you are currently using, execute the following command (note the uppercase letters in the variable name):Changing Your Default Shell
To change your default shell, use thechsh command. You will be prompted for your password and then to provide the new shell value. Remember, you must open a new terminal session for the changes to take effect.
After switching shells, consider exploring Bash-specific features to take full advantage of its functionalities.
Command Auto-Completion
Bash provides command auto-completion that completes commands, filenames, and directory names when you press the Tab key. This feature can significantly improve efficiency by saving time and reducing typing errors when navigating the filesystem. For example:Aliases and Command History
Bash allows you to create aliases to simplify frequent commands. For instance, you can create an alias nameddt for the date command to quickly display the current date. Additionally, you can use the history command to view a list of previously executed commands, making it easier to reuse them.
To verify the shell in use, simply run:
$SHELL variable stores the type of shell you are using. When printing an environment variable’s value in Bash, the variable name should be prefixed with a dollar sign.
Environment Variables
Environment variables provide information about your login session to the shell. To view all active environment variables, use theenv command:
office), use the export command:
export, the variable’s scope remains limited to the current shell only. To ensure these variables persist after logging out or rebooting, add them to your .profile or .pam_environment file.
When executing an external command, Bash utilizes the PATH variable to locate the appropriate executable. To display the directories listed in your PATH, run:
PATH, use the which command. For instance, attempting to locate an application like OBS Studio that hasn’t been added to your PATH might result in a “command not found” error.
To add a new directory (e.g., the OBS Studio path /opt/OBS/bin) to your PATH, execute:
which command to verify that the new directory is recognized.
Customizing the Bash Prompt
The Bash prompt, typically seen as[~]$ when you log in, can be customized to display useful system and user information. This is particularly beneficial when managing multiple systems, as the prompt can include details like username, hostname, and current working directory.
For example, a customized prompt indicating the host might look like:
PS1 environment variable. To view its current setting, run:
\W displays the current working directory. You can change the prompt by updating PS1. To set it to display “ubuntu-server:” followed by a colon, use:
PS1 with special backslash-escaped characters:
This concludes chapter one of the Quick Start Guide. Bob encourages exploring Bash’s features further through hands-on exercises. Enjoy diving deeper into the Bash shell!