Raspberry Pi: Cybersecurity Edition - Terminal & Text Editor Configuration
This tutorial covers the two most important pieces of software in your arsenal; your terminal and text editor, as well as how to start customizing and configuring them to your beeds.
Table of Contents
In this document, you will learn how to:
- Installing Homebrew
- Installing Python and Pip
- Using the Man and Help Commands
- Customizing the macOS Terminal with Themes & Plugins
- Installing Sublime Text 4
- Adding Sublime Packages
Homebrew is a package manager for macOS that will come in handy throughout this tutorial.
- Open the Terminal app on your Mac. You can find it in the Utilities folder within the Applications folder or use Spotlight Search to find it.
- In the Terminal window, paste the following command and press Enter:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- The installation script will start running, and you will be prompted to enter your password. This is the password you use to log in to your Mac. Type it in and press Enter.
- The installation script will then download and install Homebrew on your Mac. This process may take several minutes, depending on your internet connection speed.
- Once the installation is complete, you can test that Homebrew is installed by typing the following command in the Terminal window and pressing Enter:
- Homebrew is installed correctly, the version number should be displayed in the Terminal window.
That’s it! Homebrew is now installed on your Mac, and you can use it to install a wide variety of command-line tools and software packages.
Setting up your Terminal on macOS
The terminal for macOS is a command-line interface that provides access to the underlying operating system of a Mac computer. It allows users to execute various commands, such as running scripts, managing files and directories, installing packages and applications, and controlling system settings. In other words, the terminal serves as a powerful tool for users who want to interact with their computer in a more direct and precise way. It can be particularly useful for developers, system administrators, and power users who need to perform complex tasks quickly and efficiently.
Commonly used commands
The macOS terminal is what allows you to interact with the Operating System.
The most important commands to know are in the table below, especially the man command.
||List contents of current directory|
||Change to a different directory|
||Create a new directory|
||Create a new file|
||Copy a file or directory|
||Move or rename a file or directory|
||Remove a file or directory|
||Print a message to the console|
||Display manual pages for a command|
||Print the current working directory|
Each of those commands allows for different "arguments" (also known as flags). For example, with the rm command:
||Remove a file|
||Remove a directory and its contents recursively|
||Force removal of a file or directory without prompting for confirmation|
||Prompt before removing each file or directory|
||Verbose output, prints the name of each file or directory as it is removed|
||Remove an empty directory|
⚠️ Using the man and help commands.
The man command and help command are like instruction manuals for how to use different commands on a computer. man shows instructions for commands that are built into the computer system, while help shows instructions for commands that you can use in the command line.
||Display the manual page for a specific command|
||Search the manual pages for a specific keyword|
||Display the one-line description of a command|
||Display all the available manual pages for a command|
||Display a list of built-in shell commands|
||Display information about a specific shell command|
||Display the manual page for a specific shell command|
Customizing the macOS Terminal with Themes & Plugins
The terminal is better when you stylize it!
- Open the Terminal app on your Mac. You can find it in the Utilities folder within the Applications folder, or use Spotlight Search to find it.
- In the menu bar at the top of the screen, click on Terminal > Preferences. Alternatively, you can use the keyboard shortcut Command + , to open the preferences window.
- In the Preferences window, click on the Profiles tab.
- Select the profile that you want to change the theme for by clicking on it in the list on the left-hand side of the window.
- On the right-hand side of the window, you can customize the theme by changing the text, background, and cursor colors, as well as the font style and size. You can also choose from several built-in themes by clicking on the "Color Presets" dropdown menu.
- Once you’ve made your desired changes, close the Preferences window. Your new theme will be applied to the Terminal.
Adding Terminal Plugins
- Install Zsh4Humans by running
brew install zsh4humansin the terminal
- Install Powerlevel10K by entering
brew install romkatv/powerlevel10k/powerlevel10kinto your terminal
- Add Powerlevel10K to your shell configuration, so it’s easier to use
echo "source $(brew --prefix)/opt/powerlevel10k/powerlevel10k.zsh-theme" >>~/.zshrc
- Restart your terminal or run source ~/.zshrc for the changes to take effect.
Sublime Text 4
Next, we are going to install a simple text editor for working with Raspberry Pi and cybersecurity projects.
- Go to Sublime Text 4 to download the latest version
- In Sublime click View > Show Console
- Paste the code from Package Control (also below) into console and press Enter
import urllib.request,os,hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)
Adding Sublime Packages
Let’s install our first package, the Dracula Theme. To do this
Command + Shift + Pit will bring up Package control.
- Search for
Dracula Color Schemeand press enter
- Go to Sublime Text > Preferences > Color Scheme > Select
Install the Markdown Preview package for Sublime Text
This will make it very easy for you to be able to write in markdown and preview it.
- Open Sublime Text 4 on your computer.
- Open the Package Control panel by pressing Ctrl+Shift+P (Windows) or Cmd+Shift+P (macOS).
- In the panel, type
Install Packageand press
Enter. This will bring up a search bar where you can search for packages.
- Type "Markdown Preview" in the search bar and press Enter. This will search for the package in the Package Control repository.
- When the search results appear, select
Markdown Previewfrom the list of packages and press Enter. This will begin the installation process.
- Wait for the package to download and install. This process may take a few seconds or minutes, depending on your internet connection speed.
- Once the package is installed, you should be able to use it to preview Markdown files in Sublime Text 4.
- Open a Markdown file in Sublime Text 4, and then open the Markdown Preview panel by pressing
Cmd+Shift+P(macOS) and selecting
Markdown Preview: Preview in Browser"` from the list of commands.
- A new browser tab will open, displaying a preview of the Markdown file.