Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,207,518 members, 7,999,314 topics. Date: Monday, 11 November 2024 at 12:56 AM

Bash/shell Scripting In A Unix/linux Environment - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Bash/shell Scripting In A Unix/linux Environment (7358 Views)

PHP Or Python For Server-side Scripting / I Need Who Will Teach Me Linux And Shell Scripting / Which Programming Language Was Used For Nairaland Server-side Scripting? (2) (3) (4)

(1) (2) (3) (4) (Reply) (Go Down)

Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 10:58pm On Oct 03, 2015
Greetings fellow Denizens of Nigeria. I don't know if this has been started yet, but I wanted to go ahead and start a shell scripting thread. I wanted to know if anyone else was interested. Thanks!
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 12:13am On Oct 04, 2015
Well i will be but mehn shell is a bit*c*h carry on bro.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 6:26am On Oct 04, 2015
I'm following...
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 5:07pm On Oct 04, 2015
Ok I'll do some updates soon.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 7:57am On Oct 05, 2015
Well I guess I'll do my first post.

Linux is an operating system (much like Windows OS and the UNIX-derived Mac OS X). Most people have never used a flavour of Linux/UNIX before, but there are several different Linux distributions (Ubuntu, Redhat, Kali Linux, etc.). Most of you are probably unaware that you use a version of Linux in your pocket (Android OS).

Enough of that. I'm going to show and demonstrate some Linux commands to you guys before we get into scripting.

The scripting shell that will be discussed in this thread is Bash (Bourne Again Shell) on most Linux Distros, it's the default Shell. Though, there are various shells.

By default when at the command line, you are in your home directory. Often, the home directory can also be denoted with a '~'.

e.g.

PulloHamidou@Ubuntu:$ ls ~

Documents Videos Downloads Files

by utilising the ls command (which stands for list) I am listing my home directory. Alternatively, that home directory would be /home/PulloHamidou, but I love typing short hand and would much rather use ~.

This is going to be something difficult to teach. So please bare with me, I will continue to add more to this thread. I'm just thinking of a good starting point.
Re: Bash/shell Scripting In A Unix/linux Environment by Funjosh(m): 8:11am On Oct 05, 2015
Fulaman198:
Well I guess I'll do my first post.

Linux is an operating system (much like Windows OS and the UNIX-derived Mac OS X). Most people have never used a flavour of Linux/UNIX before, but there are several different Linux distributions (Ubuntu, Redhat, Kali Linux, etc.). Most of you are probably unaware that you use a version of Linux in your pocket (Android OS).

Enough of that. I'm going to show and demonstrate some Linux commands to you guys before we get into scripting.

The scripting shell that will be discussed in this thread is Bash (Bourne Again Shell) on most Linux Distros, it's the default Shell. Though, there are various shells.

By default when at the command line, you are in your home directory. Often, the home directory can also be denoted with a '~'.

e.g.

PulloHamidou@Ubuntu:$ ls ~

Documents Videos Downloads Files

by utilising the ls command (which stands for list) I am listing my home directory. Alternatively, that home directory would be /home/PulloHamidou, but I love typing short hand and would much rather use ~.

This is going to be something difficult to teach. So please bare with me, I will continue to add more to this thread. I'm just thinking of a good starting point.

The first time I came across Linux/Ubuntu was during my undergraduate day in FUTA when we have to run Ferret on it. I love it.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 8:30am On Oct 05, 2015
Funjosh:


The first time I came across Linux/Ubuntu was during my undergraduate day in FUTA when we have to run Ferret on it. I love it.

Linux is a great operating system. I'm surprised that it is often ignored for Windows and Mac OS X.
Re: Bash/shell Scripting In A Unix/linux Environment by Funjosh(m): 8:39am On Oct 05, 2015
Fulaman198:


Linux is a great operating system. I'm surprised that it is often ignored for Windows and Mac OS X.


Yes it is. But you know it doesn't look much attractive like Windows. Was made to know that it is also free from virus.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 2:30pm On Oct 06, 2015
Funjosh:



Yes it is. But you know it doesn't look much attractive like Windows. Was made to know that it is also free from virus.
Yea,it is not easily attacked by virus due to its programmed nature.It's preferable in a security circle because of this feature and many more.

It doesn't gain wide popularity like winfows o.s because you've to know the commands you're going to use to interact with it whereas windows has made everything easier for users by means of icons and other shortcuts.
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 4:37pm On Oct 06, 2015
baba11:

Yea,it is not easily attacked by virus due to its programmed nature.It's preferable in a security circle because of this feature and many more.

It doesn't gain wide popularity like winfows o.s because you've to know the commands you're going to use to interact with it whereas windows has made everything easier for users by means of icons and other shortcuts.

I think Ubuntu is easy to use from a GUI point of view.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 7:12pm On Oct 06, 2015
Fulaman198:


I think Ubuntu is easy to use from a GUI point of view.
Then I'll need to install this on my second partition because there's no way it can run on windows 8

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 7:14pm On Oct 06, 2015
baba11:

Then I'll need to install this on my second partition because there's no way it can run on windows 8

Ubuntu is very friendly on resources. It's very nice and if you are an avid Windows user, getting used to Ubuntu will be extremely easy. You don't have to worry about the command line terminal (though you could use it). I feel more at home at the command line. I love the command line ROFLLL.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 7:25pm On Oct 06, 2015
Fulaman198:


Ubuntu is very friendly on resources. It's very nice and if you are an avid Windows user, getting used to Ubuntu will be extremely easy. You don't have to worry about the command line terminal (though you could use it). I feel more at home at the command line. I love the command line ROFLLL.
Then let the lecture continues.... grin
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 7:32pm On Oct 06, 2015
baba11:

Then let the lecture continues.... grin

You are right, I was not at all happy with myself in the first post. It was a disaster. I just don't know where to begin for people who have never touched the command line before. I'm thinking though.

What I would like people to familiarize themselves with I guess are the following commands before we go any further.

ls - List directories

rm - Remove a file or directory

mv - rename or move a file or directory

cp - copy a file or directory

mkdir - create a directory

touch - create a file

rmdir - removes an empty directory (I prefer using rm command as the directory doesn't have to be empty)

cat - read the contents of a file or concatenate a file (used on text mainly)

man - Online manual for linux commands



At the command line these all have what they call different options as well.

An example of an option is typically something associated with a hyphen.

e.g. ls -la

Means list the directories. The 'a' option means list all directories whether they are hidden or not, and the 'l' option lists more details about the files or directories that are listed.

I don't want to go more overboard because there are those who have never touched the command line before. Before we can get into actual Bash scripting, people need to know the basics first.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 7:39pm On Oct 06, 2015
Fulaman198:


You are right, I was not at all happy with myself in the first post. It was a disaster. I just don't know where to begin for people who have never touched the command line before. I'm thinking though.

What I would like people to familiarize themselves with I guess are the following commands before we go any further.

ls - List directories

rm - Remove a file or directory

mv - rename or move a file or directory

cp - copy a file or directory

mkdir - create a directory

touch - create a file

rmdir - removes an empty directory (I prefer using rm command as the directory doesn't have to be empty)

cat - read the contents of a file or concatenate a file (used on text mainly)

man - Online manual for linux commands



At the command line these all have what they call different options as well.

An example of an option is typically something associated with a hyphen.

e.g. ls -la

Means list the directories. The 'a' option means list all directories whether they are hidden or not, and the 'l' option lists more details about the files or directories that are listed.

I don't want to go more overboard because there are those who have never touched the command line before. Before we can get into actual Bash scripting, people need to know the basics first.
OK...copy that..
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 9:36am On Oct 07, 2015
Fulaman198:


Linux is a great operating system. I'm surprised that it is often ignored for Windows and Mac OS X.

No its not ignored, just that this part of the world, DOESNT use linux.
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 9:39am On Oct 07, 2015
baba11:

Then I'll need to install this on my second partition because there's no way it can run on windows 8

Use a virtual environment like Oracle Virtual box.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 9:57am On Oct 07, 2015
gimakon:


Use a virtual environment like Oracle Virtual box.
How should I go about this?
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 10:53am On Oct 07, 2015
baba11:

How should I go about this?

Go to www.google.com and download Oracle Virtual box (that's what I use) am on mobile hence I cannot make a screen shot for you, but follow these steps

Step 1: Choose System Type. - After install VirtualBox, click New. ...
Step 2: Select The Amount of RAM. - Here select the amount of RAM For example: 1024 MB = 1 GB 2048 MB = 2 GB.
Step 3: Hard Disk Setting. ...
Step 4: Choose Liunx ISO File. ...
Step 5: Install Linux and Make Account. ...
Step 6: Congratulations.

Better still if you still do not understand, follow the YouTube link below


https://www.youtube.com/watch?v=QkJmahizwO4

Happy Linuxing!
Heil Linus Trovalds.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 2:09pm On Oct 07, 2015
gimakon:


Go to www.google.com and download Oracle Virtual box (that's what I use) am on mobile hence I cannot make a screen shot for you, but follow these steps

Step 1: Choose System Type. - After install VirtualBox, click New. ...
Step 2: Select The Amount of RAM. - Here select the amount of RAM For example: 1024 MB = 1 GB 2048 MB = 2 GB.
Step 3: Hard Disk Setting. ...
Step 4: Choose Liunx ISO File. ...
Step 5: Install Linux and Make Account. ...
Step 6: Congratulations.

Better still if you still do not understand, follow the YouTube link below


https://www.youtube.com/watch?v=QkJmahizwO4

Happy Linuxing!
Heil Linus Trovalds.

Thanks...I'll give you the feedback after the installation cool
Re: Bash/shell Scripting In A Unix/linux Environment by Baroba(m): 7:58pm On Oct 07, 2015
Nice thread, useful link for those interested in basic command lines...
http://cli.learncodethehardway.org/book/
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 8:26pm On Oct 07, 2015
And for the records, I have done something in bash some years back

#!/usr/bin/bash

Don't Wonna go back to that
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 10:46pm On Oct 07, 2015
gimakon:
And for the records, I have done something in bash some years back

#!/usr/bin/bash

Don't Wonna go back to that

That statement '#!/usr/bin/bash or alternatively #!/bin/bash' informs and instructs the kernel to use Bash as its shell for processing the instructions in the script. We'll get to that. I'm thinking about how to pursue this thread.
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 1:39pm On Oct 08, 2015
I'm getting my pen to put everything down....pls continue
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 1:45pm On Oct 08, 2015
Fulaman198:


That statement '#!/usr/bin/bash or alternatively #!/bin/bash' informs and instructs the kernel to use Bash as its shell for processing the instructions in the script. We'll get to that. I'm thinking about how to pursue this thread.

You want me to start? grin

Don't mind me, you can use Google to gather tutorials chief
Re: Bash/shell Scripting In A Unix/linux Environment by DanIndia(m): 5:00pm On Oct 09, 2015
Go on, Fulaman198, I'm a follower now smiley

I got my LPIC-1 OCG a couple days ago. I'm still figuring a way to integrate Linux study time with my day-to-day stuff. That being said, the book is a great deal.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 9:22am On Oct 11, 2015
I'm still following....
Re: Bash/shell Scripting In A Unix/linux Environment by orobogenius: 11:16am On Oct 11, 2015
Linux is by far the best OS for those of us that do not have a phobia for the command line, you feel at home, you are in control. I don't care for the so-called romantic interface windows seems to project. OP please continue, it's a nice feeling to know you're not alone.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Borwe: 12:12pm On Oct 11, 2015
For those without Linux PC, or even a PC, use your android phone with installing the app terminal emulator. Acts like linux terminal
Re: Bash/shell Scripting In A Unix/linux Environment by Supermiy: 1:22pm On Oct 11, 2015
Borwe:
For those without Linux PC, or even a PC, use your android phone with installing the app terminal emulator. Acts like linux terminal
their Is Android Version Of Linux..Runs Ubuntu But Its Recommend For Pros Only..I Haven't Tried It My Self Tho
Re: Bash/shell Scripting In A Unix/linux Environment by Supermiy: 1:27pm On Oct 11, 2015
baba11:

Yea,it is not easily attacked by virus due to its programmed nature.It's preferable in a security circle because of this feature and many more.

It doesn't gain wide popularity like winfows o.s because you've to know the commands you're going to use to interact with it whereas windows has made everything easier for users by means of icons and other shortcuts.
i Almost Would Have Totally Agreed..We Have GUIs Too But Na Terminal Sweet Pass!
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 2:36pm On Oct 11, 2015
Supermiy:
i Almost Would Have Totally Agreed..We Have GUIs Too But Na Terminal Sweet Pass!
Graphics user interface as how?

(1) (2) (3) (4) (Reply)

Converting Picture To Byte Array(blob) And Back To Picture / Uber Vs Taxify - Which Do You Prefer? / My Journey To Programming

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 52
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.