Objective
Every time after reading the Linux command, the brain is always blank, good memory as bad pen, this time to write down, for later review. It's all basic, but it's practical.
First day Linux Command
1. Set the Start screen
Init 3 Switch to character interface
Init 5 switch to graphical interface
Cd/etc = VI Inittab Last ID represents startup item, 3 characters, 5 graphics, 0 shutdown, 6 restart. It should be understood that it is not possible to change to 0 or 6, otherwise the system will shut down after rebooting or starting.
All in all, there are 2 ways to shut down the machine, because 0 means to shut down.
Init 0, direct shutdown, will not notify other users, not very friendly
Shutdown–h now, notify other users to shut down, more friendly, qualified administrator.
2,ls command, view files, not much to say, usage, man a bit.
3,. Current directory,.. The upper directory,/represents the root directory. What does not add back to the working directory after the CD
4,pwd Show current directory
5,cat viewing the contents of a file
6,grep Find content Lookup files, content retrieval commands
7,find directory –name file name, finding files
8,RM file name, deleting files
RM–F file name, forced to delete files, file does not exist without error
RM–RF directory names, recursively delete directories and files within directories
9,CP File New file, copy
10,MV files, new files, same directory, renaming, different directories, moving
11,clear Clear Screen
12,ps View process information –a all processes,-u verbose,-x background process,-aux combination
13,top Viewing performance
14,whoami, who I am, not much.
15,who, see who logged into the system
16,TAR–CVF Xx.tar file 1 file 2 ... File packaging
TAR–XVF Xx.tar release the packaged files
Note: Tar is only packaged, not compressed
Gzip Xx.tar, compress file asked XX.tar.gz, the original tar file will be deleted
Gzip–d XX.tar.gz Extract Files
Linux compressed files in two steps, first tar packaging, in gzip compression
The next day Linux Command
1, new user useradd–d/home/xx xx = passwd xx
2, Switch User su-xx
3, let Linux look for executable files under the current path
CD (What does not write, back to the current host directory)
=>vi. Bash_profile
+ = Append to path:., indicating that the executable file can be found in the current directory
=>:wq, save exit
=>. . Bash_profile, as amended to take effect.
4,reboot restart
Third Day GCC
1,gcc–o Specify target file name example: Gcc–o destination file name source file name
2,gcc–e Precompiled file Example: Gcc–o target file name –E source file name
3, precompiled: Replace the included library file with the source file
4,gcc–c Compile source file (not linked) Example: gcc–c source file –o destination file
Gcc–s Generating assembly code example: Gcc–s source file-o destination file
5,linux files do not look for extensions, GCC distinguishes between file types according to the extension name
6,GCC can compile C + + files, but the link fails because the GCC default link C's library does not link C + + libraries
Combined with the above explanation, you can use the-l option to compile C + + files using GCC, which links C + + libraries with the-l command
Example: Gcc–o target file name –lstdc++ source file (CPP file)
7,NM File name View label
8, when the Make command is executed, the makefile file in the current directory is automatically searched
Makefile notation
->makefile default is based on dependency execution, no dependent statements do not execute
Specify statement designator to execute the specified statement, for example: Make clean
9, in order to strengthen GDB debugging, generate Corefile steps
Cd=> in. BASHRC finally add ulimit–c unlimited=>. . BASHRC, execute file, modify effective
10, using the core file debug program
The program run information is written to the core file, so we can look directly at the core file for error messages
Method: GdB Executable Core file
11, Direct Debugging program ※ Black Bold for command interpretation
Gdb-q executable file
Quit-> Exit
Run
Where-> Display Error location
List[m,n]-> Displays the context code for the error line, which displays the top and bottom lines of the error by default
print-> Monitoring Example: Print i
Continue-> continues to run, equivalent to jumping directly to the next breakpoint
Info break-> Viewing breakpoints
Delete breakpoint number, remove breakpoint
Set variable variable name = value Change variable value
Step-> Step in
Next-> Step over
Return [value]-> early termination of function execution
12,man tips: Man 2 XX View system calls
Man 3 XX View library functions
Man 5 XX View third-party libraries
Linux Common commands