Front-End Developer's Starter Guide to Terminal Commands

Front-End Developer's Starter Guide to Terminal Commands

1. What is the Terminal? The terminal, also known as the Command Line Interface (CLI), is a powerful tool that allows you to interact with your computer using text commands. Front-end developers should master the terminal to efficiently manage files, install tools, and use version control systems.


The basic architecture of a Linux system.

Let's break down the components and their interactions:

User Space:

  • This is where user applications and processes run. It's the layer you directly interact with when using a Linux system.

  • Shell: This is the command-line interface (CLI) that allows you to interact with the system. It interprets your commands and translates them into system calls.

  • Applications: These are the programs you use, like web browsers, text editors, and terminal emulators.

Kernel Space:

  • Kernel: This is the core of the operating system. It manages hardware resources, processes, and system calls. It's responsible for communication between hardware and software.

  • Hardware: This includes the physical components of the computer, such as the CPU, memory, storage, and peripherals.

Relationship:

The shell interacts with the kernel, which in turn interacts with the hardware. The kernel provides an abstraction layer, allowing applications to interact with hardware without needing to know the specific details of each device.

Linux Distributions:

A Linux distribution is a complete operating system based on the Linux kernel. It includes the kernel, system utilities, libraries, and a user interface (like a graphical desktop environment or a command-line interface). Popular Linux distributions include Ubuntu, Debian, Fedora, and CentOS.


2. Basic Commands to Get Started

Navigation:

  • ls: Lists files and folders in the current directory.

  • cd folder-name: Moves into a specified folder.

  • cd ..: Moves up one directory level.

  • pwd: Prints the current working directory.

  • pushd and popd: Save and restore directory history.

File Management:

  • touch filename.txt: Creates a new file.

  • mkdir folder-name: Creates a new directory.

  • rm filename.txt: Deletes a file.

  • rm -r folder-name: Recursively deletes a directory and its contents.

  • locate "filename": Finds files by name.

  • cp file1 file2: Copies file1 and names it file2.

  • mv file1 file2: Moves file1 to file2 (or renames file1 to file2).

  • rm file1: Deletes file1.

  • rmdir folder-name: Deletes an empty directory.

Opening and Navigating Files:

  • more filename: Opens a file and displays its contents page by page.

  • less filename: Similar to more, but allows you to search within the file using keywords. Remember the motto: "Less is more."

Editing a File:

  • nano filename: Opens a file in the nano text editor, allowing you to edit and add content.

  • echo "text" >> filename: Appends the specified text to the end of the file.

Cool Hack:

  • command > filename: Redirects the output of a command to a file. For example, ls -al > file.txt will save the output of the ls -al command to file.txt.

Shortcuts to Save Time:

  • Tab Completion: Autocompletes commands and filenames.

  • Up/Down Arrows: Scrolls through command history.

  • Ctrl+L: Clears the terminal screen.

  • history: Displays a list of previously executed commands.

  • apropos "word": Finds commands related to a specific word.

  • man "command": Displays the manual page for a specific command.

3. Setting Up Your Tools

  • Node.js: Essential for running JavaScript and npm.

  • npm (Node Package Manager):: Used to install and manage packages for your projects.

4. Understanding Your Home Directory (~)

Your home directory is where your personal files and settings are stored. You can access it using the ~ symbol.

5. Intro to Git

Git is a version control system that helps you track changes to your code.

  • git init: Initializes a new Git repository in your project.

  • git add .: Stages all changes for commit.

  • git commit -m "message": Commits the staged changes with a message.

  • git push: Pushes changes to a remote repository (e.g., GitHub).

  • git pull: Pulls changes from a remote repository.

6. Additional Tips

  • cat filename: Displays the contents of a file.

  • cat >> filename: Appends text to an existing file.

By mastering these fundamental commands and concepts, you'll be well on your way to becoming a proficient terminal user.


Hope that helped!