LinuxQuestions.org
Review your favorite Linux distribution.
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, 07:34 AM   #1
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 24

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 07:37 AM.
 
Old 12-29-2014, 07:52 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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, 03:19 PM   #3
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,986

Rep: Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447Reputation: 2447
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 03:21 PM.
 
Old 12-29-2014, 05:48 PM   #4
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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, 10: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, 07:25 AM   #6
mhsahkir
LQ Newbie
 
Registered: Dec 2014
Location: U.S.A ,NEWYORK
Posts: 24

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

Rep: Reputation: 264Reputation: 264Reputation: 264
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, 10:25 AM   #8
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,654

Rep: Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255Reputation: 1255
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:17 PM
[SOLVED] /usr/bin/xterm: Could not exec /bin/bash: Permission Denied suheng Linux - Newbie 2 09-24-2010 06:31 PM
[SOLVED] #!/bin/sh vs #!/bin/bash -- script executes differently; each way = different bugs GrapefruiTgirl Programming 21 12-16-2009 06:30 PM
How to add paths to sbin, bin/bash, bin sh for users gopi.d Fedora 3 12-07-2007 01:47 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 07:42 PM


All times are GMT -5. The time now is 08:14 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration