Exercise 1: Understanding Command Syntax
- Use the
ls
command to list the files in your current directory. - Now modify the behavior of the
ls
command by using the-l
option. What differences do you notice in the output? - Use the
ls
command with the-l
option and/etc
as the target argument. What does the output display?
Exercise 2: Executing Commands
- Define an alias for the
ls -l
command asll
. Use thell
command to list the files in your current directory. What does the output display? - Use the
type
command to determine ifls
is an internal or external command. - Now use the
type
command to determine ifcd
is an internal or external command. What differences do you notice?
Exercise 3: The $PATH Variable
- Use the
echo
command to display the contents of the$PATH
variable. What directories are listed in the$PATH
variable? - Create a simple bash script named
myscript.sh
in your current directory with the following content:
!/bin/bash
echo “Hello, world!”
Make the script executable with the chmod
command:
chmod +x myscript.sh
- Try to run your script with the command
myscript.sh
. What happens? - Now try to run your script with the command
./myscript.sh
. What does the output display? Why is the output different from the previous step?