CertGrid CertGrid
Concepts·LPIC-1

Finding your way on an unfamiliar machine

Before any objective, there is the skill of working out what a machine will actually do. This guide covers the three things that decide it: whether a command is a builtin or a program, where the shell looks and in what order, and how to find documentation from the command line - including the manual sections that explain why man passwd and man 5 passwd are different pages.

Start Here Guide 3 of 33 Beginner

One Debian-family host. Everything here is read-only and behaves the same on either family.
Server NameIP AddressOSRolesCPURAMHDD
LPIC1-A01192.168.0.76Ubuntu 26.04 LTSDebian-family host - dpkg and apt, which objective 102.4 names2 Core4 GB50 GB

This guide includes

Use this before any objective. This matters because which and the shell can disagree - a command is not always a program, and the answer depends on which of them you asked.

Before you start

  1. A command is not always a program

    type -a shows every candidate, in the order the shell considers them.

    bash Example session
    type -a echo; echo "---"; type -a lsecho is a shell builtinecho is /usr/bin/echoecho is /bin/echo---ls is /usr/bin/lsls is /bin/lstype -a cd; echo "--- cd MUST be a builtin: a child process could not change your directory"cd is a shell builtin--- cd MUST be a builtin: a child process could not change your directory

    Expected resultecho is a shell builtin AND /usr/bin/echo AND /bin/echo; ls is only a program; cd is only a builtin.

    Success conditionYou can tell what will actually run before you run it.

  2. Where `which` disagrees with the shell

    Two tools that look interchangeable and are not.

    bash Example session
    which echo; command -v echo; echo "--- which finds the binary, command -v finds what will actually run"echo: shell built-in commandecho--- which finds the binary, command -v finds what will actually run

    Expected resultwhich reports echo: shell built-in command; command -v reports echo.

    Success conditionYou know which tool to trust in a script.

  3. Where the shell looks, and in what order

    $PATH is a list, and the order is the whole story.

    bash Example session
    echo $PATH | tr ':' '\n'/usr/local/sbin/usr/local/bin/usr/sbin/usr/bin/sbin/bin/usr/games/usr/local/games/snap/binecho $PATH | tr ':' '\n' | head -1; echo "--- the FIRST match wins, which is how a local bin shadows a system one"/usr/local/sbin--- the FIRST match wins, which is how a local bin shadows a system one

    Expected resultNine directories, /usr/local/sbin first and /snap/bin last.

    Success conditionYou can explain why a command ran the version you did not expect.

  4. Reading a manual page you did not know existed

    The same word can be several different pages.

    bash Example session
    man -f passwd 2>/dev/null | head -4; echo "--- the same word in several manual sections"passwd (1)           - change user passwordpasswd (1ssl)        - OpenSSL application commandspasswd (5)           - the password file--- the same word in several manual sectionsapropos -s 1 'list directory' 2>/dev/null | head -3; echo "--- search by description when you do not know the name"dir (1)              - List directory contents. Ignore files and directories ...gnudir (1)           - list directory contentsgnuls (1)            - list directory contents--- search by description when you do not know the nameman 5 passwd | head -6; echo "--- section 5 is the FILE, section 1 is the command"PASSWD(5)                File Formats and Configuration               PASSWD(5) NAME       passwd - the password file DESCRIPTION--- section 5 is the FILE, section 1 is the command

    Expected resultpasswd (1) the command, passwd (5) the file, and passwd (1ssl) from OpenSSL - then a description search, then section 5 itself.

    Success conditionYou can find documentation on a machine with no browser.

Troubleshooting

Official sources