Basic understanding of Linux

Linux is an open source operating system. In Linux, everything is a file. Linux has a great advantage in the server and embedded fields, such as: the total cost of use and maintenance, hardware support, flexibility, security, stability and reliability, and affordable.


Linux has a lot of basic instructions, as time slowly learn, I will not enumerate here only to talk about the part of the content.
1.rm command: rm command to delete, but to add -r (recursive delete) option, -f represents the force delete when deleting a folder, be used with caution.
2.cp and mv command: Personally, I like these two commands together memories, cp is copy, mv are moving, they are using the rules in the instruction + [options] [source] [destination file], so of course, support the operation of the folder you, just add -r option can be friends.
3. The compression and decompression:
①tar:
the tar in two ways, namely, gzip (used) and bzip2
the gzip:
Compression: tar -zcvf /tmp/etc.tar.gz / etc -> the contents of the folder compression etc next to the / tmp / directory, and named etc.tar.gz
decompression: tar -zxvf etc.tar.gz
②zip and the unzip
4.find instructions: Usage: find [path] -name (to find the name) Note : here's name can use wildcards (*).


Linux rights:
the linux are two users and ordinary users superuser (root)
has two switched from the normal user mode to the super-user: and su su -, but both are different ways, use instruction su after entering the root path is still home / current user, which means that although the right to have super-user but in fact are not really super-user, and use su - command path after entering the super-user is / root this time is real the super user.
1. File Classification visitors: file owner, user group owner of the file where the other
2 file types and access rights:
d: folder
-: normal file
l: soft link (shortcut Windows-like)
b: file block device (e.g., hard disk, CD-ROM, etc.)
P: pipe file
c: character device file (e.g., serial device screen or the like)
S: socket file
basic permissions:
. I read (4): read the file concerned, having read permissions file contents; for a directory, the directory information with a browser permissions
ii write (2): write on the document, modify the contents of the file have permissions; for a directory within the directory has moved to delete the file permissions.
iii the Executive (1): execute the file, the file has execute permissions; for a directory, has permission to access the directory
can modify the file permissions using the chmod command.


Text editor vim (normal mode, insertion mode, line mode)
Normal mode is important :( seven types of commands: delete shift more complex for withdrawal jumping)
1. $ moves to end of the line, moved to the beginning ^ , gg beginning to move the text, the text is moved to the end of the G
2.x delete the character at the cursor position, dd delete the entire line
3.yy and p
replacement character at the cursor position 4.r, R replaced wherever the cursor character (sec stop)
5.u revoked, the revocation] [ctrl + r recovery
6.cw changes the cursor to the suffix (not used)
7. ctrl + g] [line number, [skip] # G #Row


Linux compiler gcc / g ++
must first know the code generation phase, and each phase of the four tasks:
1. Pretreatment: macro expansion and replacement of headers and remove annotations
gcc -E test.c -o test.i
2. compile: checks syntax and generating assembly code
GCC -S test.i -o test.s
3. Assembly: generating a machine-readable code
GCC -C test.s -o test.o
4. Links: generating executable files (the Test)
gcc -o test.o the Test
of course, the most commonly used or gcc test.c -o test directly to the source code for an executable file
Note: the system will achieve most of the library functions are placed libc.so .6 library file, the system will look at the case is not specified in the path of "user / lib" will link to the appropriate library function, the function of which is linked, and library functions are divided into static library and dynamic libraries, and then explained in detail this behind us.
About static linking and dynamic linking
1. statically linked refers to the dynamic link library will depend to an executable program, it will be relatively large, but the normal execution on different platforms.
2. Dynamic Link is a function to depend in a dynamic library is loaded into the symbol table, the dynamic link library to the dynamic code execution in a dynamic library when running a program, it is necessary to rely on different computers using dynamic Gallery also gives otherwise could not find the dynamic library is not running.
3. The compiler default mode is dynamic links link, if you want to use a static link, then the option to add -static compiler option


About Makefile:
Use one-touch make compilation, the key to the Makefile is based on dependence on target to complete the compiled target, but the writing at the top of dependent files once they are generated behind the useless (forever just to generate the first targets), while generally want to compile multiple files generated by the makefile will use a dummy target is determined, dependent pseudo-file goal is to generate a file, so that solved the problem.
Predefined variables: $ ^: all the dependent objects
$ @: all audiences


Guess you like

Origin blog.51cto.com/14239789/2462011