BeDeve
0.1 Get Started1. Home1.1 Linux AdministrationRun linux through a usb stickBasic commandsGit version controlProject folders organizingMarkdown1.2 Tutorials2.1 Web app architecture2.2 Developer Environment setup2.3 Javascript2.4 Mongodb2.5 Soundcloud Reverse Engineering3.1 Developer Operations3.1.1 Markdown CheatsheetContributingPull request templateReadme

Run linux through a usb stick

Create a custom image

Cubic is a custom Ubuntu ISO creator. With it you can take a standard Ubuntu ISO image, install all the third-party software you need, and then create a custom, bootable (and installable) image from that.

Install

Make a pestistent linux usb stick

Install mkusb

Change boot order in BIOS

uefi/legacy boot startup options

Basic commands

Filesystem

Terminal Keyboard Shortcuts

  • <Alt + . >: use the previous argument
  • <Ctrl + Shift + C>: copy the selected text
  • <Ctrl + Shift + V>: paste the clipboard text
  • <Ctrl + Shift + T>: open a new tabbed terminal in the same path

List directory contents

ls

Change directory

Command :

cd <folder_name>

Examples:

  • One folder back

    cd ..
  • Two folders back

    cd ../..
  • Previous directory

    cd -
  • User root directory

    cd ~

More

Create new file

Command :

touch <fileName>

Usage instructions:

  • Create multiple files

    touch <File1_name> <File2_name> <File3_name>
  • Change access time only

    touch -a <fileName>
  • Check whether a file is created or not. If not created then don’t create it. This command avoids creating files.

    touch -c <fileName>
  • Update access and modification time

    touch -c-d <fileName>
  • Change modification time only

    touch -m <fileName>
  • Use the timestamp of another file

    touch -r <second_file_name> <first_file_name>
  • Create a file using a specified time

    touch -t YYMMDDHHMM <fileName>

Edit file

Command :

nano <fileName>
or
nano

Keyboard Shortcuts:

  • Save a file
<Ctrl + o>
  • Cut an an entire line

    <Ctrl + k>
  • Select a particular string

    1. <Alt + A> with the cursor at the beginning of the string ONCE
    2. →/←/↑/↓ to select text
    3. <Ctrl + k> to cut only the selected text this time
  • Paste text

    <Ctrl + u>
  • Search for a word

    1. <Ctrl + w>
    2. Enter the word which you want to search
    3. Hit Enter and the tool will take you to the matched entry
  • Replace a word

    1. <Ctrl + \>
    2. Enter the word which you want to replace
    3. Enter the replacement word
    4. Press y/n repeatedly to confirm or not the changes in the whole document
  • Insert another file into the current one

    1. Move the cursor to the insert position
    2. <Ctrl + R>
    3. Give the path of the file
  • Display the cursor position

    <Ctrl + c>
  • Exit nano

    <Ctrl + x>
  • Convert tabs into spaces

    nano -E [filename]

Create New Folder

Command:

mkdir <folder_name>

example create a folder named lesson: mkdir lesson

Git version control

Install

In Linux debian based

sudo apt install git

Initialize repository

In the directory we want to track with git

git init

Configure git

##TODO Get info from https://alvinalexander.com/git/git-show-change-username-email-address

git config

Stage changes

  • Stage all changes in <file> for the next commit.

    git add <file>
  • Stage all changes in <directory> for the next commit.

    git add <directory>
  • Begin an interactive staging session that lets you choose portions of a file to add to the next commit. This will present you with a chunk of changes and prompt you for a command.

    Use y to stage the chunk, n to ignore the chunk, s to split it into smaller chunks, e to manually edit the chunk, and q to exit.

    git add -p

Examples:

  1. Add all files in the packages/linux directory

    git add packages/linux/*

  2. Add all files ending with .js in the packages/linux directory

    git add packages/linux/*.js

diff

commit

log

ignore

Create repo on github

add ssh key

add remote

push

pull

Examples:

  • Fetch all Git branches

    git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
    git fetch --all
    git pull --all

branch

To create and checkout a new branch

git checkout -b new_branch_name

stash

merge

To merge from another branch

git merge another_branch_name

resolve conflicts

Take code back in time (reset)

Examples:

  • Reset local repository branch to be just like remote repository

    git fetch origin
    git reset --hard origin/master

Project folders organizing

Markdown

Cheatsheet