0
0
Linux CLIscripting~20 mins

Aliases for shortcuts in Linux CLI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Alias Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
Output of alias command
What is the output of the following commands executed in sequence?

alias ll='ls -l' ll
Linux CLI
alias ll='ls -l'
ll
ALists files in short format (names only)
BShows an error: command not found
CLists files in long format (detailed list)
DPrints the string 'ls -l'
Attempts:
2 left
💡 Hint
Remember that alias replaces the command with the shortcut before execution.
📝 Syntax
intermediate
1:00remaining
Correct alias syntax
Which of the following is the correct way to create an alias named 'gs' for 'git status' in bash?
Aalias gs=git status
Balias gs='git status'
Calias 'gs=git status'
Dalias gs:'git status'
Attempts:
2 left
💡 Hint
Alias values must be enclosed in quotes.
🔧 Debug
advanced
2:00remaining
Why does this alias not work?
Given the alias:
alias greet='echo Hello $USER'
What will be the output when you run greet and why?
APrints 'Hello $USER' literally
BPrints 'Hello ' with an empty username
CPrints 'Hello' followed by the current username
DRaises a syntax error
Attempts:
2 left
💡 Hint
Think about when variables inside single quotes get expanded.
🚀 Application
advanced
1:30remaining
Creating a persistent alias
You want to create an alias 'll' for 'ls -la' that works every time you open a terminal. Which file should you add the alias command to?
A~/.profile
B/etc/passwd
C/etc/hosts
D~/.bashrc
Attempts:
2 left
💡 Hint
This file runs every time a new interactive shell starts.
🧠 Conceptual
expert
2:00remaining
Effect of alias in scripts
If you define an alias in your interactive shell, will it be available automatically inside a bash script you run? Why or why not?
ANo, because aliases are not expanded in non-interactive shells by default
BYes, aliases are global and always available
CNo, because scripts run in a different user context
DYes, but only if the script is run with sudo
Attempts:
2 left
💡 Hint
Think about how bash treats interactive vs non-interactive shells.