Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,149,973 members, 7,806,830 topics. Date: Wednesday, 24 April 2024 at 02:49 AM

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

Nairaland Forum / Science/Technology / Programming / Bash/shell Scripting In A Unix/linux Environment (6874 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)

Re: Bash/shell Scripting In A Unix/linux Environment by DanIndia(m): 3:16pm On Oct 11, 2015
Ubuntu, Fedora, Kali are all GUI's but you can run them in different modes. Ubuntu is mostly known for its GUI friendliness. You could consider them GUI but Redhat, Suse are more of commandline
baba11:

Graphics user interface as how?

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Supermiy: 5:18pm On Oct 11, 2015
baba11:

Graphics user interface as how?
i Meant Some Programs On Linux Comes With Gui Features But Most Linux Users Are Commandline Gurus
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 5: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

Or they can install Oracle Virtual Box and run Ubuntu as a virtual machine for free....

It will help as I continue the tutorial
Re: Bash/shell Scripting In A Unix/linux Environment by baba11(m): 5:42pm On Oct 11, 2015
Supermiy:
i Meant Some Programs On Linux Comes With Gui Features But Most Linux Users Are Commandline Gurus
Ok
Re: Bash/shell Scripting In A Unix/linux Environment by DanIndia(m): 4:22am On Oct 12, 2015
My default OS is the Ubuntu 15.04 but I don't lab with my home OS. I use a CentOS 7 on Oracle VB.
Fulaman198:


Or they can install Oracle Virtual Box and run Ubuntu as a virtual machine for free....

It will help as I continue the tutorial

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 6:03am On Oct 12, 2015
Love my Linux boxes more than most humans.

Currently having trouble configuring one distro for arcane SendMail and dreaded Wordpress stack without being relayed... angry
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 7:20am On Oct 12, 2015
AAinEqGuinea:
Love my Linux boxes more than most humans.

Currently having trouble configuring one distro for arcane SendMail and dreaded Wordpress stack without being relayed... angry


I believe it should have some issues with the configuration file. Maybe you look inside the .conf file and see if there must be something to toggle off or on
Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 7:30am On Oct 12, 2015
gimakon:


I believe it should have some issues with the configuration file. Maybe you look inside the .conf file and see if there must be something to toggle off or on

Started at .conf..., now looking in .err's, may need to go back to .conf

The emails exit properly but they're not accepted by client server except one so far; Mac's iCloud server

My guess is it's either a DNS issue, outside Linux topic, or host.all/deny config
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 7:31am On Oct 12, 2015
Okay lemme give some slight commands

In Linux we want to move to a directory like Desktop

We say cd Desktop

We want to list all the files and directories we say

ls

We want to know the current user we say whoami

And we want to run an installation without gui, and downloading from your terminal, like we Wonna install chrome, we say things like

Sudo apt install chrome

For updates we say
Sudo apt get updates

Should ask you for root password to do most of that. In some debian Linux, we have some commands like

Dpkg -i

For "de packaging"

Linux has so many commands. And so far is the best for exploits and doing several hacks. grin
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 7:35am On Oct 12, 2015
AAinEqGuinea:


Started at .conf..., now looking in .err's, may need to go back to .conf

The emails exit properly but they're not accepted by client server except one so far; Mac's iCloud server

My guess is it's either a DNS issue, outside Linux topic, or host.all/deny config

Yea, some ISP also have funny ways of blocking sent emails using smtp. Maybe that should also be an issue with it too.
Run the checks. I try from here as well.
Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 8:00am On Oct 12, 2015
gimakon:


Yea, some ISP also have funny ways of blocking sent emails using smtp. Maybe that should also be an issue with it too.
Run the checks. I try from here as well.

Successful entry (mail.log)

Oct 11 23:49:25 debbie sendmail[10122]: t9C4nPKE010122: to=x@icloud.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30486, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t9C4nPot010123 Message accepted for delivery)
Oct 11 23:49:26 debbie sm-mta[10125]: STARTTLS=client, relay=mx3.mail.icloud.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Oct 11 23:49:28 debbie sm-mta[10125]: t9C4nPot010123: to=<x@icloud.com>, ctladdr=<www-data@x.y.name /*FQDN*/> (33/33), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120623, relay=mx3.mail.icloud.com. [17.158.8.61], dsn=2.0.0, stat=Sent (Ok.)

Bad entry

Oct 12 01:41:24 debbie sendmail[10418]: t9C6fO5u010418: to=x@msn.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30222, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t9C6fOhm010419 Message accepted for delivery)
Oct 12 01:41:24 debbie sm-mta[10421]: STARTTLS=client, relay=mx4.hotmail.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-SHA384, bits=256/256
Oct 12 01:41:25 debbie sm-mta[10421]: t9C6fOhm010419: to=<x@msn.com>, ctladdr=<root@x.y.name> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120481, relay=mx4.hotmail.com. [65.55.92.152], dsn=2.0.0, stat=Sent ( <201510120641.t9C6fO5u010418@x.y.name> Queued mail for delivery)

*flushes queue, still nothing is sent

*we see that address is resolving... good sign
*other (non-Apple) addresses have similar messages
*no email is sent
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 8:22am On Oct 12, 2015
AAinEqGuinea:


Successful entry (mail.log)

Oct 11 23:49:25 debbie sendmail[10122]: t9C4nPKE010122: to=x@icloud.com, ctladdr=www-data (33/33), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30486, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t9C4nPot010123 Message accepted for delivery)
Oct 11 23:49:26 debbie sm-mta[10125]: STARTTLS=client, relay=mx3.mail.icloud.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Oct 11 23:49:28 debbie sm-mta[10125]: t9C4nPot010123: to=<x@icloud.com>, ctladdr=<www-data@x.y.name /*FQDN*/> (33/33), delay=00:00:03, xdelay=00:00:03, mailer=esmtp, pri=120623, relay=mx3.mail.icloud.com. [17.158.8.61], dsn=2.0.0, stat=Sent (Ok.)

Bad entry

Oct 12 01:41:24 debbie sendmail[10418]: t9C6fO5u010418: to=x@msn.com, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30222, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t9C6fOhm010419 Message accepted for delivery)
Oct 12 01:41:24 debbie sm-mta[10421]: STARTTLS=client, relay=mx4.hotmail.com., version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-SHA384, bits=256/256
Oct 12 01:41:25 debbie sm-mta[10421]: t9C6fOhm010419: to=<x@msn.com>, ctladdr=<root@x.y.name> (0/0), delay=00:00:01, xdelay=00:00:01, mailer=esmtp, pri=120481, relay=mx4.hotmail.com. [65.55.92.152], dsn=2.0.0, stat=Sent ( <201510120641.t9C6fO5u010418@x.y.name> Queued mail for delivery)

*flushes queue, still nothing is sent

*we see that address is resolving... good sign
*other (non-Apple) addresses have similar messages
*no email is sent


It behaves like the mail is sent, and it doesn't send email? If yes then the answer is this.

Some ISP blocks SendMail on port 25. Hence you cannot send mail on default port 25. You can further read from here

http://www.google.com/search?q=isp blocking sendmail on port 25&hl=en-GB

From.what I see you are configuring say iCloud to send mail, I cloud (I think) requires a secure connection to send email and of which (I think) port 25 isn't the right connection or port for that configuration
I suggest you change from port 25 to port 587 (or any of the SSL ports) and try again.

2 Likes

Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 9:12am On Oct 12, 2015
gimakon:


It behaves like the mail is sent, and it doesn't send email? If yes then the answer is this.

Some ISP blocks SendMail on port 25. Hence you cannot send mail on default port 25. You can further read from here

http://www.google.com/search?q=isp blocking sendmail on port 25&hl=en-GB

From.what I see you are configuring say iCloud to send mail, I cloud (I think) requires a secure connection to send email and of which (I think) port 25 isn't the right connection or port for that configuration
I suggest you change from port 25 to port 587 (or any of the SSL ports) and try again.

Works on 587!! BUT WHY WOULD PHP DEFAULT to p25?!! It would be like like Apache not defaulting to p80.

Only problem now is that my emails are marked for Spam on Gmail and Hotmail accounts ( and likely others). DNS ISSUE CONFIRMED.

Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 9:31am On Oct 12, 2015
AAinEqGuinea:


Works on 587!! BUT WHY WOULD PHP DEFAULT to p25?!! It would be like like Apache not defaulting to p80.

Only problem now is that my emails are marked for Spam on Gmail and Hotmail accounts ( and likely others). DNS ISSUE CONFIRMED.



Issues with spamhaus.
Most clients actually behave like that. And most times google mail and Hotmail usually have problems with spamhaus that even most times your hello you put as subject may be identified as testing for Spam. Hence other than checking for potency, or rather would I say efficiency, it just drives the email to spam. Like giving you false positive results.
It's nothing to worry much about. I send email via phone and it moves most times to inbox, since I don't have "Hello" in the subject line.
Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 1:19pm On Oct 12, 2015
gimakon:


Issues with spamhaus.
Most clients actually behave like that. And most times google mail and Hotmail usually have problems with spamhaus that even most times your hello you put as subject may be identified as testing for Spam. Hence other than checking for potency, or rather would I say efficiency, it just drives the email to spam. Like giving you false positive results.
It's nothing to worry much about. I send email via phone and it moves most times to inbox, since I don't have "Hello" in the subject line.
im 'white listed for now, emails are still getting junked
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 1:58pm On Oct 12, 2015
AAinEqGuinea:
im 'white listed for now, emails are still getting junked

Gimme sometime lemme figure out what to do this evening. I send you a direct email and yell you how to go about it.
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 7:28pm On Oct 12, 2015
AAinEqGuinea:
Love my Linux boxes more than most humans.

Currently having trouble configuring one distro for arcane SendMail and dreaded Wordpress stack without being relayed... angry


That's doing a bit too much isn't it smiley

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 9:54am On Oct 19, 2015
gimakon:


Gimme sometime lemme figure out what to do this evening. I send you a direct email and yell you how to go about it.


After playing around with this long enough, I've decided to go with email-as-a-service, Mailchimp, instead poking more holes in my linux box. That's all bloated wordpress needs is another module undecided
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 6:35pm On Oct 22, 2015
When you want to start writing a script in Linux, choose an editor that you feel is sufficient at the task. Some people like emacs, others prefer vi/vim. I personally use vim as it has proven to be time and time again a very powerful built-in tool.

In order to start a script, always start of with the what we call the "shebang" sequence. This is signified by

#! /bin/bash #Indicates where to call the shell and how it is to be executed (telling the system to run bash)

That should always be the first line in any bash programme.

Today, we are going to write our first bash programme. As aforementioned, you will want to include the shebang sequence at the beginning of the file.

On another note, if you have ever programmed in another language before, then you should be familiar with comments/commenting. To comment in bash, you simply use the '#' annotation.

E.g: #My first programme in bash.

So let's put it together

#! /bin/bash
# My first programme utilising the bash script

echo "Hello Nairaland, this is a simple demonstration"

That's it, really only one line of code to output to the screen. I failed to mention earlier that you will create a new file called "firstscript.sh". To do so for vim, at the command line, type 'vi firstscript.sh'. The vi/vim editor will open a separate window.

I know this explanation is extremely muddy and porous. I will improve on my explanations with time and even include screenshots (heck I will even revise this and include screenshots). So that I can clarify what I'm saying. We will soon get into more complex stuff. Please feel free to ask questions.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Borwe: 7:44pm On Oct 22, 2015
Supermiy:
their Is Android Version Of Linux..Runs Ubuntu But Its Recommend For Pros Only..I Haven't Tried It My Self Tho

Can you post link showing where you got it..
Re: Bash/shell Scripting In A Unix/linux Environment by AAinEqGuinea: 8:29pm On Oct 22, 2015
Fulaman198:
When you want to start writing a script in Linux, choose an editor that you feel is sufficient at the task. Some people like emacs, others prefer vi/vim. I personally use vim as it has proven to be time and time again a very powerful built-in tool.

In order to start a script, always start of with the what we call the "shebang" sequence. This is signified by

#! /bin/bash #Indicates where to call the shell and how it is to be executed (telling the system to run bash)

That should always be the first line in any bash programme.

Today, we are going to write our first bash programme. As aforementioned, you will want to include the shebang sequence at the beginning of the file.

On another note, if you have ever programmed in another language before, then you should be familiar with comments/commenting. To comment in bash, you simply use the '#' annotation.

E.g: #My first programme in bash.

So let's put it together

#! /bin/bash
# My first programme utilising the bash script

echo "Hello Nairaland, this is a simple demonstration"

That's it, really only one line of code to output to the screen. I failed to mention earlier that you will create a new file called "firstscript.sh". To do so for vim, at the command line, type 'vi '. The vi/vim editor will open a separate window.

I know this explanation is extremely muddy and porous. I will improve on my explanations with time and even include screenshots (heck I will even revise this and include screenshots). So that I can clarify what I'm saying. We will soon get into more complex stuff. Please feel free to ask questions.

Thanks Fulaman.

A couple more house-tips:

Piping your script or (any file to shell):

>
 sh < firstscript.sh 
('sh' is the same reference to shebang)
Imagine the possibilities

To make your script more portable:
#!/usr/bin/env bash


Make the script executable:
> chmod a+rx firstscript.sh

> ./firstscript.sh

Add scripts to your login scripts (automatically ran at login or when you start a new shell):

"Man" your shell, find out where your shell's initialization scripts are.

Common places:
/etc/profile ~/.profile Bourne family, Login only

~/.shrc Bourne family All interactive shells (login and non-login)

~/.bashrc Bourne-again only All interactive shells (login and non-login)

~/.bash_profile Bourne-again shell only Login shells only

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 6:49am On Oct 23, 2015
AAinEqGuinea:


Thanks Fulaman.

A couple more house-tips:

Piping your script or (any file to shell):

>
 sh < firstscript.sh 
('sh' is the same reference to shebang)
Imagine the possibilities

To make your script more portable:
#!/usr/bin/env bash


Make the script executable:
> chmod a+rx firstscript.sh

> ./firstscript.sh

Add scripts to your login scripts (automatically ran at login or when you start a new shell):

"Man" your shell, find out where your shell's initialization scripts are.

Common places:
/etc/profile ~/.profile Bourne family, Login only

~/.shrc Bourne family All interactive shells (login and non-login)

~/.bashrc Bourne-again only All interactive shells (login and non-login)

~/.bash_profile Bourne-again shell only Login shells only


Excellent contribution, thanks smiley

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 6:51am On Oct 23, 2015
Borwe:


Can you post link showing where you got it..

http://www.ubuntu.com/phone/devices

There are some ubuntu phones, but I don't know if they have command line capabilities. It would be nice to see if it can do everything an actual Debian Ubuntu box can do.

On tablets as well:

http://www.ubuntu.com/tablet
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 9:37pm On Oct 24, 2015
I am not a pro.

but I think I can lend a helping hand to android users.

great work @op. keep it up.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 10:54am On Oct 26, 2015
You could explain your commands. E.G. 'ls -al' lists the directory you're in both hidden files which typically have a '.' In front of them and the detailed information of the files (and the file permissions).
Re: Bash/shell Scripting In A Unix/linux Environment by MOM1(m): 6:44pm On Oct 27, 2015
Does anyone knows how to use the Oracle Virtual Machine?
Re: Bash/shell Scripting In A Unix/linux Environment by RockMaxi: 6:08am On Oct 28, 2015
Great work @OP, my first experience with linux was disastrous, it was a server machine and I was sent to boot the system. Chai, grin it was something I least expected, all commands and no graphics. Blank monitor with a command line. grin

I think their is a respite for Windows with cygwin. The day I ran a complete shell script using a cygwin terminal my love for commands and scripting took a different turn. Very great and it makes life easier.

1 Like

Re: Bash/shell Scripting In A Unix/linux Environment by Borwe: 8:18am On Oct 28, 2015
MOM1:
Does anyone knows how to use the Oracle Virtual Machine?

You mean Java the Oracle version?
Yeah I know, and if you want to use it, just learn java.
Re: Bash/shell Scripting In A Unix/linux Environment by Nobody: 9:03am On Oct 28, 2015
@op

"Most of you are probably unaware that you use a version of Linux in your pocket (Android OS)"

lol

1 Like 1 Share

Re: Bash/shell Scripting In A Unix/linux Environment by orobogenius: 9:25am On Oct 28, 2015
danjumakolo:
@op

"Most of you are probably unaware that you use a version of Linux in your pocket (Android OS)"

lol

True talk sir, most of the core *nix Utilities are available
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 6:51pm On Oct 28, 2015
MOM1:
Does anyone knows how to use the Oracle Virtual Machine?

Yeah I'll make a tutorial on it later
Re: Bash/shell Scripting In A Unix/linux Environment by Fulaman198(m): 6:52pm On Oct 28, 2015
danjumakolo:
@op

"Most of you are probably unaware that you use a version of Linux in your pocket (Android OS)"

lol

:-D

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

Php/mysql Help:how To Run Sql Query From A Link / How Was Nairaland Able To Achieve Its Speed / MTN Momo Hack: The Dangerous Aspect Of Programming No One Tells You About

(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. 62
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.