Command Line
: The line in which we enter our commands.Prompt
: The bit of text before your CL that gives some context to your pwd.Output
: Anything that’s been executed to the terminal.Keyboard Shortcuts
Return & Enter
: Submit code we have typed.Up & Down Arrows
: Move up and Down your command history.ctrl + a
: Move your cursor to the beginning of the line.ctrl + e
: Move your curse to the end of the line.ctrl + l
: clear your terminal.Understanding Directories
/User/your_username/
or ~
: Home Directory./
: The Root Directory..
: Current Directory..
: Parent of Current Directory.Getting Around
pwd
: Print Working Directory, will always print the full path of where you are.-al
to ls in order to see all the hidden files as well.Making Changes
appending -p to mkdir will allow you to make all required parent directories it needs to create a requested directory.
Manipulating Existing Files
cp
: duplicates a file, requires a source and a destination.mv
: moves a file from one place to another, can also be used to rename files.rm
: removes files and directories.
rmdir
: for removing directories only.
Grep marks the spot
g/re/p
means “Globally search for a Regular Expression and Print”
Common grep options
-r
: recursive - searches all files in a given path.-n
: line number - will show you the exact line for each match.-i
: ignore case.-c
: will return count, the number of matches.Teaching yourself anything
man
: (manual) utility to learn more about any built in command.
Command Redirection
Command Redirection
: Takes the output from one command makes it the input for another command.
>
: will create a new file to save output.>>
: will append output to an existing file.tee
: the tee operator can be used to view an output before writing it to a file.Editing files directly from the CLI
Nano
is a terminal text editor that provides easy-to-read instructions and is available on most systems.
Bringing the Internet into your Terminal
curl
: command used to download from a URL to your computer.-o
: appending this flag to your curl command will allow you to name the incoming download file.shell
: the software layer that translates your command line instructions into actual commands.
Selling C-Shells by the Seashore
Shells vs Terminals
Shells and Terminals are not the same thing, just think of a terminal as an emulator that allows us to work with our Shell.
Shell Prompts
If we ever see a # instead of the usual $ or %, we are logged in as a super-user and must take great care!
Two Purposes
From the Command Line to the Screen
Customizing your Environment
Export : command used to change/initialize a new environment variable
Zsh Customizable Files: .zshrc.
Bash Startup Files
ZSH Startup Files
macOS Catalina with Zsh
Put your customizations into your .zshrc file. Change Visual Studio Code to use zsh as it’s shell.
Modifying Permissions
Ignoring Permissions entirely with Sudo
Bash Scripting
Script requirements
An effective script requires three things: