Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-09-2009, 02:44 AM   #1
LQ Newbie
Registered: Nov 2009
Posts: 28

Rep: Reputation: 15
source code for fg, bg command

can any one tell me where can i found the source code for fg and bg command. I have tried and searched every where but i am unable to find it. even on running which <fg command> and also for bg comand. I am not able to find even the patch file.
Old 12-09-2009, 02:53 AM   #2
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295

I provided you with an answer to the same question on a thread where you posted it too.

Have you had a look at those links I provided?

Kind regards,

Old 12-10-2009, 03:04 AM   #3
LQ Newbie
Registered: Nov 2009
Posts: 28

Original Poster
Rep: Reputation: 15
I could not find anything there, please help me with the question.
Old 12-10-2009, 03:55 AM   #4
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
The linuxfromscratch link provided by EricTRA was indeed a good starting point. I suggest an alternative and a method you can follow for other similar searches in the future. First use the type command to see which is the actual command executed (take in mind that some commands like echo, can be either a shell built-in or a standalone program. The type command will tell you which of them is currently used by your system).
$ type fg
fg is a shell builtin
as you can see the fg command is a shell built-in. And it is only and uniquely a shell built-in. This means the source code of fg is built into the code of the shell itself. If using BASH, your best bet to find the code you're looking for is to download the source code for bash (eventually verify which version of bash you've installed and download that exact version).

Take in mind that bash - as any other GNU software - is available for download at the GNU website,

If your intent is to apply a patch, first it is strongly advised that you apply only the official ones. And it is even more strongly suggested that you wait for the updated package released by your linux distribution. Said that, since you're running on a RPM based system, if you really want to apply a patch you can download the source RPM and rebuild it.

Back to the search of source code in general, suppose the type command returns the path to an executable (here we are talking about an external program - external as opposite of shell built-in). In this case you can try the rpm command to find out which package provided the executable, then you can look for and download the source code on the official (developer or project) site. Here is an example, taken from my CentOS box:
$ type thunderbird
thunderbird is /usr/bin/thunderbird
$ rpm -qf /usr/bin/thunderbird
$ rpm -qi thunderbird
Name        : thunderbird                  Relocations: (not relocatable)
Version     :                          Vendor: CentOS
Release     : 2.el5.centos                  Build Date: Fri 26 Jun 2009 12:08:45 AM CEST
Install Date: Thu 16 Jul 2009 12:52:15 PM CEST      Build Host:
Group       : Applications/Internet         Source RPM: thunderbird-
Size        : 47338016                         License: MPL
Signature   : DSA/SHA1, Fri 26 Jun 2009 04:07:53 PM CEST, Key ID a8a447dce8562897
URL         :
Summary     : Mozilla Thunderbird mail/newsgroup client
Description :
Mozilla Thunderbird is a standalone mail and newsgroup client.
Next step is to browse the official site and look for the source code.

Take in mind that in many cases you will be able to find the source code as source RPMs. This is especially true for software/packages built and provided by the official linux distribution you're running on. Just adding the Source RPM repository to the list of available software sources, should let you have easy and quick access to the code.

Hope this helps!
1 members found this post helpful.
Old 12-10-2009, 04:00 AM   #5
Gentoo support team
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,074

Rep: Reputation: 386Reputation: 386Reputation: 386Reputation: 386
Originally Posted by mohit_parihar View Post
I could not find anything there, please help me with the question.
The response is on the other thread, if you didn't understand it completely, or at all, the right thing to do is to ask for further clarification on that same thread.

There's no need to open a new one. On the contrary, that is usually annoying to some users. Duplication of threads is also against the common netiquette.

As the other person said in your other thread, fg and bg are part of the shell (more correctly, they are shell builtins), so it's the source code for your shell what you should be looking for. In most distros nowadays, the default is bash.
1 members found this post helpful.


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 On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Where i can get source code of the 'cp' command? chaits Linux - General 5 11-22-2010 09:50 PM
Where can i get the source code of rm command jaikris Linux - Software 6 09-19-2009 12:04 AM
dump command source code Ajay Mozar Linux - Newbie 1 04-22-2009 06:58 AM
source code of ps command sudeepghiya Linux - General 1 09-21-2006 10:35 AM
Where i can get the source code of the command 'top' hustning Programming 2 03-31-2002 12:06 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:37 PM.

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