Kali Linux: Creating An Executable Script File

C. Oscar Lawshea
BitWise Tech Tips
Published in
3 min readJun 7, 2024

Creating a script file in the terminal in Kali Linux involves several steps, typically using text editors like nano, vi, or vim, and setting the necessary permissions. Here's a step-by-step guide to creating and running a basic shell script:

Open the Terminal:

  • You can open the terminal by clicking on the terminal icon or by pressing Ctrl + Alt + T.

Create a New Script File:

  • Use a text editor to create a new file. Here, we’ll use nano for simplicity. You can replace nano with vi or vim if you prefer those editors.

This command opens the nano editor with a new file named myscript.sh.

Write Your Script:

  • In the nano editor, you can write your shell script. For example, you can start with a simple script that prints "Hello, World!":
  • The #!/bin/bash line is called a shebang, and it tells the system that this script should be run using the Bash shell.

Save the Script and Exit the Editor:

  • In nano, save the file by pressing Ctrl + O (then press Enter to confirm the filename), and exit by pressing Ctrl + X.

Make the Script Executable:

  • Before running the script, you need to make it executable. Use the chmod command to change the file permissions:

Run the Script:

  • Now you can run your script by typing:
  • You should see the output:

Example: Creating and Running a Script

Here’s a quick summary of the commands in sequence:

By following these steps, you can create, edit, and execute a script file in the terminal on Kali Linux.

--

--

C. Oscar Lawshea
BitWise Tech Tips

I enjoy all science, and learning new tech skills. When I'm not blogging or tinkering with computers; I'm video/pc gaming, watching movies or being a gym bro.