Cheatography
https://cheatography.com
The Z Shell Basics cheatsheet is a quick reference for common Unix commands in the Zsh shell. Unix commands are core utilities, while a shell (like Zsh) is an interpreter that runs these commands. Zsh is a popular shell with enhancements over the traditional Bourne Shell (sh) and Bash.
Directory Commands
pwd |
Print working directory |
mkdir <directory> |
Create a new directory |
rmdir <directory> |
Remove an empty directory |
cd <directory> |
Change directory |
↳ Use < .. > to go up one level, < ~ > for home directory, or < - > for the previous directory. |
ls <flag> |
List files and directories |
-l |
Long format |
-a |
All entries |
-h |
Human-readable sizes |
-t |
Sort by modification time |
-r |
Reverse order |
-d |
List directory (meta) |
Finding Files
grep <pattern> <file> |
Search pattern in a file |
find <path> <expression> |
↳ Search for files and directories within a directory hierarchy:* |
-name |
(by name) |
-type d |
(by directories) |
-type f |
(by files) |
locate <filename> |
Quickly find files by name |
Command Help
man <command> |
Display the manual page. Press { q } to exit. |
<command> --help |
Brief help message. |
|
|
File Operations
touch <file> |
Create an empty file or update a file’s timestamp |
cp <source> <dest> |
Copy files and directories |
↳ Add { -r } to copy directories recursively. |
mv <source> <dest> |
Move or rename files and directories |
rm <file> |
Remove files |
↳ Use with caution! Add < -r > to remove directories and their contents, < -f > to force removal without prompting. |
cat <file> |
Display the content of a file |
less <file> |
View file content page by page. Press q to exit |
head <file> |
Display the first few lines of a file (default 10) |
tail <file> |
Display the last few lines of a file (default 10) |
↳ Add < -f > to follow the file as it grows. |
zsh shortcuts: Navigation
⌃ A |
Beginning of line |
⌃ E |
End of line |
⌃ F |
Forward one character |
⌃ B |
Back one character |
zsh shortcuts: Deletion
⌃ U |
Delete the current line |
⌃ K |
Delete from cursor to EOL |
⎋ + ⌦
|
Delete one word (backward)
|
⌃ W |
Delete one word (backward) |
⌃ D |
Delete one char (forward) |
🌐︎ ⌦ |
Delete one char (forward) |
⌃ L |
Clear the screen |
⌘ K |
Clear history |
⌃ _ |
Undo the last change |
zsh shortcuts: Process and shell
⌃ C |
Terminate the running foreground process |
⌃ Z |
Suspend the running foreground process |
⌃ D |
Exit current shell (when line is empty) |
zsh shortcuts: History
↑ |
Recall the previous command in history |
↓ |
Recall the next command in history |
⌃ R |
Search the command history |
⌃ G |
Escape from command search mode |
!! |
Execute the last typed command |
!pw |
Execute the last command in history that begins, e.g. with pw |
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets