Simple Linux Script

a minute read

Linux_logo_errorbits.com

First Linux Script

In this first script I will show you all the details and preparations that you will need to do prior creating an running your first Linux script. I will use VIM text editor (see the tutorial in the link), but you can use any editor that you might like.

Go to the folder in which you want to create the file for the script and type:

vim test.sh

The editor will create a new file called test.sh (if the file already exist, it will be opened for editing), then input the following commands in the file:

#!/bin/sh
echo “This is my first Linux script”
echo “I will learn more advanced Linux scripts…”
echo “… but a little bit later”

Save your script and exit editor.

Make sure that your file is allowed to run by running chmod command (see the permissions tutorials: File permissions in Linux and Permissions in Linux: Octal/Absolute mode):

chmod +x test.sh

Run the script file with:

./test.sh

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

Related Posts:

To execute a shell script on Linux, you need to follow these steps:Open a terminal: Launch the terminal application on your Linux system. You can usually find it in the applications menu or by using the keyboard shortcut Ctrl+Alt+T. Navigate to the script'...
To pass a seconds variable from bash to Perl, you can use command line arguments. In your bash script, you can call the Perl script and pass the seconds variable as an argument. For example:Bash script: #!/bin/bash seconds=60 perl script.pl $seconds Perl scri...
To install Golang in Kali Linux, you can follow these steps:Open the terminal on your Kali Linux system. Download the latest stable version of Golang from the official website. You can use the wget command to download it directly from the terminal. For example...
To execute a Groovy script from a Jenkins pipeline, you can use the built-in script step in the pipeline. First, define your Groovy script within a variable or directly within the script block. Next, use the script step to run the Groovy script by passing the ...
To create a link to a script on Linux, you can use the ln command.The general syntax for creating a link is: ln -s <source_file> <destination_link> Here, <source_file> represents the path to the script you want to link, and <destination_li...
To run multiple instances of a Powershell script, you can open multiple Powershell windows and execute the script in each window. Alternatively, you can use the Start-Process cmdlet within your Powershell script to start new instances of the script. By adding ...