Friday, January 30, 2015

Linux Bash Scripting - Install Script

Though many of you may scrutinize me for the poor structure of the content of my following source code but it's not like I'm gonna lose anything besides my pride as a programmer lol jk. Enough of the non professional text shorthand, let's get to some serious coding here. 

Linux is such a beautiful OS (Operating System for those of you who don't know). Not only does it give you the full reigns of the OS but also the greatest asset of any Linux based distro, The Package Manager! Once I discovered the package manager and it's abilities within its use on the terminal blew my mind when I was first delving into Linux my sophomore year of high school.

Let's begin with the basic structure of the Linux Bash Script.
#! /bash/bin

This is a basic beginning of writing a Linux Bash Script we are almost on our way to writing the finished product. For those of you who are new to this world of Linux and Bash Scripting let me break a few things down for you to make your learning experience that much better. Alright enough suger talk, the #! /bash/bin simply is a system call to the Linux Kernel referencing the commands within the bash/bin library. Over the progress of my programming and this blog we will have special sections specifically explaining the more finer details of the Linux Operating System and navigating it's terminal.

The next part of the script will be to simply add the commands that we need to run the install of the particular software we want to install. Here is some sample code below:

1
2
3
4
#!/bash/bin

echo "Installing software...."
apt-get install vlc ubuntu-restricted-extras //-y if you wanna skip the confirmation


We could simply add -y to the end of the apt-get install vlc ubuntu-restricted-extras and that will continue the installation without having us confirm the installation of the packages but I will leave that up to you guys whether or not you want to implement. Also as another side note I believe that using the sudo option at the beginning of the apt-get command if your not running the script in sudo.

So as your final product you should have this as the final result of this little brief tutorial on creating a Linux Bash Install Script:

1
2
3
4
#!/bash/bin

echo "Installing software...."
apt-get install vlc ubuntu-restricted-extras //-y if you wanna skip the confirmation

No comments:

Post a Comment