Bo2SS

Bo2SS

10 Review Summary of "Introduction to Linux and Its Usage"

Course Content#

Basic Usage of vim#

  • Quick Navigation
    • Beginning of line: 0 [^ Valid 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

Linux History#

  • C language: How did it come about? How closely is it integrated with the system?
  • Essence of Linux [Linux usually refers to the Linux kernel and Linux operating system]
  • Differences between Linux and Windows [Early Linux attitude towards users: praise those who know, let those who don't know do as they please]
  • Unix [macOS; after Google proposed cloud computing, Apple became the only major Unix system manufacturer]

Shell#

  • zsh
    • Related Files
    • Concept of environment variables: exist in the shell process
    • Essence of executing commands: mostly executing files, opening a child process [to ensure that commands do not interfere with each other], the child process ends after running, and returns the result
  • man
    • Simplified version: tldr
    • English language sense
    • Retrieval: move forward/backward - N/n
    • C library functions
    • Search engine [Google English search]: improve your information processing ability
  • How to search for commands
    • tab [provided by zsh]
    • man -k [-f: search based on explicit words]
    • apt search [apt-cache search]

Specific Use of Linux#

  • Files and directories
    • Remote copy
      • scp [based on ssh -> based on tcp]
      • sshfs [based on ssh, remote file system]: can mount directories on remote servers to local
        • Can be applied to embedded development process
    • File viewing
      • cat
      • head
      • tail
        • -f: can view dynamically updated files, always read the end of the file, used to monitor logs [will block]
      • more
      • less [more user-friendly than more]
        • Can look back
        • Highlight when searching
    • Move, copy
      • cp, mv
      • ln
        • Hard link
        • Symbolic link: be careful when deleting symbolic links, do not add a / after the name [will enter the directory]
          • [PS] End of support for Python 2; Switching Python versions only requires changing the symbolic 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 [in most cases, the parent process creates two children and establishes a pipe in between]
        • Link
        • Socket
      • Permissions
        • rwx
          • x represents enter for directories
        • User groups: u, g, o
        • Commands
          • chmod, chgrp, chown
          • usermod: for users
        • Special permissions
          • Set UID: those who possess the magic sword have the right
          • Set GID: when you arrive at a certain place, you have a specific identity
          • Sticky bit: only the owner of the file has the permission to delete it
        • Hidden attributes
    • File time
      • atime [access]: updating too frequently is not good, you can set the hidden attribute to not update
      • ctime [change permissions]
      • mtime [modify content]: default display in ls
      • touch
      • The higher you stand, the more you need to consider the life of the disk [wear and tear, electricity bill]
    • File location
      • Locating special files
        • which
        • whereis
      • Regular files
        • locate: based on database db, updatedb is required in real time [rarely used]
        • find
  • Data processing[Suitable for future work]
    • cut, tr, sort, uniq, grep, head, tail
    • Redirection: >, >>, <
    • read: read data [pay attention to the format of the input data]
  • Process management
    • ctrl + z
    • fg
    • bg
    • jobs
    • crontab -e/-l [should know, understand the format of tasks]* Image
  • Getting System Information[Try it out]
    • uname, top, free, dstat, htop, nmon, uptime

Shell Programming#

  • Variables
    • Command substitution: ``
    • Special variables: $0, $#, $?, $@, $*
    • ❗ No spaces around =
  • Input and output
    • read
    • echo
    • printf
  • Branching
    • test expression
      • man test
      • Integer comparison: integer calculation $[] (also expr, let, remember one is enough)
      • Strings: ==
    • if: [[ ]]
    • case
  • Loops
    • for
      • for i in `seq 1 100` --> seq needs to be called by the system continuously
      • for ((i=1; i<=100; i++)) 🆒 more efficient
    • while [usually use while 1]
    • until [usually not used]
  • Functions [simple programs usually do not need them]
  • Arrays
    • Array initialization [optional; if not initialized, it is empty; initialization takes time]
    • unset
    • Traversal
    • $variable

⭐[PS]Prime sieve, Linear sieve are must-knows!

Tips#

  • The exam includes questions in English.

Attached: Mind Map#

【Produced by Captain Su】

  • Image
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.