What Does a Bash Startup Script Mean?
Basically, startup files are those files that run initially when a system is being booted up or when a user is trying to run a script/program. Well, this basic definition is not different from what bash startup script actually means. So, what does it mean?
Here you will find out:
- what bash startup files are
- about an interactive bash login shell and interactive non-login shell
- whether bash can be started non-interactively or not
- when DiskInternals can help you
Are you ready? Let's read!
What are bash startup files?
Simply, bash startup files are those files utilized by the shell program to create a working environment for Linux users to run shell/bash scripts. The shell program makes use of a variety of startup files, and each file is unique. Thus, the bash startup files can affect login and interactive environments. The shell reads the files stored in the /etc directory to define the global settings, and if there’s a corresponding file in your home directory, it can rewrite the global settings.
How does bash decide which files to read at startup?
Bash follows two conditions to decide the files to read at startup. The first condition is if the shell’s standard streams are connected to a terminal, which implies that the shell is interactive. This condition always comes out true in most cases; however, when you run Bash with the “-c” flag, this condition may come out false.
The second condition is when your shell is a login shell. When bash processes start with the "-" or "--login" flags, they act as login shells.
Find out about an interactive bash login shell
Put simply, if you log in using /bin/login, it means you start to use an interactive bash login shell. When you call up bash (either as an interactive login shell or non-interactive shell with the --login option), this is what happens: bash will read and run commands in the /etc/profile folder. Also, Bash looks for commands in ~/.bash_profile, ~/.bash_login, and ~/.profile folders. Once Bash detects any of these folders/files, it runs the commands in there.
What is an interactive non-login shell?
[prompt]$/bin/bash or /bin/su command signal the start of an interactive non-login shell. If you're running a GUI environment, xterm or console can be used to start an interactive non-login shell. Here’s how a non-login shell starts up:
The file ~/.bashrc is read by the shell for startup configuration commands.
How bash can be started non-interactively
A shell is non-interactive because it works if a parent shell is already running in the environment. Thus, the non-interactive shell is just used to process a script without having to wait for instructions from the user. It copies instructions from the already running parent shell. A non-interactive shell that is started with “–login” will try to read and run commands from the login shell startup files.
Using Linux Reader
There are times when you may want to access your Linux files saved on your dual-boot PC, but you're logged onto Windows. Well, it is practically impossible for Windows OS to read EXT4 partitions. But if you use DiskInternals Linux Reader, you can easily access all your Linux files.
This software is an intuitive freeware program designed to help virtual machine and dual-boot users. Interestingly, DiskInternals Linux Reader features a recognizable and easy-to-navigate interface.