Sunday, April 2, 2017

Arch Linux Cheat Sheet

This walkthrough is largely based on this video walkthrough.
https://wiki.archlinux.org/index.php/Installation_guide

I. Download and Run Arch Linux iso

  1. https://www.archlinux.org/download/
  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/grub.mo /boot/grub/locale/en.mo
  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 https://static.rust-lang.org/rustup.sh | 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 main.rs and populate it with the following lines of code:
fn main() {
    println!("You have successfully installed rust!");
}
Now run rustc main.rs. 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 main.rs file in the src folder
Write code in the main.rs file
To run the project, navigate to the project folder (not inside the src folder)
enter:

cargo run

  Compile and Build Executable

rustc main.rs

Friday, September 23, 2016

Install pygame for Python 3 on Ubuntu

  1. sudo apt-get install python3-pip
  2. sudo pip3 install --upgrade pip
  3. sudo pip3 install pygame

Wednesday, August 24, 2016

Run a Personal MediaWiki

This guide is about quickly running an offline Mediawiki in a virtual machine.


It can also serve as a first-time primer for using and communicating with a Linux server.


However, this guide is NOT an example of effective server management.




MediaWiki is a chore to set up and use, but I love its versatility too much to not have one for my own.





Install VirtualBox

sudo apt-get install virtualbox


Download TurnKey MediaWiki

https://www.turnkeylinux.org/mediawiki



Set Up Your Virtual Server

Open the downloaded file with Virtualbox.

Follow guided steps to create usernames and passwords.


Start and Stop VM from a Script or Launcher Icon

Your VM's name is in VirtualBox. Open VirtualBox, and select the VM. It appears on the right next to "Name:"

VBoxManage startvm "vm name" --type headless

VBoxManage controlvm "TURNKEY MEDIAWIKI" acpipowerbutton



See Your Wiki From Your Browser

Type your the VM IP address into the browser.

Interact with wiki by creating a user and a new page.



Interact With Virtual Server Remotely

Move a new logo to your server via scp.




Log in to edit LocalSettings.php via ssh.










Friday, August 19, 2016

Walkthrough for Lubuntu with i3 Tiling

At the time of this writing, Lubuntu is getting the LXQt treatment either for version 16.10 or 17.04.

See the Xubuntu version of this here.

One key difference in Xubuntu is its "Whisker Menu", which acts in place of dmenu. Lubuntu and LXQt do not seem to have a keystroke-activated applications menu. (like every other OS)


The idea of this setup is to achieve the best of both worlds from convenient desktop features and essential i3 features. This walkthrough assumes that you are already familiar with using i3, but you do not have to be in order to complete it. An altered default i3 config file is part of the walkthrough, which adapts default i3 keystrokes to LXQt components. (New and replaced sections of the config file are designated in the file.)



  • Use the familiar i3 keystrokes and config file for window tiling.
  • Access normal application menus. (dmenu still available)
  • Desktop notifications/indicators (not typically easy to find for i3)
  • Fixes the administrator authentication problem when using i3 in Ubuntu.
    • Software Center
    • Updater
    • Users and Groups
  • Elegant color scheme and icons





For this guide, you will need to enter terminal commands, but you should not expect to remember them. Conversely, you will always want to understand the i3 config file. The last step will be to create a link to the i3 configuration file on you XFCE panel - to provide a visual reminder that it is central to your user experience, and conveniently available to open and edit.

The i3 site provides the best source about editing the configuration file.


I. Preliminaries

  • You should have LXQt on Lubuntu. This is releasing officially in October 2016, but can be rigged before then.
  • You might want to create a spare user for this, but the settings are not as difficult to reverse as, say, with the walkthrough with Xubuntu.






You should have an LXQt Panel desktop that looks a lot like this:
 
Hint:












 

II. Install i3 and Background Image Manager

i3 is of course the tiling window manager.
Nitrogen is the replacement wallpaper image manager.
  1. Open a terminal
  2. Enter the following:














III. Configure the background image manager: Nitrogen

  1. Open Nitrogen: Accessories >> Nitrogen
  2. Click the button: "Preferences"
  3. Add any folders that you include your wallpaper images: 
  4. Click button: "OK"
  5. Click the dropdown menu on bottom left and select: "Zoomed Fill"
  6. Click the button: "Apply" and exit Nitrogen.








IV. Paste the i3 config file

Let's get down to brass tacks and just do this thing.
  1. In Lubuntu, there should be a directory in your user's home directory named '.config/i3'
    • The file path will be like: /home/<yourusername>/config/i3/
    • If the i3 directory is not there, then take the liberty of creating it: "i3"
  2. Create a new file in the i3 directory named "config"
    • the file path will be like: /home/<yourusername>/.config/i3/config
  3. Open the config file in a text editor and save the following in the file:



The i3 site provides the best source for editing the configuration file.


















IV. Set i3 as the Session Window Manager

  1. Open LXQt Session Settings: Preferences >> LXQT Settings >> Session Settings
  2. Click on the Window Manager dropdown box that reads: "openbox" 
  3.  Scroll down the long menu of options until you reach i3, and select i3:  
  4. For "LXQt Modules", uncheck "Desktop" and "Global Keyboard Shortcuts"    
  5. Click the button: "Close" and "OK" on the notification of changes:                               












Here is the magic moment when you can restart your computer and log in with i3 as your window manager.

 
 



i3 cheat sheet

The mod key is the 'super key', also called the 'windows key' (left of the space-bar.)

mod+Enter opens a terminal

mod+d opens the dmenu
mod+Shift+q closes the current window tile
mod+r initiates resize-tile mode
mod+1, mod+2, etc. (1-0) switches to a different workspace
mod+Shift+1, mod+Shift+2, etc. (1-0) moves the current window tile to a different workspace
mod+Shift+e initiates Lubuntu's session logout dialogue
















V. Configure the LXQt Panel

  • Configure the "Desktop Switcher"
    1. Right-click the desktop switcher
    2. Select the option: "Configure "Desktop Switcher""
    3. Change the dropdown: "Desktop labels" to be: "Names"










VI. Configuring Theme and Icons

As of the creation of this walkthrough, I still found it useful to configure the appearance using the old LXDE method and the new LXQt method:
  • Preferences >> Customize Look and Feel
  • Preferences >> LXQt Settings >> Appearance
    • Dark icons and dark panel look better in my opinion








VII. Try Everything on For Size

If the i3 config file is set up correctly, then all the standard keystrokes should work.









Thursday, May 19, 2016

Page-Specific Gadget Content


This is a feature idea for Google Blogger.

This feature would allow bloggers to display soft classes of information to blog readers on a per-page basis, via sidebar Gadgets like the "Text" and "Links" Gadgets. This would allow Blogger blogs to have a more dynamic feeling with minimal extra data and feature disruption.

The user would primarily interact with this feature while editing a Page.

When a user is editing a Page, there would be a heading called "Page-Specific Content" under "Page Settings".

When the heading is clicked, a list of Gadgets appears. These would be Gadgets that the user already chose in Layout mode. These would also be Gadgets altered to allow for page-specific content. (This would most notably be the "Text" and "Links" Gadgets.)

Default Gadget content is still defined from Layout mode (as it is presently.)

Saturday, November 21, 2015

Xubuntu with i3 Tiling Windows Walkthrough

Also look up Manjaro i3. Manjaro is an Arch Linux distro.
See the Lubuntu version of this here.

The idea of this setup is to achieve the best of both worlds from convenient desktop features and essential i3 features. This walkthrough assumes that you are already familiar with using i3, but you do not have to be in order to complete it. An altered default i3 config file is part of the walkthrough, which adapts default i3 keystrokes to XFCE components. (New and replaced sections of the config file are designated in the file.)




  • Use the familiar i3 keystrokes and config file for window tiling.
  • Utilize normal application names instead of binaries'. (dmenu still available)
  • Desktop notifications/indicators (not typically easy to find for i3)
  • Fixes the administrator authentication problem when using i3 in Ubuntu.
    • Software Center
    • Updater
    • Users and Groups
  • Elegant color scheme and icons


As usual, i3 is brought to you by the letter i and by the number 3 . . . and by Dexter.

For this guide, you will need to enter terminal commands, but you should not expect to remember them. Conversely, you will always want to understand the i3 config file. The last step will be to create a link to the i3 configuration file on you XFCE panel - to provide a visual reminder that it is central to your user experience, and conveniently available to open and edit.

The i3 site provides the best source about editing the configuration file.


I. Install Xubuntu on your system

Install the Xubuntu desktop in another Ubuntu variant by entering the following in a terminal:






(The general idea of this walkthrough should work for XFCE and Mint XFCE as well.)

 

 II. Create a Spare User

Especially if you are already using Xubuntu, creating a spare user account ensures that you can easily return to Xubuntu's default desktop.
  1. Open 'Users and Groups'
  2. Click button: 'Add'
  3. Type in your current admin password
  4. Enter a Name title
  5. Enter the official username
  6. Click button: 'OK'
  7. Enter the new user's password
  8. Click button: 'OK'
  9. Click 'Change...', next to 'Account type'
  10. Change the account type to 'Administrator
  11. Click button: 'OK'
  12. Click button: 'Close'
  13. Log out
  14. Select the Xubuntu desktop 
  15. Log in to the new user





III. Install a new background image manager

Xubuntu's desktop settings manager will not work with this setup, but luckily you can install "nitrogen" to change background images. Only remove xfdesktop4 if you (Unfortunately wallch does not work with i3.)






Nitrogen is simple and plays well with i3. It has the ability to set different wallpapers for different monitors or to expand one wallpaper between them.

  1. Open Nitrogen.
  2. Click "Preferences"
  3. Click "Add"
  4. Add any folders you use for background images
    • /usr/share/backgrounds
    • /usr/share/xfce4/backdrop






IV. Install the i3 Window Manager

Enter the following in a terminal to install the i3 window manager:











V. Install i3ipc-GLib and i3 Workspaces Plugin

This is a prerequisite for being able to switch between i3 workspaces in XFCE.


Open a terminal and enter the following:

(The details of this source are found here.)
  • Installing individual sources like this should be done rarely. There is a slight security risk, and it can slow down apt updates 



 


This wonderful plugin allows you to place an i3-compatible workstation switcher on your XFCE panel.

Open a terminal and enter the following:

(The details of this source are found here.)
  • Installing individual sources like this should be done rarely. There is a slight security risk, and it can slow down apt updates








VI. Deactivate Xubuntu's window manager


  1. Open 'Session and Startup', and go to the 'Session' tab.
  2. Note xfwm4 and xfdesktop. These processes will be replaced by the i3 Window Manager.
  3. For xfwm4, click 'Immediately' and change it to the  'Never' option.
  4. For xfdesktop, click 'Immediately' and change it to the 'Never' option.
  5. Click the button: 'Save Session'.
  6. Go to the 'Application Autostart' tab to activate the i3 window manager in the next stage.

Note that you leave the xfce4-panel and Xfsettingsd as they are.










VII. Activate the i3 window manager

  1.  In the 'Session and Startup' window, make sure you are in the 'Application Autostart' tab.
  2. Click the button 'Add' to add i3 to the list of startup applications.
  3. Fill out the form:
    • Name: i3 (or whatever you want to call i3)
    • Description: Tiling Window Manager (or whatever you want)
    • Command: i3 (must be "i3", as below)
  4. Click the button: OK
  5. You should scroll down to the bottom of the list and verify that i3 is listed and checked.
    • (Yes, the intimidating terminal command to start i3 is . . . i3.)
  6. Click the button: Close








VIII. Remove non-i3 Keyboard Shortcuts

Disabling the shortcuts here is about letting i3 take over in this regard, utilizing the i3 config file. Although my general philosophy is to avoid getting technical wherever possible (ie: avoid using a config file when a GUI is available), managing keyboard shortcuts through the i3 config file is inevitable if you want to use i3 at all. For the sake of peace-of-mind, as well as avoiding strange conflicts, I say avoid using 2 different applications for managing keyboard shortcuts. In this guide, ALL keyboard shortcuts are defined by the i3 config, rather than some here and some there. bleh.

  1. Open the 'Keyboard' dialogue.
  2. Go to the 'Application Shortcuts' tab as above.
  3. Remove all keyboard shortcuts
    • You can shift-select all of them and click the button: 'Remove
  4. Click the button: Close









IX. Paste i3 config

Let's get down to brass tacks and just do this thing.
  1. Create a directory in your user's home directory named '.i3'
    • The file path will be like: /home/<yourusername>/.i3/
  2. Create a new file in the .i3 directory named 'config'
    • the file path will be like: /home/<yourusername>/.i3/config
  3. Open the config file in a text editor and save the following in the file:



The i3 site provides the best source for editing the configuration file.





Here is the magic moment when you can restart your computer and log in with i3 as your window manager.



i3 cheat sheet

The mod key is the 'super key', also called the 'windows key' (left of the space-bar.)

mod+Enter opens a terminal
mod+d opens Xubuntu's whisker menu (in place of the dmenu)
mod+Shift+d opens the dmenu
mod+Shift+q closes the current window tile
mod+r initiates resize-tile mode
mod+1, mod+2, etc. (1-0) switches to a different workspace
mod+Shift+1, mod+Shift+2, etc. (1-0) moves the current window tile to a different workspace
mod+Shift+` (` is left of '1') Moves a window tile to the scratch-pad workspace
mod+` Reveals/hides the scratch-pad workspace
mod+Shift+e initiates Xubuntu's session logout dialogue










X. Configure the XFCE Panel


  1. Right-click the XFCE Panel at the top of the screen.
  2. Select the menu option 'Panel >' and then 'Panel Preferences'
    • The panel preferences dialogue should open
    • This looks different in Xubuntu 16.04.
  3. Click on the plus button to add the i3 workspaces plugin you installed earlier.
  4. Use the arrows to place the i3 workspaces plugin where you want it on the panel.
  5. Click the gear button, and configure the i3 workspaces plugin with colors that will show up on the panel.
    • I like to incorporate the i3 window color, which is #285577
  6. Remove the 'Window Buttons' from the panel items by selecting it and clicking the minus button.
  7. You can change the icon on the 'Whisker Menu' so that it is not an infantile mouse icon.
  8. Add or remove any application launchers to the panel.






XI. Create a launcher for i3's config file

  1. In the XFCE Panel items list, add a launcher next to the clock in order to create convenient access to the i3 config file.
  2. Edit the launcher details to be as below
    • Click the icon to change it. (The icon above is included with xubuntu-desktop)
    • Name: i3 Config
    • Command: mousepad config
    • Working Directory: /home/<yourusername>/.i3

The i3 site provides the best source about editing the configuration file.