Bash Shell Flashcards
Variable and function syntax
FOO=bar VAR2=/home/user/docs function yo() { echo "yo" }
List of all exported shell variables
Command used to allow child sessions to use env vars
- export
- export FOO=bar
- export PATH=$PATH:/home/user/programs
Show environment vars
env
List shell settings or shell vars and funcs for the session
set
set -x/set +x- turn on/off she debugging
set -f -enable file globbing
set +f -disable file globbing
Remove var or function
unset -f yo
unset FOO
Display shell options
Modify shell options
shopt
shopt -s histreedit- set
shopt -u histreedit -unset
Locate an app file listed in $PATH
which bash
Determine if something is a function, file, alias, built-in or keyword
type cd=> function
type type=> built-in
Interactive login shell
/etc/profile=>/etc/profile.d/*
info from /etc/profile.d/ returns back to /etc/profile=>~/.bash_profile or ~/.profile =>~/.bashrc=>/etc/bashrc
Interactive non-login shell
~/.bashrc=>/etc/bashrc
First file read on login session. Sets env vars such as PATH, umask, bash history controls
/etc/profile
Configs of system-wide functions and aliases
/etc/bashrc
Templates of files that are added when an account is created
/etc/skel
Legacy ~/.bash_profile file
~/.bash_login
Set alias
vim ~/.bashrc
alias ll=”ls -la”
source ~/.bashrc or . ~/.bashrc