20145239 "Fundamentals of Information Security system Design" Summary of Knowledge points summary common Linux commands
- The command format for Linux is:
command [options] [arguments] []表示是可选的
the composition structure is:命令 [选项] [参数]
Man command
man命令
is a help instruction under Linux, which allows you to view information such as instruction help, configuration file Help, and programming help in Linux with the Man command.
- Common options:
-a
: Search in all man help manuals
-k
: Search online Help based on keywords, is a fuzzy search
-f
: keyword exact search, equivalent to Whatis instruction, displays a short description of a given keyword
-P
: Use the paging program when specifying content
-M
: Specifies the path of the man manual search
- Parameters:
数字
: Specify which man manual to search for help
关键字
: Specify keywords to search for help
man -k
: Commonly used to search, combined with pipe use. Examples are as follows:man -k k1 | grep k2 | grep 2
Cheat command
- On Linux,
man命令
it's almost omnipotent, but it's not the most efficient. Because it gives the help information very long, in a short period of time not understanding, so in this case, in cheat命令
a more convenient, cheat命令
simply speaking, is to tell you how to use a command. It does not provide any additional extraneous information, only by using an instance to tell you how a command is used.
grep command
grep命令
is a powerful text search tool that can use regular expressions to search for text and print matching lines. The grep
full name is the Global Regular Expression Print
global regular expression version, which uses permissions for all users.
- Command format:
grep [options]
- [Options] Main parameters:
-c
: Outputs only the count of matching rows
-I
: Case insensitive (only for single-character)
-h
: File name is not displayed when querying multiple files
-l
: Only file names with matching characters are output when querying multiple files
-n
: Displays matching lines and line numbers
-s
: Does not display error messages that do not exist or have no matching text
-v
: Displays all lines that do not contain matching text
- If you want to find a macro, we know that the macro is saved in the Include folder, so you can use the following statement:
grep -nr XXX /usr/include(XXX为所要找的宏)
Find command
find命令
Used to locate files under the specified directory. Any string that precedes the parameter will be treated as the name of the directory you want to find. If you use this command without setting any parameters, you find命令
will find subdirectories and files under the current directory. and displays all the subdirectories and files that are found.
- Command format:
find pathname -options [-print -exec -ok ...]
- Parameters:
pathname
: The directory path that the Find command looks for. For example, use. To represent the current directory, and/to represent the system root directory
print
: The find command outputs the matched file to the standard output
exec
: The Find command executes the shell command given by this parameter to the matching file, in the form of ' command ' {} \;, note the space between {} and \;
ok
: The -exec
same as the function, but in a more secure mode to execute the parameters given by the shell command, before executing each command, will give a prompt for the user to determine whether to execute
- Common options:
-name
: Find files by file name
-perm
: Find files according to file permissions
mtime -n +n
: Finds files according to file change time,-n means file change time is less than n days, + n means file change time is now N days ago
-newer file1 ! file2
: Find change times newer than file file1 but older than file2 files
-type
: Find a file of a certain type, such as: B-Block device file, D-Directory, C-character device file, p-pipe file, L-Symbolic link file, F-Normal file
-size n
: [C] Find files with a file length of n blocks, with C indicating file length in bytes
-depth
: When looking for a file, first find the file in the current directory, and then look in its subdirectories
Locate command
locate命令
In fact find -name
, it is another way of writing, but much faster than the latter, because it does not search the specific directory, but rather search a database (/var/lib/locatedb), the database contains all the local file information. The Linux system automatically creates this database and updates it automatically once a day, so you can't find the latest changed files using the Locate command. To avoid this situation, you can manually update the database by using the UpdateDB command before using locate.
- Command format:
locate [选择参数] [样式]
- Command parameters:
-e
: Will be excluded from the scope of the search
-1
: If 1 is the boot security mode, in Safe mode, the user will not see the files that the permissions cannot see. This slows down because it is locate
necessary to obtain access to the file in the actual file system.
-f
: Exclusion of specific file systems, e.g. we do not have the need to put files in the file system in the database proc
-q
: Quiet mode, no error message is displayed
-n
: Displays up to n outputs
-r
: Use normal expressions to search for conditions
-o
: Specify the name of the data inventory
-d
: Specify the path to the repository
-h
: Show Auxiliary messages
-V
: Displays the version message of the program
Whereis command
whereis命令
is the location of the executable file, the source code file, the Help file in the file system. The properties of these files should belong to the original code, binary files, or Help files. whereis
The program also has the ability to search for source code, specify alternate search paths, and search for unusual items. whereis命令
search only for program names, and search only for binaries (parameter-B), man description file (parameter-m), and source code file (parameter-s). If the argument is omitted, all information is returned.
- Command format:
whereis [-bmsu] [BMS 目录名 -f ] 文件名
- Main parameters:
-b
: Locating an executable file
-m
: Locating Help files
-s
: Locating source code files
-u
: Search for files other than executables, source code files, Help files under the default path
-B
: Specifies the path to the search executable file
-M
: Specify the path to the search Help file
-S
: Specifies the path to the search source code file
which command
which指令
Searches for the location of a system command in the path specified by the path variable, and returns the first search result. which
is to search for a running file based on the directory within the variables configured by the user, PATH
so the PATH
commands found for different configurations are not the same.
- Command format:
which 可执行文件名称
- Command parameters:
-n
: Specifies the length of the file name, which must be greater than or equal to the longest file name in all files
-p
: The same as the-n parameter, but the path to the file is included here
-w
: Specifies the width of the field at the output
-V
: Display version Information
The difference between find, locate, which, Whereis
- Which (look for the execution file): This command is based on the path of the environment variable specification, to search the file name of the execution file, so the focus is to find the execution file, which followed by the full file name
- Whereis (looking for a specific file): Search for what is recorded in the Linux database file, and the main difference between the locate is the following parameters
- Locate: Search the Linux database files recorded in the file, followed by the name of the file directly on the line
- Find: Search the entire hard drive directly
Sort command
- Sorts the contents of the text file. The contents of the text file can be sorted in the unit of behavior.
- Parameters:
- M: Merge several sorted files.
- N: Sort by numeric size
- In Linux bash, ls. | The function of the sort command is (displays the current directory contents and sorts)
Du command
- Displays the size of the directory or file. DU displays the disk space occupied by the specified directory or file.
- Parameters:
- A: Displays the size of individual files in the directory.
- B: When displaying the directory or file size, in bytes.
- C: Displays the sum of all directories or files in addition to the size of individual directories or files
ls command
- Displays the contents of the specified working directory (lists the files and subdirectories included in the current working directory).
- Parameters:
- A: Show All files and directories
- A: Same as-a, but not listed "." (current directory) and ".." (Parent directory)
- T: List the files in the order of establishment time
- List all the files and directories under the current working directory; add "/" to the name, and then add "*" to the file name: LS-AF
- In Linux bash, the command output redirection command that displays the results of the current directory in the LS command (ls > ls.txt) is stored in ls.txt.
VI, GCC, GDB, make the use of vim Common command summary
- Insert:
i
: Edit at current cursor
a
: Inserts an edit after the cursor
- Exit:
q!
: Force quit, do not save
:q
: Exit
:wq!
: Force Save and exit
:wq
: Save and exit
:w <文件路径>
: Save As
- Delete:
x
: Delete the character that contains the cursor
dd
: Delete entire row
- Inline Jump:
nG(n Shift+g)
: Cursor moves to nth row
- Copy and paste:
nyy
: A total of n rows after the copy cursor and its entire row
p
: represents after pasting to cursor
- Function setting:
:set autoindent(ai)
: Set auto Indent
:set cindent(cin)
: Set C language Style indentation
:set nu
: To display line numbers
GCC compilation process
- Preprocessing: Gcc–e hello.c–o hello.i; gcc–e call CPP to produce preprocessed C primitive program
- Compile: Gcc–s hello.i–o hello.s Gcc–s call CCL Produce assembly language original program
- Assembly: Gcc–c Hello.s–o hello.o; gcc-c call as produce target file
Link: gcc hello.o–o hello; gcc-o invoke ld to generate executable file
- Run:./hello
Static Library
- A static library is an archive of a series of target files (. o files) ((lib+name). a file); link stage, select Static Library, suffix named ". A", select Dynamic Library, suffix ". So".
- Static link library Generation:
gcc -c 文件名.c ar rcsv libxxx.a xxx.o
- Use of static libraries:
gcc -o 文件名 文件名.c -L. -lxxx
//link to Static library
- Attention:
-L
: Add dir directory to the list of search paths in the library file
-l
: Add dir directory to the list of search paths in the header file
Shared libraries
- Generation of shared libraries:
gcc -fPIC -c xxx.c
gcc -shared -o libxxx.so xxx.o
- Use of shared libraries:
gcc -o main main.c -L. -lxxx
- How to register a shared library: Copy the library file directly to the/lib or/usr/lib directory:
cp (lib+name).so /lib
GDB debugging
- Go to GDB:
gcc -g xxx.c -o xxx
gdb xxx
- View Source:
(gdb) l
: Prompt for line number
(gdb) b n
: Set breakpoints on Nth line
(gdb) r
: Run code, run to Breakpoint
(gdb) n
: Single Step operation
(gdb) c
: Causes the program to continue running down until the breakpoint is encountered again or the program ends
(gdb) q
: Exit GDB
(gdb) watch n
: The Observer is set at "N" to observe the variation of the variable
- Four types of breakpoints:
- Function Breakpoint:
b 函数名 条件表达式
- Line breakpoint:
b 行数或函数名 条件表达式
- Conditional breakpoint:
b 行数或函数名 if表达式
- Temporary breakpoint:
tbreak 行数或函数名 条件表达式
Makefile
- Function: Identify whether the file code is updated, reduce the compilation effort
- The format is:
- Target body: Dependent file
- [tab] Run commands for each target body
- Target: Created by make, usually a target file or executable file
- Dependent files: Create a file on which the target body depends
- Run command: The Run command required to create each target body must start with the TAB key.
- Use make for format: Make target body
Harvest
- The first level of the harvest is about the course. For example, I learned the installation of virtual machines, learned the instructions of many virtual machines and the principles of computer operation.
- The second level of harvesting is understanding, such as the use of Git, in the beginning I really refused, I want to click on the computer a few mouse things why use the command line so
Advanced things, the result of this thought in the last semester of Java to this semester of Linux gradually changed, it can be said from the teacher's mandatory requirements into a habit of my own. This
In fact, it is a very important change, in a way that he actually changed my mode of thinking, let me begin to have a programmer's cautious, rigorous, logical thinking. This will be very helpful to my future work.
- The third level of the harvest is the impact on my values is also the most profound impact. During the year of teacher Lou's teaching, I saw a lot of classmates around the different attitudes and different results of flipping the classroom. At first,
I hate this way, so the last semester of Java is a muddle through, and finally see the class in the envy of the students and helpless. This semester I saw a classmate of the blog write feel that I chose the wrong professional, on the present
The course is not interesting and wants to study literature. In fact, I have had similar troubles, but think carefully, programming, code, these seemingly boring and mechanical courses in fact, the deep training of our rational thinking, solid
Sitting in front of the computer, quiet to knock a few lines of code, more than anything come true. Therefore, to say that the best-of-fate, said the prodigal son, anyway, I have been doing this semester to learn the course of their own.
Insufficient
Course Suggestions and comments
Every week we ask a lot of questions and Baidu is not the problem of teachers can teach the same explanation, everyone privately asked the teacher is very troublesome, the key is many students want to learn but afraid to ask questions when making low-level mistakes.
20145239 Interim Summary of the basic design of information security system