Skip to content

Linux & shell: Help & shell basics

11 Linux & shell commands: Help & shell basics. Click a command to see what each part does.

Index
11 items
Click a command to see what each part does.

Help & shell basics11

  • man <command>Read the manual for a command

    What each part does

    1. manmanual page; / to search, q to quit
    2. <command>e.g. man ls, man tar
  • <command> --helpQuick help for a command

    What each part does

    1. --helpmost tools print their options and exit
  • which <command>; type <command>Where is a command installed?

    What each part does

    1. whichpath of the program that would run
    2. typealso tells you if it is an alias, built-in or function
  • history | grep <word>Search your command history

    What each part does

    1. historynumbered list of commands you ran
    2. | grep <word>only the ones containing <word>; re-run one with !<number>

    Tip Faster: press Ctrl+R and start typing to search history interactively.

  • sudo !!Re-run the last command with sudo

    What each part does

    1. sudorun as root
    2. !!history expansion: the whole previous command
  • alias ll='ls -lh'Create a shortcut command

    What each part does

    1. aliasdefine a short name for a command
    2. ll='ls -lh'typing ll now runs ls -lh (add it to ~/.bashrc to keep it)
  • echo "$HOME"Print a variable

    What each part does

    1. echoprint text
    2. "$HOME"value of the HOME variable; quotes keep spaces intact
  • export <NAME>=<value>Set a variable for this shell and its programs

    What each part does

    1. exportmake the variable visible to programs you start from this shell
    2. <NAME>=<value>no spaces around =
  • env | grep <NAME>Show environment variables

    What each part does

    1. envall environment variables
    2. | grep <NAME>only matching ones
  • sudo <command>; sudo -iRun as root / open a root shellCaution

    What each part does

    1. sudo <command>run one command as root (asks for your password)
    2. sudo -iinteractive root login shell; type exit to leave
  • Tab · Ctrl+C · Ctrl+R · Ctrl+L · Ctrl+DUseful keys

    What each part does

    1. Tabcomplete file and command names (press twice to list options)
    2. Ctrl+Cstop the running command
    3. Ctrl+Rsearch command history
    4. Ctrl+Lclear the screen (same as clear)
    5. Ctrl+Dend input / log out of the shell

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…