Operating Systems & Administration

[Day 4] 1. Few more Commands

D
DITISS Admin
••4 min read

Types of Commands in Linux

1. Internal Commands

  • Definition: Commands implemented within the shell program itself.
  • Executable File: Not available on the disk.

2. External Commands

  • Definition: Commands implemented separately from the shell.
  • Executable Locations: Found on the hard disk in directories such as
    /bin
    ,
    /sbin
    ,
    /usr/bin
    , and
    /usr/sbin
    .

Command Types and Tools

  • type
    Command: Checks if a command is internal or external.

    • Examples:
      • type echo
        →
        echo is a shell builtin
      • type mkdir
        →
        mkdir is /usr/bin/mkdir
      • type cd
        →
        cd is a shell builtin
  • which
    Command: Provides the path of a given command (location on the hard disk).

    • Examples:
      • which ls
        →
        /usr/bin/ls
      • which cd
        →
        /usr/bin/cd
      • which echo
        →
        /usr/bin/echo
      • which pwd
        →
        /usr/bin/pwd
      • which mkdir
        →
        /usr/bin/mkdir
  • whereis
    Command: Gives the path of the command and its manual page.

    • Examples:
      • whereis ls
        →
        ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz
      • whereis cd
        →
        cd:
      • whereis alias
        →
        alias:

File Handling in Shell

  • Internal commands are executed inside the shell only.

  • The shell deals with text files and not special files like PDFs.

  • open
    Command:

    • Use to open files based on their paths. It checks the file's magic number and opens the appropriate application.
    • Example: Opening a PDF file will launch a PDF viewer.

Tools for Executable Files

  • readelf
    : Displays detailed information from ELF (Executable and Linkable Format) files, such as headers, sections, and symbols.
  • objdump
    : Offers broader functionality, including disassembling code and showing headers, sections, and symbol tables for various binary formats.

Manual Pages

  • Use
    man
    to access manual entries for commands.
    • Example:
      man alias
      returns "No manual entry for alias" because it's built-in.
    • Instead, use
      man bash
      for bash-related commands.

Command Execution

  • Synchronous Execution: Commands execute one after the other, with the shell waiting for the current command to finish before proceeding.

  • Asynchronous Execution: Commands execute in the background, allowing immediate execution of other commands. This is done using

    &
    at the end of the command.

    • Example:
      cat &
    • Check status with
      ps
      command.
    • Use
      kill
      command to stop background processes.
      • kill -l
        : Lists signals (64 in total, each with a predefined meaning).
      • Examples of killing a process:
        • kill -9 5480
          (using PID)
        • kill -SIGKILL 5480
        • pkill -9 cat
          (can kill multiple processes)

Logical Operators

  • &&
    (AND Operator):

    • Nest commands; the second command executes only if the first is successful.
    • Example:
      ls && pwd
    • If the first command fails (e.g.,
      ls -W
      ), the second won't execute.
  • ;
    (Separator):

    • Executes the second command regardless of the first command's success or failure.
  • ||
    (OR Operator):

    • The second command executes only if the first fails.
    • Example:
      ls || pwd
    • If
      ls -W
      generates an error, the error is displayed, and the second command executes.

Read Next

8/26/2026

[Day 4] 3. Types of Operating System

### **Resident Monitors** !3. Resident Monitors.png - **Input Method:** Code was written using a typewriter-like device on punch cards. - **Pro...

8/26/2026

[Day 4] 4. Grep (GNU Regular Expression Parser)

#### **Regular Expression / Pattern** - **Definition:** A collection/set/combination of characters used for searching or matching purposes....