# Linux Notes

# Architecture

Architecture

# Kernel

The kernel acts as the core of the Linux system. It's responsible for managing hardware resources, memory allocation, process scheduling, and communication between different parts of the system. You can think of it as the conductor of the orchestra, keeping everything in sync.

Important linux components

# Shells

The shell acts as the user interface for Linux. It allows you to interact with the system by issuing commands. There are different shell options available, like Bash or Zsh.

Linux shells

# File

# File systems

Linux File systems

# File types

Linux File types

# Permissions

Linux Permissions

# Permission Types

  • r: read
  • w: write
  • x: execute

Bitwise

EXECUTE   =>  001  =>  1 
WRITE     =>  010  =>  2  
READ      =>  100  =>  4

# User types

  • u: user - the owner
  • g: group - members of file's group
  • o: others - neither owner nor group

# Commands

  • chown: change the owner
  • chgrp: change the group
  • chmod: change permissions

Example

chmod 600 filename
  • owner: 6 (110) => WRITE + READ
  • group: 0
  • other: 0

# Redirections

By default, commands receive instructions from the keyboard (standard input) and display results on the terminal (standard output). Redirection lets you modify this behavior.

Here's a breakdown of the key concepts:

  • Standard Input (stdin): This refers to the data a command receives, typically typed on the keyboard.
  • Standard Output (stdout): This is where the command sends its results, usually displayed on the terminal window.
  • Standard Error (stderr): This is a separate stream used by commands to report errors or warnings, also shown on the terminal by default.

Redirections cheatsheet

Operators

  • > (output redirection): This sends the standard output (stdout) of a command to a file. Any existing content in the file will be overwritten.
  • >> (append redirection): Similar to >, but instead of overwriting, it appends the output to the end of the existing file.
  • < (input redirection): This feeds the contents of a file as standard input (stdin) to a command.

# Logical volume management (LVM)

lvm

# Linux admin tips & tricks

Linux admin tips & tricks

# Commands / Tools

# Basic commands

Basic commands

Commands cheatsheet

Important commands

# Log parsing tools

Log parsing

Log parsing 2

  • group
  • ngrep
  • cut
  • sed
  • sort
  • uniq
  • diff
  • awk
  • head / tail
  • less
  • comm
  • csvcut
  • jq
  • tr
  • ccze

# Network tools

Networking tools

# Datetime

Ubuntu

cat /etc/timezone

Output example: Australia/Melbourne

Another way

date +%Z

Output example: AEDT. Check list here (opens new window)

# Sử dụng Vi

SGK (opens new window)

Tóm tắt lệnh hay xài

  • Esc để chuyển đổi qua lại từ command mode với insert mode.
  • :w! lưu tập tin
  • :x! lưu tập tin và thoát
  • :wq ZZ lưu tập tin và thoát
  • :q! không lưu và thoát

# Sử dụng Nano

SGK (opens new window)

  • Ký hiệu ^ thay cho phím Ctrl
  • Ctrl+O lưu file
  • Ctrl+X thoát khỏi editor (có thể cần ấn thêm Y/N)
  • Ctrl+W search