Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to source the .bashrc file inside .bash_profile.
Linux CLI
if [ -f ~/.bashrc ]; then [1] ~/.bashrc fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not valid bash commands for sourcing files.
✗ Incorrect
The 'source' command reads and executes commands from the specified file in the current shell.
2fill in blank
mediumComplete the code to check if the shell is a login shell in .bash_profile.
Linux CLI
case $- in *[1]*) echo "Login shell" ;; esac
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' which indicates interactive shell, not login shell.
✗ Incorrect
The 'l' option in the shell flags indicates a login shell.
3fill in blank
hardFix the error in the .bashrc snippet to export a variable only if not already set.
Linux CLI
if [ -z "${MY_VAR}" ]; then export MY_VAR=[1] fi
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string causes syntax errors or unexpected behavior.
✗ Incorrect
Quotes are needed around the string to assign it correctly as a value.
4fill in blank
hardComplete the code to append a directory to PATH only if it is not already included.
Linux CLI
case ":$PATH:" in *":[1]:"* ;; * PATH=$PATH:"/my/custom/dir" ;; esac
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separator like ';' which is for Windows PATH.
✗ Incorrect
The code checks if '/my/custom/dir' is in PATH and appends it with ':' separator if not.
5fill in blank
hardFill all three blanks to create an alias in .bashrc that lists files with details and colors.
Linux CLI
alias ll='ls [1] [2] [3]'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up option order or missing '--color=auto' for colors.
✗ Incorrect
The alias 'll' commonly uses '-l' for long listing, '-a' for all files, and '--color=auto' for colors.