Skip to content

Instantly share code, notes, and snippets.

@myriaglot
Created July 25, 2026 06:31
Show Gist options
  • Select an option

  • Save myriaglot/f6a335aa3639dc6657dba6296b33a005 to your computer and use it in GitHub Desktop.

Select an option

Save myriaglot/f6a335aa3639dc6657dba6296b33a005 to your computer and use it in GitHub Desktop.
linux advanced overview

Myria-glot Academy

Myria is the other word for 'many', alternative to 'poly'

Advanced Linux Tools, Editors, SSH, Git, sed, and awk

This guide continues from the Linux basics and introduces terminal shortcuts, text editors, text processing, remote server access, SSH keys, Git, and GitHub.


1. Terminal Keyboard Shortcuts

Shortcut Action
Ctrl+C Stop the current command
Ctrl+D End input or exit the terminal
Ctrl+L Clear the screen
Ctrl+R Search command history
Ctrl+A Move to the start of the line
Ctrl+E Move to the end of the line
Ctrl+U Delete before the cursor
Ctrl+K Delete after the cursor
Ctrl+W Delete the previous word
Tab Autocomplete
Up arrow Previous command
Down arrow Next command

View history:

history

Run the previous command:

!!

Use sudo with the previous command:

sudo !!

2. Viewing Files with more and less

more

more application.log

Controls:

  • Space — next page
  • Enter — next line
  • q — quit

less

less application.log

Useful controls:

Key Action
Arrow keys Move
Space Next page
b Previous page
g Beginning
G End
/error Search forward
n Next result
N Previous result
q Quit

Use less for large files and logs.


3. Editing with Nano

Nano is recommended for beginners.

Open a file:

nano notes.txt

Common shortcuts:

Shortcut Action
Ctrl+O Save
Enter Confirm filename
Ctrl+X Exit
Ctrl+W Search
Ctrl+\ Find and replace
Ctrl+K Cut line
Ctrl+U Paste
Alt+U Undo
Alt+E Redo

In Nano, the ^ symbol means Ctrl.

For example:

^X

means:

Ctrl+X

4. Editing with Vi or Vim

Open a file:

vi notes.txt

or:

vim notes.txt

Vim has modes.

Insert Mode

Press:

i

Then type normally.

Other insertion commands:

Key Action
i Insert before cursor
a Insert after cursor
o New line below
O New line above

Normal Mode

Press:

Esc

Use Normal Mode for navigation and commands.

Save and Exit

After pressing Esc:

:w

Save.

:q

Quit.

:wq

Save and quit.

:q!

Quit without saving.

Navigation

Key Action
h Left
j Down
k Up
l Right
w Next word
b Previous word
0 Start of line
$ End of line
gg Beginning of file
G End of file

Editing Commands

Command Action
x Delete character
dd Delete line
yy Copy line
p Paste
u Undo
Ctrl+R Redo
/word Search
n Next result

The minimum Vim survival commands are:

i
Esc
:wq
:q!

5. Text Replacement with sed

sed is a stream editor used to transform text.

Replace Text in Displayed Output

sed 's/old/new/' notes.txt

Replace all matches on each line:

sed 's/old/new/g' notes.txt

Edit the Original File

sed -i 's/old/new/g' notes.txt

Create a backup:

sed -i.bak 's/old/new/g' notes.txt

This may create:

notes.txt
notes.txt.bak

Print Specific Lines

sed -n '1,10p' notes.txt

Delete Lines

Delete line 3:

sed '3d' notes.txt

Delete lines 3 through 8:

sed '3,8d' notes.txt

Delete blank lines:

sed '/^$/d' notes.txt

Change a Configuration Value

Given:

PORT=3000

Change it to:

PORT=8080

Command:

sed -i.bak 's/^PORT=.*/PORT=8080/' .env

Always inspect the file before using sed -i.


6. Column Processing with awk

awk works well with columns and structured text.

Given:

jose developer active
anna designer active
mark tester inactive

Print the first column:

awk '{print $1}' users.txt

Print the first and second columns:

awk '{print $1, $2}' users.txt

Work with CSV Files

Given:

jose,developer,active
anna,designer,active

Print the first field:

awk -F',' '{print $1}' users.csv

Print name and role:

awk -F',' '{print $1, $2}' users.csv

Filter Rows

Print rows containing active:

awk '$3 == "active" {print $1}' users.txt

Process Command Output

Show process IDs and commands:

ps aux | awk '{print $2, $11}'

Show disk usage columns:

df -h | awk '{print $1, $5, $6}'

7. Useful Advanced Text Commands

Count Lines

wc -l application.log

Sort Lines

sort names.txt

Numeric sorting:

sort -n numbers.txt

Remove Duplicate Lines

sort names.txt | uniq

Count duplicates:

sort names.txt | uniq -c

Extract CSV Fields

cut -d',' -f1 users.csv

Replace Characters

echo "hello world" | tr ' ' '_'

Convert lowercase to uppercase:

echo "hello" | tr 'a-z' 'A-Z'

Write and Display Output

echo "Deployment complete" | tee deployment.log

Append:

echo "Second deployment" | tee -a deployment.log

8. Shell Scripts

Create a script:

nano hello.sh

Contents:

#!/usr/bin/env bash

set -euo pipefail

echo "Welcome to FWDP Academy"
echo "Current user: $(whoami)"
echo "Current directory: $(pwd)"

Make it executable:

chmod +x hello.sh

Run it:

./hello.sh

The first line is called a shebang:

#!/usr/bin/env bash

9. Environment Variables

Display common variables:

echo "$HOME"
echo "$USER"
echo "$PATH"

Create a temporary variable:

APP_ENV=development

Export it:

export APP_ENV=development

Display it:

echo "$APP_ENV"

Common shell configuration files:

~/.bashrc
~/.profile
~/.zshrc

Reload Bash configuration:

source ~/.bashrc

Never commit passwords, tokens, or private keys into Git repositories.


10. SSH Basics

SSH allows secure access to another computer.

Connect to a server:

ssh username@server.example.com

Using an IP address:

ssh jose@192.168.1.50

Using a custom port:

ssh -p 2222 jose@server.example.com

Exit the remote server:

exit

The first connection may ask you to verify the server fingerprint. Confirm it only when you trust the server.


11. Creating SSH Keys

Generate an Ed25519 key:

ssh-keygen -t ed25519 -C "your-email@example.com"

The default files are:

~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub

The private key is:

~/.ssh/id_ed25519

Never share it.

The public key is:

~/.ssh/id_ed25519.pub

Display it:

cat ~/.ssh/id_ed25519.pub

Recommended private-key permission:

chmod 600 ~/.ssh/id_ed25519

12. SSH Agent

Start the SSH agent:

eval "$(ssh-agent -s)"

Add the private key:

ssh-add ~/.ssh/id_ed25519

List loaded keys:

ssh-add -l

13. Installing a Public Key on a Server

Use:

ssh-copy-id username@server.example.com

Then connect:

ssh username@server.example.com

The server normally stores approved keys in:

~/.ssh/authorized_keys

Recommended permissions:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

14. SSH Configuration

Create:

nano ~/.ssh/config

Example:

Host fwdp-server
    HostName server.example.com
    User jose
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Set permissions:

chmod 600 ~/.ssh/config

Connect using:

ssh fwdp-server

15. Copying Files Through SSH

Copy with scp

Local file to server:

scp report.txt jose@server.example.com:/home/jose/

Server file to local computer:

scp jose@server.example.com:/home/jose/report.txt .

Copy a directory:

scp -r project/ jose@server.example.com:/home/jose/

Synchronize with rsync

rsync -av project/ jose@server.example.com:/home/jose/project/

With progress and compression:

rsync -avzP project/ jose@server.example.com:/home/jose/project/

Be careful with:

--delete

It removes destination files that are missing from the source.


16. Git and GitHub

Git is a version control system.

GitHub is an online platform that hosts Git repositories.

Git helps developers:

  • Track changes
  • Create branches
  • Review history
  • Work with teams
  • Restore earlier versions
  • Share projects

17. Configure Git

Set your name:

git config --global user.name "Jose Palala"

Set your email:

git config --global user.email "your-email@example.com"

Set the default branch:

git config --global init.defaultBranch main

View configuration:

git config --list

18. Create a Git Repository

mkdir demo-project
cd demo-project
git init

Create a file:

echo "# Demo Project" > README.md

Check status:

git status

Stage the file:

git add README.md

Commit it:

git commit -m "Add initial README"

19. Git Working Cycle

Working Directory
       ↓ git add
Staging Area
       ↓ git commit
Repository History

Common workflow:

git status
git diff
git add .
git commit -m "Add login validation"

20. Important Git Commands

Check Status

git status

Stage Changes

git add app.js

Stage all changes:

git add .

Interactively stage selected changes:

git add -p

Commit Changes

git commit -m "Fix invoice calculation"

Good commit messages describe the change clearly.

View History

git log

Compact history:

git log --oneline

Visual branch history:

git log --oneline --graph --decorate --all

View Differences

Unstaged changes:

git diff

Staged changes:

git diff --staged

21. Git Branches

Create and switch to a branch:

git switch -c feature/login

Return to the main branch:

git switch main

Merge the feature:

git merge feature/login

Delete the merged branch:

git branch -d feature/login

Common branch names:

feature/login
fix/payment-total
docs/installation-guide
refactor/user-service

22. Merge Conflicts

A conflict may look like:

<<<<<<< HEAD
Current branch version
=======
Incoming branch version
>>>>>>> feature/login

To resolve it:

  1. Open the file.
  2. Choose or combine the correct content.
  3. Remove the conflict markers.
  4. Test the result.
  5. Stage the file.
  6. Commit the resolution.
git add conflicted-file.txt
git commit

23. Undoing Git Changes

Discard unstaged changes:

git restore app.js

Unstage a file:

git restore --staged app.js

Change the latest commit:

git commit --amend

Reverse an old commit safely:

git revert COMMIT_ID

Dangerous commands include:

git reset --hard
git clean -fd

These may permanently remove uncommitted work.


24. .gitignore

Create:

nano .gitignore

Example:

node_modules/
vendor/
.env
*.log
dist/
build/
.idea/
.vscode/

Do not commit:

  • Passwords
  • API keys
  • SSH private keys
  • Database backups
  • Environment files containing secrets

Check whether a file is already tracked:

git status

25. Connect Git to GitHub Using SSH

Copy your public key:

cat ~/.ssh/id_ed25519.pub

Add it to your GitHub account under SSH keys.

Test the connection:

ssh -T git@github.com

Clone a repository through SSH:

git clone git@github.com:username/project.git

26. Push a Local Repository to GitHub

Create an empty repository on GitHub, then run:

git remote add origin git@github.com:username/project.git

Check the remote:

git remote -v

Push the main branch:

git push -u origin main

Future pushes can use:

git push

27. Pulling and Fetching

Download and merge changes:

git pull

Download changes without merging:

git fetch

Review remote changes:

git log --oneline main..origin/main

A safer team habit is:

git status
git fetch
git pull

Make sure local work is committed or safely stored before pulling major changes.


28. GitHub Collaboration Workflow

A simple team workflow is:

git switch main
git pull
git switch -c feature/new-page

Make changes, then:

git status
git add .
git commit -m "Add new page"
git push -u origin feature/new-page

After pushing:

  1. Open GitHub.
  2. Create a pull request.
  3. Request review.
  4. Resolve comments.
  5. Merge the pull request.
  6. Update your local main branch.
git switch main
git pull

29. Advanced Commands Worth Practicing

grep -Rni "searchText" .
find . -type f -name "*.log"
sed -i.bak 's/old/new/g' file.txt
awk -F',' '{print $1, $2}' users.csv
tail -f application.log
ssh user@server
rsync -avzP project/ user@server:/var/www/project/
git log --oneline --graph --decorate --all
git diff --staged
git switch -c feature/example

30. Safety Rules

  1. Check your current folder before deleting files.
pwd
ls -la
  1. Back up files before using sed -i.

  2. Never share SSH private keys.

  3. Never commit passwords or API keys.

  4. Avoid sudo unless required.

  5. Read commands before pasting them into a terminal.

  6. Use git status frequently.

  7. Commit small, understandable changes.

  8. Test code before pushing it.

  9. Treat production servers more carefully than local development machines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment