ZSH

Useful ZSH Commands

NOTE: The following commands are largely the same as BASH commands, since they're both UNIX-based shells.

Basic Commands

Change the Current Directory

cd <DIR_NAME>

List Directory Contents

ls

Move or Rename Directories

mv <SOURCE> <DESTINATION>

Remove Files Directories

rm <FILE_OR_DIR_NAME>

Set an Environment Variable

export VARIABLE_NAME=<SOME_VALUE>

Display an Environment Variable

Open a Directory in Finder (Mac)

Display an Entire File

Display the First N Lines of a File

Fist 10 Lines:

First 5 Lines:

Show Command History

Clear Terminal History

  1. Ensure only one terminal window is open.

  2. Run the command below:

  1. Close the terminal window.

  2. Quit the terminal app by right-clicking the app icon and selecting “Quit”.

  3. Open a terminal window.

  4. Run the command below to ensure your .zsh_history is empty.

Clear Clipboard Content

List Local IP Address

The following command lists all local, non-loopback IPv4 addresses. Each IP address corresponds to a different network interface or network configuration on your machine.

List Public IP Address

SSH

Access a remote machine via SSH.

Exit SSH Session.

In case your shell does not display user@hostname, the following are commands to check this information.

Check the current user's username:

Check the current machine's hostname:

Last updated

Was this helpful?