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.
Make a pestistent linux usb stick
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 ~
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>ornano
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 ONCE2. →/←/↑/↓ to select text3. <Ctrl + k> to cut only the selected text this timePaste text
<Ctrl + u>Search for a word
1. <Ctrl + w>2. Enter the word which you want to search3. Hit Enter and the tool will take you to the matched entryReplace a word
1. <Ctrl + \>2. Enter the word which you want to replace3. Enter the replacement word4. Press y/n repeatedly to confirm or not the changes in the whole documentInsert another file into the current one
1. Move the cursor to the insert position2. <Ctrl + R>3. Give the path of the fileDisplay 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:
Add all files in the packages/linux directory
git add packages/linux/*
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"; donegit fetch --allgit 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 origingit reset --hard origin/master