About Linux

Premise

I will write what I learned about Linux.

Linux boot process and systemd

  1. Power on
  2. Firmware (BIOS / UEFI) operation --Call the boot loader 3, boot loader --kernel and ramdisk
  3. Start the kernel --Memory initialization and hardware recognition
  4. Start service with systemd (init)
  5. Login prompt display

init and systemd

・ Mechanism to start the service --init: SysVinit (System File Init) Conventional --systemd: Adopted in current Linux

systemd daemon

-Daemon (process that is always running in the background) --systemd (main) --systemd-journald (journal management process, log management) --systemd-logind (login process) --systemd-udevd (device dynamic detection)

systemd and Unit

・ Unit (processing unit) --Controlled by systemctl command --Type ・ Service (start various services) httpd, sshd, etc. ・ Device -Mount (file system) / etc / fstab ・ Swap (Enable swap area. Disk to memory) ・ Target (group multiple units)

systemctl command

・ Start, stop, restart ・ Status ・ Is-active ・ Enable, disable (automatic start) ・ List-units -List-unit-files (list of unit-file, status, etc.) ・ List-dependencies

Enable / disable services

[Systemd startup order] -Default.target is called first. Associate with ・ Lambert (init) and target (systemd)  0、poweroff.target

  1. rescue.target (rescue mode, single user mode) 2-4, multi-user.target (multi-user mode)
  2. Units under graphical.target (GUI mode) are also called ・multi-user.target     basic.target 6, reboot.target (reboot)

Isolate mode change

$ systemctl isolate rescue.target

OS shutdown / restart

shutdown -h +10 "this host will shutdown in 10 minutes"

-option
・ H(halt)Stop
-r(reboot)Reboot
-k(test)Test without stopping
・-c(cancel)Shut down waiting for countdown
-f(no fsck)Do not check files on reboot
-F(fsck)Check files on reboot

-Execute the command to shut down after 15 minutes and cancel -h (halt / stop) + minutes "message"

$ su -
# shutdown in 15 "this host will shutdown in 15 minutes!!"
# shutdown -c

Shutdown command and wall command

-Similar commands Stop ・ Halt, poweroff, init 0 ・ Systemctl poweroff target Reboot ・ Reboot, shutdown reboot, init6 -Systemctl reboot.target notification ・ Wall (Notify all at once without stopping)

# wall "this host will stop 20:00 p.m."

Display process list with ps command

・ From process creation to extinction

-Ps command to check the process --PID: Process ID

options for the ps command ・ BSD format --a (all), f (parent-child relationship), l (details), x (no terminal) --pstree can substitute f

-Unix format --- e (all), -f (details), -l (details)

Process management related commands ・ Ppgrep (search) ・ Top (status every 3 seconds) ・ Uptime ・ Free (free memory)

Process stop

-Kill option PID /% job num.  - 1 (HUP)hang up  - 2 (INT)interrupt ―― 9 (KILL) kill / forced termination --15 (TERM) terminate / end  - 20 (TSTP)suspend(Ctrl+D)

· Killall process name · Pkill process name

Use of desktop environment

Integrated desktop environment

File directory owner

r = 4 w = 2 x = 1

rwxr-xr-x (4+2+1)(4+0+1)(4+0+1) = 755

Change of owner / group / authority ・ Chown  - change owner ・ Chgrp  - change group ・ Chmod  - change mode

Read / write permissions with the chmod command

# chmod u-r hello.txt
# chmod u+r hello.txt

File archiving and compression / decompression

・ Tar command d (tape archive) --Option ・ C (create) ・ X (expansion) ・ T (information display) ・ V (verbose) ・ F (filename) ・ Z (compressed with gunzip) --Often use cvzf (created) and xvzf / xzf

・ Cpio, dd command



Shell function

・ The role of the shell --Accept user input and instruct the kernel

・ Check the type of shell

echo $SHELL
env | grep SHELL

Shell variables / environment variables

・ Check LANG

echo $LANG

・ PATH variable

PATH=$PATH:PATH you want to add
PATH=$PATH:/home/h/temp

-Reflect shell variables in environment variables Shell variables cannot be referenced by child processes Environment variables can be referenced by another child process

・ Say_hello

man command

・ Man [option] [section] keyword  - -a(all) --- f (exact match) fully matched --- k (partial match) keyword match

File reference

・ Cat: concatenate --- n: Line number display ・ The nl command can be used as a substitute. --Concatenate the contents of the file and output ・ Head / tail --Number of lines, -n Number of lines --- f (continuous display)

Redirects and pipes

·redirect --Write mode -Command> File (Overwrite) ・ Command >> File (append) --Option ・ Command 2> File -Command> File 2> & 1 · Command $ file -Command << EOF> file

pipe and tee commands

-Output to both standard output and file

· Command | tee file name --Inject the execution result of the first command into the tee command with a pipe (|) --Output to standard output and file

xargs command

-Use the command execution result as the argument of the next command

vi editor

・ Standard on Linux / Unix --Required for system management work and server settings

・ Two types of modes --Command mode <=> Input mode --Command mode is search, delete, copy, paste --Input mode (switch between i, a, o) Text input

Move cursor

・ H, j, k, l --Left, bottom, top, right

・ Move --w (beginning of word), b (previous word) --e (end of word, end) --0 (beginning of line), $ (end of line)

・ Search -/ kw, n (backward search) ――? kw, N (forward search)

Text manipulation

・ Cw (word replacement), c $ (until the end of line) ・ Y (copy), yy (line copy) ・ Cw (delete one character) ・ D (delete), dd (line), dw (word), d $ (end of line) ・ P (paste) ・ U (undo) ・ R File name (insert file contents)

Security

SUID and SGID

・ Three special permissions

Network basics

How TCP / IP works

・ Communication protocol (one of the rules) --Technical standards such as communication procedures and data formats ・ Proposed and standardized by IEEE, IETF, etc. --Send / receive in packet (data division, header addition)

Each layer of the header (Layer)

・ Four more information is stored in the header --Network interface layer ・ Ethernet, PPP ,,, --Internet layer ・ IP, ICMP (* ping), ARP (MAC address) --Transport layer ・ TCP, UDP (* streaming) --Application layer ・ FTP, SSH, Telnet, DNS, HTTP, IMAP4, POP3 ,,,

TCP and UDP

・ TCP confirms the arrival of data --Retransmit packet if insufficient

・ Packet transmission unilaterally without checking UDP --Highly real-time applications such as video distribution

Pod number

-Host is identified by IP address -Communication using different communication ports (/ etc / services)

Recommended Posts

About Linux
About Linux
About Linux
About Linux
About Linux ①
[Linux] About export
[Linux] About PATH
Linux (about groups)
Linux (about directory path)
About Linux kernel parameters
Basic knowledge about Linux
Linux
About Linux environment construction (CentOS)
Linux (about files and directories)
Linux (About adding / removing users)
About LINUX files and processes
What I learned about Linux
About LangID
About CAGR
linux memorandum
Linux command # 4
About virtiofs
Linux commands
About python-apt
Linux commands
About Permission
About sklearn.preprocessing.Imputer
About gunicorn
Linux command # 3
Linux overview
About requirements.txt
About locale
Linux basics
About permissions
direnv (linux)
Organize Linux
About axis = 0, axis = 1
linux commands
About Opencv ③
About Linux environment construction (VMware VirtualBOX)
Ubuntu Linux 20.04
Linux Summary
Linux process
Linux permissions
About numpy
Linux command # 5
About pip
Linux basics
About numpy.newaxis
Forgot linux
About endian
About import
Linux commands
Linux commands
About Opencv ①
About Linux commands Super basic edition
Beginners have learned about Unix (Linux).
About cv2.imread
About _ and __
About wxPython
Linux redirect