bash is a standard Linux shell. You can use bash to execute Linux commands.
# Execute Linux command with bash ls
Check environment variables
Let's check the environment variables. You can check it with the env command.
When combined with grep, you can retrieve only the environment variables you need.
# Get only those that contain PATH env | grep PATH
Set environment variables
Use the export command to set environment variables.
bash configuration file
The bash configuration file is ".bashrc" in your home directory.
There is also a special config file called ".bash_profile", but use ".bashrc" for normal configs.
If you write the above environment variable settings in ".bashrc", they can be set automatically when the shell is loaded.
bash shell script
Let's create a bash shell script. This is useful when executing frequently used Linux commands.
Suppose you save the following script as "myecho".
#!/bin/bash echo 'Hello'
Save this script and change the permissions to 755 with the chmod command so you can run it
chmod 755 myecho
Shebang is "#!/bin/bash".
What kind of shell scripts are there?
Bash is the standard shell script on Linux, but there are other shell scripts such as csh, ksh, and zsh.
Shell scripts are like dialects, and each Linux OS has a different standard shell.