Sunday, April 2, 2017

Arch Linux Cheat Sheet

This walkthrough is largely based on this video walkthrough.

I. Download and Run Arch Linux iso

  2. burn to 
    • disk: Use normal utility (In Windows, right-click .iso file to burn to disk)
    • usb: Use unetbootin
  3. Insert disk or usb and restart computer to boot into Arch Linux
    • An Arch Linux graphic and an options menu should appear
  4. Select option     Boot Arch Linux (x86_64)                       
  5. You should go through a text boot process and then eventually see a command prompt.

II. Partition, Format, Mount

A. Create Disk Partitions with fdisk

  1. type: fdisk -l and note the location of the disk (/dev/sda here)
  2. type: fdisk <disk location>
  3. enter: o to reset the drive
  4. create new partitions
    1. enter: n to create a new partition
    2. enter p or l for primary or logical
    3. enter start point (usually stick with default by pressing enter)
    4. enter end point (enter as +30G for a 30 gigabyte partition)
  5. enter partition types
    1. enter 'type'
    2. select partition number to alter 
    3. select type number
      • (83 for Linux partitions)
      • (82 for swap partitions)
      • (this is not formatting. formatting will be done next)
  6. Finally enter w to save partitions and exit fdisk

B. Format ext4 Partitions with mkfs

  •  example
    • mkfs.ext4 /dev/sda1
  • example
    • mkfs.ext4 /dev/sda3 

C. Mount Filesystem to Partitions for Installation

  1. mount the root partition to /mnt
    • example: mount /dev/sda3 /mnt
  2. make directories (such as /boot and /home) in the /mnt directory
    • example: mkdir /mnt/boot
    • example: mkdir /mnt/home
  3. mount those directories to their respective partitions
    • example: mount /dev/sda1 /mnt/boot
    • example: mount /dev/sda4 /mnt/home

III. Set Up WPA Wireless Networking

  1. Find your computer's interface names by entering: 'ip link' or 'ip a'
    • a wireless interface will start with 'w' if it starts with 'e' (or 'enp'), then it is most definitely not a wireless interface.)
  2. Make sure you know your wireless SSID and passcode from your home router
  3. Copy a wpa wireless config template: cp /etc/netctl/exmaples/wireless-wpa /etc/netctl/<name>
    • name the file whatever you want to.
    • keep the filename simple and memorable
  4. Edit the wpa config template: vim /etc/netctl/<name>
    • edit Interface= to be the name of the wireless interface from the 'ip link' command
    • edit ESSID='<router>' to be the SSID of your wireless router you'd normally see
    • edit Key='<key>' to be whatever your router's passkey is
  5. Start the wireless interface with: netctl start <name>

IV. Install and Configure the System

A. Install the system

  1. pacstrap -i /mnt base 
  2. genfstab -U /mnt >> /mnt/etc/fstab 
  3. arch-chroot /mnt
  4. pacman -S vim openssh grub-bios linux-headers linux-lts linux-lts-headers wpa_supplicant wireless_tools

B. Configure language

  1. vim /etc/locale.gen
    1. un-comment your language (en_US.UTF-8 UTF-8)
    2. save file
  2. enter: locale-gen

 C. Configure time

  1.  ln -sf /usr/share/zoneinfo/<Region>/<City> /etc/localtime
    • example: ln -sf /usr/share/zoneinfo/American/New_York /etc/localtime
  2. hwclock --systohc --utc
    • Runs hwclock(8) to generate /etc/adjtime:

D. Enable SSH at startup

  • systemctl enable sshd.service

E. Set Password

  • passwd

F. Install Grub bootloader

  1. grub-install --target=i386-pc --recheck /dev/sda
  2. cp /usr/share/locale/en\@quot/LC_MESSAGES/ /boot/grub/locale/
  3. grub-mkconfig -o /boot/grub/grub.cfg

Thursday, February 2, 2017

Rust Programming Language

Rust is a Well Planned Modern Language Comparable to C++ Developed Largely by Mozilla

System Update

To make sure that all of Rust's dependencies are up-to-date, run the following commands.
apt-get update
apt-get dist-upgrade -y
apt-get install curl

Install Rust

Installing Rust is a simple process. Run the following command to launch their installation script.
curl -sSf | sh
When the script finishes, Rust will be installed.

Verifying Rust

To verify that Rust was successfully installed, run rustc -V. You will see output similar to:
rustc 1.0.0 (a59de37e9 2015-05-13) (built 2015-05-14)

Using Rust

To use Rust, create a file called and populate it with the following lines of code:
fn main() {
    println!("You have successfully installed rust!");
Now run rustc You will see an executable file called main in the same directory. Execute it by running ./main. The text "You have successfully installed Rust!" will appear on your screen

[The above installation instructions were taken from here.]

Create a New Project with Cargo

cargo new <project name>

There should be a new project folder with an src folder in it
Create a file in the src folder
Write code in the file
To run the project, navigate to the project folder (not inside the src folder)

cargo run

  Compile and Build Executable