music
OSdata.com: programming text book 

OSdata.com

built-in commands

summary

    This subchapter looks at built-in commands in a UNIX (and Linux) BASH shell.

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

table of contents
If you like the idea of this project,
then please donate some money.
more information on donating

Google

built-in commands

    This subchapter looks at built-in commands in a UNIX (and Linux) BASH shell.

tools

    Most of the commands in the UNIX or Linux shell are actually programs. If you look at the usr/bin directory, you will see the actual programs. Most of these programs were written in the C programming language.

    There is a common core of tools/commands that will be available on almost every UNIX or Linux machine, but exactly how many and which commands/tools are available varies widely.

    The good news is that if a command or tool is missing from your system, you can go out and get the source code and recompile it for your local computer.

built-in

    Many of the shells have special built-in commands. These are not separate programs, but are part of the code for the shell itself.

    One example would be the shell command cd that you just saw in the previous quick tour chapter.

    There are some built-in commands are only available in selected shells and these can make your scripts shell-dependent.

    Some examples of built-in commands include the history command in the C shell, and the export command in the Bourne shell. The cd command is built-in in both bash and csh.

    echo is an example of a command that is built into both bash and csh, but also exists externally as a utility.

overriding built-in commands

    You can override any built-in commands by giving the full path name to an external command or utility. If bash finds a slash character ( ) anywhere in a command, the shell will not run the built-in command, even if the last component of the specified command matches the name of a builtin command.

    As an example, using the command echo will run the version of the command that is built into bash, while specifying /bin/echo or ./echo will ignore the built-in comamnd and instead run the designated utility.

    Overriding can be used to run alternative versions of commands or to extend the built-in command to add additional features.

determining builtin or external

    You can use the type command to determine if a particular command is a built-in command or an external utility. If the command is an external utility, you will also be told the path to the external command.

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

    You can use the which command to locate a program in your path.

    $ which echo
    /bin/echo
    $

    You can use the whereis command to locate a program in your path.

    $ whereis echo
    /bin/echo
    $

    In csh and tcsh you can use the where command to locate a program in your path.

    % where echo
    /bin/echo
    %

problems

    If something bad happens to your computer, if the shell is still loaded in memory and running, any of the built-in commands will still work correctly, even if the entire file system (including all hard drives) disappears or becomes unavailable for any reason.

built in command chart

    The following chart shows the built-in commands and external utilities for bash and csh for Mac OS X. This wil be similar for Linux and other UNIXes.

    External commands marked No** under the External column do exist externally, but are implemented using the built-in command.

CommandExternalcshbash
!NoNoYes
%NoYesNo
.NoNoYes
:NoYesYes
{NoNoYes
}NoNoYes
aliasNo**YesYes
allocNoYesNo
bgNo**YesYes
bindNoNoYes
bindkeyNoYesNo
breakNoYesYes
breakswNoYesNo
builtinNoNoYes
builtinsNoYesNo
caseNoYesYes
cdNo**YesYes
chdirNoYesYes
commandNo**NoYes
completeNoYesNo
continueNoYesYes
defaultNoYesNo
dirsNoYesNo
doNoNoYes
doneNoNoYes
echoYesYesYes
echotcNoYesNo
elifNoNoYes
elseNoYesYes
endNoYesNo
endifNoYesNo
endswNoYesNo
esacNoNoYes
evalNoYesYes
execNoYesYes
exitNoYesYes
exportNoNoYes
falseYesNoYes
fcNo**NoYes
fgNo**YesYes
filetestNoYesNo
fiNoNoYes
forNoNoYes
foreachNoYesNo
getoptsNo**NoYes
globNoYesNo
gotoNoYesNo
hashNoNoYes
hashstatNoYesNo
historyNoYesNo
hupNoYesNo
ifNoYesYes
jobidNoNoYes
jobsNo**YesYes
killYesYesNo
limitNoYesNo
localNoNoYes
logNoYesNo
loginYesYesNo
logoutNoYesNo
ls-FNoYesNo
niceYesYesNo
nohupYesYesNo
notifyNoYesNo
onintrNoYesNo
popdNoYesNo
printenvYesYesNo
pushdNoYesNo
pwdYesNoYes
readNo**NoYes
readonlyNoNoYes
rehashNoYesNo
repeatNoYesNo
returnNoNoYes
schedNoYesNo
setNoYesYes
setenvNoYesNo
settcNoYesNo
settyNoYesNo
setvarNoNoYes
shiftNoYesYes
sourceNoYesNo
stopNoYesNo
suspendNoYesNo
switchNoYesNo
telltcNoYesNo
testYesNoYes
thenNoNoYes
timeYesYesNo
timesNoNoYes
trapNoNoYes
trueYesNoYes
typeNoNoYes
ulimitNoNoYes
umaskNo**YesYes
unaliasNo**YesYes
uncompleteNoYesNo
unhashNoYesNo
unlimitNoYesNo
unsetNoYesYes
unsetenvNoYesNo
untilNoNoYes
waitNo**YesYes
whereNoYesNo
whichYesYesNo
whileNoYesYes

comments, suggestions, corrections, criticisms

please contact us

your name:
email address:
phone number:
message:

free music player coding example

    Coding example: I am making heavily documented and explained open source code for a method to play music for free — almost any song, no subscription fees, no download costs, no advertisements, all completely legal. This is done by building a front-end to YouTube (which checks the copyright permissions for you).

    View music player in action: www.musicinpublic.com/.

    Create your own copy from the original source code/ (presented for learning programming).


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

view text book
HTML file

Because I no longer have the computer and software to make PDFs, the book is available as an HTML file, which you can convert into a PDF.

previous page next page
previous page next page

free book on UNIX/Linux System Administration

Teach Yourself UNIX/Linux System Administration and Shell Programming

free computer programming text book project

Building a free downloadable text book on computer programming for university, college, community college, and high school classes in computer programming.

If you like the idea of this project,
then please donate some money.

send donations to:
Milo
PO Box 1361
Tustin, California 92781

Supporting the entire project:

    If you have a business or organization that can support the entire cost of this project, please contact Pr Ntr Kmt (my church)

more information on donating

Some or all of the material on this web page appears in the
free downloadable college text book on computer programming.


Google


Made with Macintosh

    This web site handcrafted on Macintosh computers using Tom Bender’s Tex-Edit Plus and served using FreeBSD .

Viewable With Any Browser


    †UNIX used as a generic term unless specifically used as a trademark (such as in the phrase “UNIX certified”). UNIX is a registered trademark in the United States and other countries, licensed exclusively through X/Open Company Ltd.

    Names and logos of various OSs are trademarks of their respective owners.

    Copyright © 2012 Milo

    Created: July 3, 2012

    Last Updated: September 2, 2012


return to table of contents
free downloadable college text book
free downloadable system administrator and shell programming book

previous page next page
previous page next page