Skip to main content

Mac/Linux Shell & Terminal Reference

SHELL

https://cheat.sh/ https://www.nushell.sh/

Table of Contents

  1. Bash/Zsh
  2. Commands for System Information
  3. Commands for File Permissions
  4. Commands for Networking
  5. Commands for Archives and File Compression
  6. [Commands for ]
  7. Commands for Hardware Information
  8. Misc Commands
TermsDefintions
Operating System / Kernela microkernel (also known as μ-kernel) is the near-minimum amount of software that can provide the mechanisms needed to implement an operating system (OS). These mechanisms include low-level address space management, thread management, and inter-process communication (IPC)

What is the difference between the terms shell and terminal?

In the context of technology, the terms "shell" and "terminal" are related but refer to different concepts.

  1. Shell: Shell refers to a program that provides an interface for users to interact with an operating system. It acts as a command interpreter, allowing users to enter commands and execute them. The shell interprets the commands and communicates with the operating system to execute them. It provides features such as file management, process control, and scripting capabilities. Examples of popular shells include Bash (Bourne Again SHell), PowerShell, and Zsh.

  2. Terminal: A terminal, also known as a terminal emulator or console, is a program or device that provides a text-based interface for users to interact with the shell. It emulates the behavior of a physical terminal and allows users to enter commands and receive text-based output from the shell. The terminal provides a window or console where users can type commands and view the results. It can be a command-line interface (CLI) or a graphical user interface (GUI) application. Examples of terminal applications include GNOME Terminal, macOS Terminal, and Windows Command Prompt.

To summarize, the shell is the program that interprets and executes commands, while the terminal is the program or device that provides the interface for users to interact with the shell. The terminal serves as a bridge between the user and the shell, allowing users to enter commands and view the output.

.bashrc & .bash_profile

Mac OS connect Global Packages

export PATH="$HOME/.npm-global/bin:$PATH"
npm link @angular/cli
  • open with default text editor open ~/.bashrc

  • open with vs code code ~/.zshrc

.bashrc

  • config file read by a shell that's both interactive and non-login
  • shell startup file

.bash_profile

  • executed when you login
  • you might put important environment variables here like PATH

Bash / Zsh Syntax

  • && for chaining tasks
  • & for running tasks simaltaneously

zsh Configuration Files

  • .zprofile (login shell)
  • .zshenv (environment variables)
  • .zshrc (interactive shell)
  • .zlogin (login shell)
  • .zlogout (when the shell exits)

Zsh setup

Zsh configuration

~/.zshrc, ~/.profile

Autocomplete

autoload -U compinit; compinit

common errors

“command not found” error messages at the command line

SOLUTION:

  • the command syntax was entered incorrectly
  • the command you are attempting to run is not installed
  • the command was deleted, or, worse, the system directory was deleted or modified
  • the users $PATH is incomplete, or $PATH has been erroneously set, reset, or cleared – this is the most common reason to see a ‘command not found’ message