MODULE 11- Basic Scripting Flashcards
Which file type contains a series of shell commands that can be executed in sequence?
Shell script
What is the purpose of using a shell script instead of typing commands manually each time?
To automate repetitive tasks, ensure consistency, and save time
Which error occurs if you try to run a script directly without execute permissions?
Permission denied
Which command is used to run a shell script by passing it as an argument to the shell?
sh scriptname.sh
What command do you use to make a script executable?
chmod +x scriptname.sh
Why is ./ used before a script name when running it directly?
Because the current directory is usually not in the $PATH, so ./ specifies the current location
Which line at the beginning of a script tells the system to run the script using the /bin/sh shell?
!/bin/sh
What does the command ./test.sh do after the script is made executable?
Runs the script directly from the current directory
What is the name given to the #! characters at the beginning of a script file?
Shebang (or crunchbang)
Which two shells are commonly used in shebang lines for traditional shell scripts?
/bin/sh and /bin/bash
Which two text editors are mentioned in the LPI Essentials syllabus for editing shell scripts?
nano and vi (or vim)
What command opens a file named test.sh in the nano editor?
nano test.sh
Which text editor is recommended for beginners due to its simplicity?
nano
What is the purpose of the echo -n command in a script?
Prints text without adding a newline at the end
This key combination exits nano and prompts you to save if the file was modified.
→ Ctrl + X
Which text editor is more powerful but has a steep learning curve?
vi or its improved version, vim
Which command prints the current system date and time in a shell script?
date
This key combination saves the current file in nano without exiting.
→ Ctrl + O
This key combination cuts the current line or selected text into the copy buffer.
→ Ctrl + K
This key combination begins a text search within the open file.
→ Ctrl + W
This key combination pastes the content from the copy buffer at the cursor’s position.
→ Ctrl + U
This key sequence lets you search and then replace text in the document.
→ Ctrl + W, then Ctrl + R
This key combination opens the nano help menu listing all available commands.
→ Ctrl + G
These key combinations let you page up and down in the file one screen at a time.
→ Ctrl + Y (up), Ctrl + V (down)