Codecademy Logo

Nmap Prerequisites

Print Cheatsheet

Intro to Linux

Linux is an open-source operating system that can be run on a wide range of devices. Linux can be operated without a graphical interface through a text terminal.

Open-source and Linux

Linux is one of the most prominent success stories of open-source software and its development of Linux is supported by a number of open-source non-profit organizations like the Free Software Foundation and Open Source Initiative.

Linux Kernel

The Linux kernel is part of the operating system that controls all the major functions of the hardware which include process management, managing hardware devices, and task scheduling.

Linux Shell

The Linux shell is a command-line interface between the user and kernel. Commands, typically using the Bash scripting language, are interpreted by the computer to perform a certain task.

Linux Distribution

A Linux distribution is an operating system that is based on the Linux kernel. Each distribution includes a different set of default software and tools.

Linux Ubuntu

Ubuntu is a beginner-friendly Linux distribution that offers a familiar desktop environment for users coming from more traditional operating systems. It provides a desktop environment and a suite of productivity tools to ease a transition to Linux.

OSI Model

The OSI Model is a conceptual, implementation-neutral model that describes networking in seven separate layers, where each layer covers a set of functions and tasks.

This model helps us communicate while we do network troubleshooting and architecture.

TCP/IP Model

The TCP/IP Model is an implementation-specific networking model that revolves around the TCP protocol and IP addressing which anchor the Internet as we know it.

Its layers include:

  • The Network Layer
  • The Internet Layer
  • The Transport Layer
  • The Application Layer

OSI Layers

The OSI layers include: Physical, Data Link, Network, Transport, Session, Presentation, and Application.

  • The Physical layer includes physical technologies
  • The Data Link layer includes data framing and local MAC addressing
  • The Network layer includes connecting to the larger web and IP addressing
  • The Transport layer includes protocols that make sure reliable delivery happens
  • The Session layer authenticates and maintains communication over a period of time
  • The Presentation layer en/decrypts and translates data into presentable form
  • The Application layer includes all the applications we interact with that render data

Network Categories

Three broad categories of networks include:

  • Local Area Network (LAN), a smaller-sized network that connects multiple devices in a small area
  • Campus Area Network (CAN), a larger network that connects multiple computers and devices over a slightly larger area
  • Wide Area Network (WAN), the largest-sized network that connects multiple computers, over a geographically large area

The Internet is technically a WAN.

Network

A network is two or more computers or devices that are linked in order to share information.

Networking refers to a large set of standards and protocols that organize and regulate the sharing of information.

Network Protocols

A network protocol is a set of standards for Internet traffic.

Among them are the big transport protocols:

  • TCP and UDP
  • HTTP for web requests
  • DNS to convert domain names to IP addresses
  • IMAP/POP3 for email
  • SSH
  • FTP
  • SMB for access to specific resources

pwd Print Working Directory

The shell command pwd displays the file path from the root directory to the current working directory.

$ pwd
/Users/sonny/Downloads

mkdir Make Directory

The shell command mkdir is used to make a new directory in the filesystem according to its argument. If a file path is given, the new directory will be placed at the end. Otherwise, it will create a new directory in the current working directory.

$ mkdir new-directory
$ ls
old-directory new-directory

ls List

The shell command ls is used to list the contents of a directory. If no arguments are given, it will list the contents of the current working directory.

$ ls Desktop
resume.pdf
photo.png

cd Change Directory

The shell command cd is used to move throughout the filesystem of a computer. It accepts a variety of arguments:

  • Full file paths.
  • Names of children of the current directory.
  • .. the parent of the current directory.
$ cd some-directory
$ cd ..

Filesystem Structure

A computer’s filesystem organizes the data stored by a computer, so that it can be easily retrieved by the user.

Files are generally represented in a tree-like structure, in which any parent directory can have any number of children. The root directory is then found at the base of the tree.

touch Create New File

The shell command touch creates a new file in the current working directory with the name provided.

$ touch grocery-list.txt

The Command Line

The command line allows a user to navigate the filesystem and run built-in programs or custom scripts. In Unix, the command line interface is called Bash, and the shell prompt is the $.

$

Helper Commands

Helper commands for the command line include:

  • clear to clear the terminal
  • tab to autocomplete the line
  • and to cycle through previous commands

cp Copy

The shell command cp is used to copy files or directories.

The basic argument structure is cp source destination, where the source is the file/directory to copy to the destination file/directory.

$ cp file1 file1_copy
$ cp file1 file2 destination_folder

Command Options

Options can be used to modify the behavior of shell commands. Shell command options are commonly represented by a single letter preceded by a -. For example, -l, -a, and -d could all be options that follow a shell command.

mv Move

The shell command mv is used to move a file into a directory. Use mv with the source file as the first argument and the destination directory as the second argument.

$ mv index.html website/

rm Remove

The shell command rm is used to delete files and directories. The -r flag deletes a directory and all of its files and directories (rm -r).

$ rm -r bad_selfies

ls List Command Options

The shell command ls is used to list the contents in a directory. It can be combined with the following command options:

  • -a: lists all contents, including hidden files and directories.
  • -l: lists all contents, in long format.
  • -t: lists all contents, by the time they were last modified.
$ ls -a
$ ls -l
$ ls -t