Saturday, May 18, 2024
37
rated 0 times [  37] [ 0]  / answers: 1 / hits: 9741  / 3 Years ago, tue, june 15, 2021, 7:03:42

fg, bg and jobs are used for job management. And for some reason (maybe it's just me), I'm not able to find where their binaries are nor their manpages (whereis prints no information). which gives no output. The commands themselves work just fine, though.



I ran commands like find /bin bg, but with no hits. I also ran find / bg to cast a wide net.


More From » command-line

 Answers
0

You are not getting any files against those commands because they are shell (bash) built-ins, not separate executable files (e.g. binary files, scripts). Actually, shell built-ins are compiled into the shell executable; if you want you can check the source code to be sure of it. As which or whereis only looks for external executable files, you are not getting any output for the built-ins.



To find if a command is a built-in or alias or function or external file, the best way is to use the type built-in:



$ type fg
fg is a shell builtin

$ type bg
bg is a shell builtin

$ type jobs
jobs is a shell builtin


Also note that your find command is not syntactically correct. The correct (simplest) syntax is find /where/to/search -name 'name_to_search'.



Also note that few commands are implemented as both a shell built-in and a separate standalone executable. For such commands, always remember that the built-in command will take precedence over the external one. So, when you run echo something, the built-in echo is run. If you want to run the binary executable echo you need to call it in a different way. One way is to use the full path to the executable: /bin/echo something.



To display all available versions of a command, run type with the -a option:



$ type -a echo
echo is a shell builtin
echo is /bin/echo


To get documentation for shell built-ins, you can check the manpage of bash or use the help command (which is a built-in command):



help jobs


Also as @terdon pointed out you should use type instead of which.


[#20378] Wednesday, June 16, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ateact

Total Points: 176
Total Questions: 130
Total Answers: 122

Location: Egypt
Member since Sun, Apr 23, 2023
1 Year ago
;