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.
|
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)
|
|
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
|
|
man <command>
|
Display the manual page. Press { q } to exit.
|
|
<command> --help
|
Brief help message.
|
|
Linux
|
Open source Unix-like operating system (OS) built on Linux kernel, commonly used for servers and supercomputers.
|
|
Shell
|
Text-based user interface (UI) for accessing the operating system's services.
|
|
CLI
|
The concept of interacting with the shell; accessed via a Terminal app.
|
|
touch <file>
|
Create an empty file or update a file’s timestamp
|
|
cp <src> <dest>
|
Copy files and dirs
|
|
↳ Add { -r } to copy directories recursively.
|
|
|
mv <src> <dest>
|
Move or rename files/dirs
|
|
rm <file>
|
Remove files
|
|
↳ Use with caution! Add < -r > to remove directories and their contents, < -f > to force removal without prompting.
|
|
|
cat <file>
|
Print file contents to screen
|
|
less <file>
|
View file content page-by-page
|
|
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.
|
|
|
⌃ A
|
Beginning of line
|
|
⌃ E
|
End of line
|
|
⌃ F
|
Forward one character
|
|
⌃ B
|
Back one character
|
|
⌃ U
|
Delete the current line
|
|
⌃ K
|
Delete from cursor to EOL
|
|
|
|
|
⌃ W
|
Delete one word (backward)
|
|
⌃ D
|
Delete one char (forward)
|
|
FN + ⌦
|
Delete one char (forward)
|
|
⌃ L
|
Clear the screen
|
|
⌘ K
|
Clear history
|
|
⌃ _
|
Undo the last change
|
|
⌃ C
|
Terminate the running foreground process
|
|
⌃ Z
|
Suspend the running foreground process
|
|
⌃ D
|
Exit current shell (when line is empty)
|
|
↑
|
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
|
Run last command that begins with <pw> (e.g., !cd)
|
No comments yet.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.