0
0
Linux CLIscripting~15 mins

which and whereis for commands in Linux CLI - Mini Project: Build & Apply

Choose your learning style9 modes available
Using which and whereis Commands in Linux CLI
📖 Scenario: You are learning how to find the location of commands on a Linux system. This helps you understand where programs are stored and which version will run when you type a command.
🎯 Goal: Build a simple script that uses which and whereis commands to find the locations of specific Linux commands.
📋 What You'll Learn
Use the which command to find the path of a command
Use the whereis command to find all locations related to a command
Print the results clearly
💡 Why This Matters
🌍 Real World
Knowing where commands are located helps you troubleshoot issues and understand your system better.
💼 Career
System administrators and developers often need to find command locations to configure environments or debug problems.
Progress0 / 4 steps
1
Create a variable with the command name
Create a variable called cmd and set it to the string ls.
Linux CLI
Need a hint?

Use cmd="ls" to store the command name.

2
Use which to find the command path
Use the which command with the variable cmd and save the output to a variable called which_path.
Linux CLI
Need a hint?

Use which_path=$(which $cmd) to get the command path.

3
Use whereis to find all related locations
Use the whereis command with the variable cmd and save the output to a variable called whereis_info.
Linux CLI
Need a hint?

Use whereis_info=$(whereis $cmd) to get all locations.

4
Print the results clearly
Print the text Path found by which: followed by the variable which_path, then print Information found by whereis: followed by the variable whereis_info.
Linux CLI
Need a hint?

Use echo to print the variables with descriptive text.