Close Menu
TechurzTechurz

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    What's Hot

    Buying an Android smartwatch? I found a model that’s highly functional and affordable

    October 13, 2025

    WhatsApp Worm, Critical CVEs, Oracle 0-Day, Ransomware Cartel & More

    October 13, 2025

    Aisuru’s 30 Tbps botnet traffic crashes through major US ISPs

    October 13, 2025
    Facebook X (Twitter) Instagram
    Trending
    • Buying an Android smartwatch? I found a model that’s highly functional and affordable
    • WhatsApp Worm, Critical CVEs, Oracle 0-Day, Ransomware Cartel & More
    • Aisuru’s 30 Tbps botnet traffic crashes through major US ISPs
    • See It Here First at TechCrunch Disrupt 2025
    • Final Flash Sale: Save up to $624 on Disrupt 2025 Passes
    • I tested a Windows laptop with a tandem OLED, and it’s spoiled working on other displays for me
    • Why Unmonitored JavaScript Is Your Biggest Holiday Security Risk
    • German state replaces Microsoft Exchange and Outlook with open-source email
    Facebook X (Twitter) Instagram Pinterest Vimeo
    TechurzTechurz
    • Home
    • AI
    • Apps
    • News
    • Guides
    • Opinion
    • Reviews
    • Security
    • Startups
    TechurzTechurz
    Home»Guides»What’s That You’re Running? Linux Programs, Scripts, Builtins, Functions, and Aliases
    Guides

    What’s That You’re Running? Linux Programs, Scripts, Builtins, Functions, and Aliases

    TechurzBy TechurzJuly 27, 2025No Comments8 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    What’s That You’re Running? Linux Programs, Scripts, Builtins, Functions, and Aliases
    Share
    Facebook Twitter LinkedIn Pinterest Email


    Quick Links

    • Running an Executable Program

    • Executing a Shell Builtin

    What happens when you run a Linux command? This simple act can appear straightforward, but many different things can actually occur, depending on whether you’re running an executable program, a shell script, a shell builtin, a user-defined function, or an alias.

    The Different Types of Linux Commands

    A program (binary, or executable) is a file on disk somewhere, in a recognized format. Common formats include ELF on Linux, and Mach-O on Mac. The format is a low-level, machine-friendly one that the shell can pass off to the kernel to run.

    A shell script is a much higher-level form of program, written in human-readable text. A shell script can run other commands, and it can be written in an interpreted language like Perl or Python.

    A builtin command is internal to the shell, so it’s always available and generally runs at a low-level, to perform operations that directly affect the shell itself.

    A shell function is like a mini shell script, packaging a set of commands together under one name. Shell functions are usually loaded so they are always available by name.

    An alias is an alternative name for any of the above. You can create a short alias of a longer command to save time and effort when running common tasks.

    The order in which a shell like bash looks for these types of commands is important. To put it simply, bash tries commands in this order: alias, function, built-in, program/script.

    1

    Running an Executable Program

    The most familiar type of command is an executable program file. Many of the most common programs are part of the POSIX standard, which means they should be available on most Unix or Unix-like systems, including Linux and macOS. Examples of such commands include cat, diff, and vi.

    Other command-line programs—such as Apache, Neofetch, or tree—may need to be installed because they are typically not included in a distribution by default. But, just like POSIX command programs, they will run via a single program file somewhere on your disk.

    There are two common ways to run a program. First, you can type a path to a program file, like ./myprog or /usr/bin/awk. If the first part of your command contains any forward slashes, the shell will attempt to find a file at the corresponding path. For example, you can run a program at /bin/cat like this:

    /bin/cat myfile

    The shell will then check for an executable program at /bin/cat, then run it if it exists.

    On Linux, executable programs usually have no file extension, so a command like “grep” is contained in a file named grep. This is just a convention, because it’s convenient to make executables recognizable by filename alone. However, if you really want to, you’re free to name your executables anything you want, like “myprog.exe” or “myprog.RUNME.”

    The second case occurs when you type a program name without a path; for example:

    cat myfile

    With a system that’s properly set up, this should have the same effect as before, because the shell will locate the same cat program. It does so by checking a special environment variable named PATH, which looks something like this:

    This is a colon-separated list of paths that the shell will search to locate a program. The order is important since you may have two files with the same name in different locations. For example, if you have a /usr/bin/grep file and a /bin/grep file, the above PATH will cause the shell to run the /usr/bin version. This system lets you override a system-wide command with a custom one that’s more specific to your needs, which can be very useful.

    Related

    How to Add a Directory to Your $PATH in Linux

    Do not add everything to your PATH. Seriously.

    2

    Running a Shell Script

    A shell script runs slightly differently from an executable program, and it’s a very different type of file. A simple shell script looks like this:

    #!/bin/sh
    echo Just a simple, pointless shell script

    The first line is referred to as a “shebang” or “hash-bang” line, named after the combination of # and ! characters. This is a special instruction that tells the shell which interpreter to use for the rest of the script. In the above case, it’s the shell itself, at /bin/sh.

    The remainder of the script is a text program that the interpreter understands. In this case, the shell can run commands like echo in the same way it would if you typed them on the command line.

    Otherwise, a shell script is much like an executable program, and your shell will search for it using the PATH variable in the same way. For both programs and shell scripts, it’s important to note that the permissions on the corresponding file will affect how you run it. With the execute permission set, you can run the program by typing its name or path. But if the execute permission is not set, you’ll see an error:

    You can always run such a file by passing its name as an argument to an appropriate interpreter. For example, you can run a shell script like this:

    sh myscript.sh

    You can even run an executable like this, but you’ll need to do some investigation first. The file command gives information about the type of a file, including its interpreter:

    In this case, you can run the pwd binary using the /lib/ld-linux-aarch64.so.1 program:

    3

    Executing a Shell Builtin

    Some commands are so fundamental to the nature of the shell that they need to operate in a slightly different way. These are called builtins because they are, effectively, part of the shell themselves.

    Builtins are usually low-level and commands that you use frequently: cd, echo, and kill are common examples. Unlike programs and shell scripts, these commands do not correspond to a particular file because they are part of the shell itself, compiled into the shell’s executable.

    Some systems may include wrapper scripts that run builtins. For example, on my macOS system, there’s a /usr/bin/cd script which uses the builtin command to run the corresponding builtin. This is for POSIX-compatibility, and you can safely ignore the script version.

    Builtins can be difficult to learn about because they either have no manual entry (e.g. on Ubuntu Linux) or they all have one big, shared manual page (macOS). The tldr program is a great way of finding out more about builtins.

    For similar reasons, builtins usually support far fewer command-line options than fully-fledged programs. For example, cd will usually support just two, fairly obscure options: -L (to follow symbolic links) and -P (to avoid symbolic links). This means that, sadly, options like -h or –help are not supported.

    4

    Calling a Shell Function

    A command can also be a call to a function. At any time during a session, you can load or define a function using this syntax (in bash):

    function_name()

    Alternatively, you can use a syntax that inserts the keyword “function” before a function name and drops the parentheses after it:

    function function_name
    mkdir -p “$@“
    cd “$@“

    You can then call a function by typing its name, followed by any arguments. For example, I have the following helper function defined in a file:

    mkd ()
    mkdir -p “$@“
    cd “$@“

    I then load this file from my shell’s run control script (~/.zshrc), and I can run this command to create a new directory and immediately change to it:

    mkd new_dir

    You can call such a function on the command line whenever you like. You can also call it from scripts, but remember that it needs to be loaded (use the builtin source, or its equivalent ., to do so).

    Related

    How to Create Aliases and Shell Functions on Linux

    Create your own Linux commands with aliases and Bash shell functions. We show you how.

    5

    Using an Alias

    An alias is a convenience that saves you from typing long command names or common options. For example, on my system, I have an alias to ensure file listings are in color, with type suffixes:

    ls=‘ls -GF’

    Now, if I type just “ls,” the command “ls -GF” runs in its place.

    You can create an alias at any time, using the alias builtin command, e.g.

    alias ls=“ls -GF”

    Note that quotes are required when you run alias, if the replacement string contains any spaces. You can view all aliases by running alias, and you can remove an alias with the unalias command. Again, you’ll want to add aliases to a startup file, like ~/.zshrc or ~/.bashrc, if you want them to apply across sessions.

    Related

    Why You Should Be Using Aliases in the Linux Terminal

    Even if you’re aware of them, make sure you’re using them to their full extent.

    Aliases Builtins Functions Linux Programs running Scripts Whats youre
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleBreaking From Tradition, ThinkPad X9 Offers a Cheap Path to OLED Ultraportable
    Next Article Samsung Makes New 5 Year Credit Offer To Galaxy Z Fold 7 Buyers
    Techurz
    • Website

    Related Posts

    Security

    Feeling lonely at work? You’re not alone – 5 ways to boost your team’s morale

    October 12, 2025
    Security

    Ready to ditch your Windows PC? I found a powerful mini PC that’s optimized for Linux

    October 12, 2025
    Security

    Your Windows 11 taskbar just got a major, long-requested feature – what’s new

    October 8, 2025
    Add A Comment
    Leave A Reply Cancel Reply

    Top Posts

    The Reason Murderbot’s Tone Feels Off

    May 14, 20259 Views

    Start Saving Now: An iPhone 17 Pro Price Hike Is Likely, Says New Report

    August 17, 20258 Views

    CNET’s Daily Tariff Price Tracker: I’m Keeping Tabs on Changes as Trump’s Trade Policies Shift

    May 27, 20258 Views
    Stay In Touch
    • Facebook
    • YouTube
    • TikTok
    • WhatsApp
    • Twitter
    • Instagram
    Latest Reviews

    Subscribe to Updates

    Get the latest tech news from FooBar about tech, design and biz.

    Most Popular

    The Reason Murderbot’s Tone Feels Off

    May 14, 20259 Views

    Start Saving Now: An iPhone 17 Pro Price Hike Is Likely, Says New Report

    August 17, 20258 Views

    CNET’s Daily Tariff Price Tracker: I’m Keeping Tabs on Changes as Trump’s Trade Policies Shift

    May 27, 20258 Views
    Our Picks

    Buying an Android smartwatch? I found a model that’s highly functional and affordable

    October 13, 2025

    WhatsApp Worm, Critical CVEs, Oracle 0-Day, Ransomware Cartel & More

    October 13, 2025

    Aisuru’s 30 Tbps botnet traffic crashes through major US ISPs

    October 13, 2025

    Subscribe to Updates

    Get the latest creative news from FooBar about art, design and business.

    Facebook X (Twitter) Instagram Pinterest
    • About Us
    • Contact Us
    • Privacy Policy
    • Terms and Conditions
    • Disclaimer
    © 2025 techurz. Designed by Pro.

    Type above and press Enter to search. Press Esc to cancel.