Hardware

How to create your first script in linux

Table of contents:

Anonim

Do you have Linux and want to squeeze it by doing something you don't usually do? Do you want to create your first script in Linux ? The truth is that this operating system gives a lot to that. If you study computer science, you will probably end up needing to install Ubuntu many times. And to program it is a wonder. Not long ago we told you how to program in C from Ubuntu. Today we are going to tell you what you need to create your first script and what are the steps to follow (it is very easy).

How to create your first script in Linux

If you dare to create with us your first script in Linux, you will see that it is very easy. Here are the steps to follow:

  • To create your script, the first thing you have to do is choose a text editor. We recommend gedit, it is a quite comfortable text editor. If you are looking for something more professional or advanced, install emacs. Once you have the text editor installed, open it to create a new file. Write the following code:

#! / bin / bash #This is a comment echo "Hello World!"

What do these lines of code mean? First of all we are using / bin / bash, but there are other programming languages ​​that are used in this way like python. The second line, #, is a comment. Comments are necessary to understand the code, because if you pick up a code some time later you may not remember what you were doing, it helps you document what you are programming. On the third line, echo, it will print what is displayed in quotes around the screen.

This hello world is the most basic thing you can do, because it is a simple text string that is displayed on the screen. But you will be able to do more successful things. However, it helps you to know that these are the steps to follow to create your first successful Linux script.

  • Save it with whatever name you want. Remember to give it permissions with the command Chmod 755 filename . Lastly, run the program in console with ./filename

If everything went well, you should be printed on screen in the Hello World command console. We hope the tutorial has served you! This is the most basic thing to start.

Hardware

Editor's choice

Back to top button