LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-29-2014, 06:34 AM   #1
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 26

Rep: Reputation: Disabled
linux bin and bash


hi i am linux beginner stage can somebody easily explain what is /bin/bash. another question what is the different "shutdown -h now" "poweroff"?

Last edited by mhsahkir; 12-29-2014 at 06:37 AM.
 
Old 12-29-2014, 06:52 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
1. In short, /bin/bash is the path to an executable. The bash executable is a command interpreter using a simple terminal line interface. It is also very easy to use script files that contain command lines to create simple applications.

2. Not much. The shutdown command provides more flexibility than the poweroff command. Most distributions have the poweroff command linked to the shutdown command - which in turn may be linked to yet another. But the purpose of the power off is the same as "shutdown -P -h now", and if the shutdown (which may be a script) will use the name it was invoked by to identify a predefined set of options. It is also possible that the poweroff is linked to a "halt" utility - which should only be used for emergencies, as the halt utility directly is intended to halt the system immediately. On Slakware, the halt utility (or poweroff) will first verify that the system is in single user mode before halting/poweroff the system - instead, it will invoke the shutdown utility with the appropriate options to gracefully shutdown the system, then either halt or power off.
 
Old 12-29-2014, 02:19 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
in a script that "/bin/bash" on the top line should be preceded with a #!
Code:
#!/bin/bash
----- or this ----
#!/bin/sh
----- or this ----
#!/bin/csh
---- or even this for python code-------
#!/usr/bin/env python
google " shebang linux "
https://en.wikipedia.org/wiki/Shebang_%28Unix%29

Last edited by John VV; 12-29-2014 at 02:21 PM.
 
Old 12-29-2014, 04:48 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Quote:
Originally Posted by John VV View Post
in a script that "/bin/bash" on the top line should be preceded with a #!
Code:
#!/bin/bash
----- or this ----
#!/bin/sh
----- or this ----
#!/bin/csh
---- or even this for python code-------
#!/usr/bin/env python
google " shebang linux "
https://en.wikipedia.org/wiki/Shebang_%28Unix%29
To be a bit more specific, the first line of a script file that is marked as executable should/must start with "#!" followed by the path to the program (or script even) that is to interpret the contents.

This is not, however, a property of a script - it is the property of the kernel validating a file for execution - and when the "#!" is found, using the rest of the line interpreted as the command (with options) to interpret the file.
 
Old 12-29-2014, 09:02 PM   #5
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Every system has a root directory which holds all files and sub directories. Root is give the symbol /. Bin is a subdirectory called simply as bin and if given together with root as /bin. bash is executable file located in bin directory. So it's refered as /bin/bash. The / acts as separator for directories and files.

As for commands shutdown poweroff halt just use safe ones for now. And if you want to know more details you can read their man pages by:

Code:
man shutodwn
man poweroff
man halt
 
1 members found this post helpful.
Old 01-06-2015, 06:25 AM   #6
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 26

Original Poster
Rep: Reputation: Disabled
Thank you guys for your kind reply i really appreciated.
 
Old 01-06-2015, 07:54 AM   #7
maples
Member
 
Registered: Oct 2013
Location: IN, USA
Distribution: Arch, Debian Jessie
Posts: 814

Rep: Reputation: 265Reputation: 265Reputation: 265
Quote:
Originally Posted by jpollard View Post
It is also possible that the poweroff is linked to a "halt" utility - which should only be used for emergencies, as the halt utility directly is intended to halt the system immediately.
Well, then I guess I should stop using "halt -p" to shutdown my Debian system.
 
1 members found this post helpful.
Old 01-06-2015, 09:25 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
It can depend on the system. Some will check to see if it is already in single user mode, THEN it will halt.

If it is in multi-user mode then it will shutdown the system gracefully.

But it is always better to not depend on that - it causes some bad habits that can cause problems in a multi-vendor site (and not just Linux either - UNIX can also have variations).
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] difference between /bin/bash and /bin/dash and compatibility with POSIX kakk2 Linux - Software 7 11-11-2011 01:17 PM
[SOLVED] /usr/bin/xterm: Could not exec /bin/bash: Permission Denied suheng Linux - Newbie 2 09-24-2010 05:31 PM
[SOLVED] #!/bin/sh vs #!/bin/bash -- script executes differently; each way = different bugs GrapefruiTgirl Programming 21 12-16-2009 05:30 PM
How to add paths to sbin, bin/bash, bin sh for users gopi.d Fedora 3 12-07-2007 12:47 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration