0
0
Linux CLIscripting~10 mins

.bashrc and .bash_profile in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Aexecute
Brun
Csource
Dcall
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'execute' which are not valid bash commands for sourcing files.
2fill in blank
medium

Complete 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'
Al
Bi
Cx
Ds
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'i' which indicates interactive shell, not login shell.
3fill in blank
hard

Fix 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'
A"default"
B'default'
Cdefault
Ddefault_value
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the string causes syntax errors or unexpected behavior.
4fill in blank
hard

Complete 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'
A/my/custom/dir
B:
C;
D/my/other/dir
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong separator like ';' which is for Windows PATH.
5fill in blank
hard

Fill 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'
A-l
B--color=auto
C-a
D-h
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up option order or missing '--color=auto' for colors.