Course Content#
Basic Usage of vim#
- Quick Navigation
- Beginning of line: 0 [^ Effective beginning of line]
- End of line: $
- Beginning of file: gg
- End of file: G
- Any line: 12G——jump to line 12
- Copying
- Copy
- Cut
- Multi-line operations
- Deletion
- x: delete one character
- d
- 2dd: delete 2 lines from the current line
- d2G: delete from line 2 to the current line
History of Linux#
- C Language: How did it come about? How closely is it integrated with the system?
- The essence of Linux [Linux generally refers to the Linux kernel, Linux operating system]
- Differences between Linux and Windows [Linux's early attitude towards users: those who know it say it's good, those who don't can do as they please]
- Unix [MacOS; after Google proposed cloud computing, the manufacturers of Unix systems are basically left with Apple]
Shell#
- zsh
- Related Files
- Concept of environment variables: exists in the shell process
- The essence of executing commands: mostly executing files, opening a child process [to ensure commands do not interfere with each other], the child process ends after running, returning results
- man
- Simplified version: tldr
- English language sense
- Retrieval: move forward and backward——N/n
- C language low-level library functions
- Search engines [Google English search]: improve your information processing ability
- How to find commands
- tab [provided by zsh]
- man -k [-f: search based on specific words]
- apt search [apt-cache search]
Specific Usage of Linux#
- Files and Directories
- Remote Copying
- scp [based on ssh->based on tcp]
- sshfs [based on ssh, remote file system]: can mount the directory of a remote server to local
- Can be applied in embedded development processes
- File Viewing
- cat
- head
- tail
- -f: can view dynamically updated files, continuously read the end of the file, used to monitor logs [will block]
- more
- less [more user-friendly than more]
- Can go back
- Highlight during retrieval
- Moving, Copying
- cp, mv
- ln
- Hard link
- Soft link: be careful when deleting soft links, do not add / after the name [will enter the directory]
- [PS] Python ends support for 2; switching Python versions only requires changing the soft link
- rm: can be encapsulated as mv + scheduled cleanup
- File Types and Permissions
- 7 types
- Regular file
- Directory: usually 4K in size, sufficient
- Character: based on network, serial port-->keyboard, mouse
- Block: block, storage device
- Pipe [more often, the parent process spawns two children, establishing a pipe in between]
- Link
- socket
- Permissions
- rwx
- x for directories means can enter
- User groups: u, g, o
- Commands
- chmod, chgrp, chown
- usermod: for users
- Special permissions
- set uid: the person with the special sword has the right
- set gid: has a specific identity in a certain place
- sbit: sticky bit, only the file owner has delete permission
- Hidden attributes
- rwx
- 7 types
- File Times
- atime[access]: updating too frequently is not good, can set hidden attributes to not update
- ctime[change permissions]
- mtime[modify content]: displayed by default in ls
- touch
- The higher you stand, the more you need to consider the lifespan of the disk [wear, electricity costs]
- File Location
- Locating special files
- which
- whereis
- Regular files
- locate: based on database db, needs updatedb in real-time [less usage scenarios]
- find
- Locating special files
- Remote Copying
- Data Processing[suitable for future work]
- cut, tr, sort, uniq, grep, head, tail
- Redirection: >, >>, <
- read: read in data [pay attention to the format of input data]
- Process Management
- ctrl + z
- fg
- bg
- jobs
- crontab -e/-l [should know, will look at the format of tasks]*
- Acquiring System Information[just try it]
- uname, top, free, dstat, htop, nmon, uptime
Shell Programming#
- Variables
- Command substitution: ``
- Special variables: $0, $#, $?, $@, $*
- ❗ = no spaces on either side
- Input and Output
- read
- echo
- printf
- Branching
- test expression
- man test
- Integer check: integer calculation $[] (expr, let can be remembered as one)
- String: == 🆒
- if: [[ ]] 🆒
- case
- test expression
- Loops
- for
- for i in `seq 1 100` --> seq needs to be called continuously by the system
- for ((i=1; i<=100; i++)) 🆒 more efficient
- while [generally use while 1]
- until [generally not used]
- for
- Functions [simple programs generally do not need]
- Arrays⭐
- Array initialization [optional; uninitialized is empty; initialization takes time]
- unset
- Traversal
- $variable
⭐[PS]Sieve of Eratosthenes、Linear Sieve must know!
Tips#
- The exam includes all English questions
Appendix: Mind Map#
【Produced by Captain Su】