CLI? Shell? Terminal?
Shell is a program that takes commands from the keyboard and gives them to the operating system to perform. In the old days, it was the only user interface available on a Unix-like system such as Linux. (It’s the out most layer of the OS, thus the name)
Different types (dialects) of shells
- Z-Shell (default for higher versions of macOS & some Linux distros)
 - Bash (default for older versions of macOS & some Linux distros)
 - PowerShell (default for Windows)
 
Why use the terminal?
- Makes you much better at using your OS
- Increase efficiency and productivity
 
 - You just have to sometimes
- CLI tools
 - Git
 - Package managers
 
 - It’s FUN
- Makes you look cool
 - Makes you feel like a coder
 
 
Learning Shell Commands
Basic Navigation
cd: change directorypwd: present working directory (understand where you are)ls: list filesrm: delete files/directorymv: move and rename filestouch: create a filemkdir: make a directory
clear: clear the terminal screencat: print files in your terminal
Understanding Your File System
cd ..: Navigate to parent directorycd -: Navigate to previous directorycd ~: Navigate to home directory- Common directories
/: root directory/bin: binary files/etc: configuration files/usr/<YOUR_USERNAME>: user home directory, YOU WILL BE HERE MOST OF THE TIME
 
Using Flags
rm -r: remove recursively (delete directory with contents)rm -rf: remove recursively and forcels -a: list all files (including hidden files)--help
Greping and Searching
Flags with parameters
grep: search for string in filesgrep "string" filename: search for string in filenamegrep -r "string" .: search for string in all files in current directory
find: find filesfind . -name "filename": find file with name filename in current directoryfind . -type d: find all directories in current directory
Data piping, redirect & chaining commands
|: pipels | grep "string": list all files and search for stringls | grep "string" | wc -l: list all files, search for string, and count the number of files
>: redirectecho "string" > filename: adds string to filename. Creates file if one does not existecho "strong" >> filename: appends string to filename
- Chaining commands
command 1 && command 2: command 2 executes if command 1 was successfulcommand 1 ; command 2: command 2 executes no matter if command one was successful or not
 
Make Network calls with curl
curl: make network requestscurl <URL>: make a GET requestcurl -X POST -d "data" <URL>: make a POST request with data
Package Managers
OS Package Managers
Installs and manages software on your machine
- MacOS
- Homebrew
 - MacPorts
 
 - Linux
- Apt - Debian based distros
 - Pacman - Arch based distros
 
 
Language specific package managers
Makes managing dependencies easier
- Python
- pip
 
 - Java
- Maven
 
 - JavaScript (Node)
- npm
 
 
Beyond the Basics
Shell Scripting
- Sourcing files
 - Making files executable
 - Z-Shell environment
- Aliases
 - Functions
 - Keybinds
 
 
Plugins and Tools
Lawrence’s CLI setup
- Z-Shell plugins
- oh my zsh
 - Syntax highlighting
 
 - Lawrence’s Favorite Command line tools
fzf: command line fuzzy finderripgrep/grep: search for string in filesfd: betterfindcommandbat: bettercatcommand
 
Exercises
- Navigate to your home directory
 - List all the files and directories in your current directory
 - Create a directory called 
testusingmkdir - Change into the 
testdirectory - Create a file called 
file.txt - Rename the 
file.txtfile toresult.txt 
- Download the text from 
https://raw.githubusercontent.com/ImPrankster/tamid-tech-resources/main/cli/foundation-and-earthtonovel.txt - Search for the word 
robot(case ignored) innovel.txt, and output toresult.txt