Mac/Linux Shell & Terminal Reference
SHELL
https://cheat.sh/ https://www.nushell.sh/
Table of Contents
- Bash/Zsh
- Commands for System Information
- Commands for File Permissions
- Commands for Networking
- Commands for Archives and File Compression
- [Commands for ]
- Commands for Hardware Information
- Misc Commands
| Terms | Defintions |
|---|---|
| Operating System / Kernel | a 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.
-
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.
-
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)
Links
- https://medium.com/cameron-nokes/bash-commands-ive-found-most-useful-for-front-end-development-df66c8544c96#:~:text=The%20most%20useful%20bash%20commands%20for%20front%20end,...%208%20Kill%20runaway%20processes%20...%20More%20items
- https://scriptingosx.com/2019/06/moving-to-zsh-part-2-configuration-files/
- https://apple.stackexchange.com/questions/388622/zsh-zprofile-zshrc-zlogin-what-goes-where
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