What can you do if you get an invalid command error when trying to execute a copied script?

Prepare for the LPI Linux Essentials Exam. Study with flashcards and multiple choice questions, each with hints and explanations. Get exam-ready!

When encountering an "invalid command" error while attempting to execute a copied script, it is essential to ensure that the command you are trying to run is correctly formatted and that the script is in a location where the shell can find it.

Typing out the full path to the executable is a common solution, as it instructs the shell exactly where to locate the script. If you have copied a script to a directory and the directory is not included in the system's PATH environment variable, the shell will not recognize it just by its name, leading to the invalid command error.

Additionally, adding ./ before the filename indicates that the script is located in the current directory. This is particularly useful since the current directory is usually not included in the PATH for security reasons. By prefacing the script with ./, you inform the shell that it should look for the file in the current directory, allowing it to execute as intended.

Therefore, both of these actions are valid solutions to resolve the issue of an invalid command, which is why the correct answer is a combination of both typing out the full path and adding ./ before the filename.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy