1. Learning of DIRECTORY commands
1.1, Ifconfig
Ifconfig//view network card and other information
ifconfig eth0 + IP//Set network card IP
Ifconfig eth0 down/up NIC Switch
1.2, Mount/umount
Implementation of NFS Network File system mount, the general format is:
Mount–t type–o optlist Dev dir
-T: Specifies the type of hook-up file system, such as NFS
-O: Specifies the optional command to attach, when more than one command, or use a-O, but the command is separated by commas, this comma is not Chinese oh, figure TCP
Dev: hooked up device
Dir: Specify the location of the hook, where the location of the hook must be already existing directory, if multiple files need to be mounted, you can create a new directory in the MNT directory, to differentiate
When implementing hooking up a Linux file when the board directory, in the board of the serial operation SECURECRT:
Mount–t Nfs–o nolock,tcp 10.100.10.249:/home/carlos/nfs/3516c/mnt
Visible,-T is specified as NFS, and –o specifies that nolock and Tcp,dev are paths specified by IP, dir is the MNT directory on the board
Umount:
To implement the uninstallation of a mount file, it is generally:
Mount–a//Uninstall all attached files
Mount DIR//will be hooked up to the location for release
1.3, PS
It is usually taken to view the process,
Ps–e//Implement view of all processes, the first is process number
PS–AJX//view process PID, PPID and other information
Ps–aux//View information on CPU MEM consumed by all processes
1.4, Kill/killall
Kill is usually done by –9, adding the process number and killing a process directly.
KILL–9 + process Number
Killall is a process named by the way that kill a process
Kill–p + process Name
1.5. Make
Compile and build the upgrade package?
1.6, reboot
The system restarts, the general setting has,
Reboot or reboot + command
-F: Force shutdown
-I: Shut down the network before shutting down
-N: After saving the data and then shutting down the computer
1.7. Ping
Ping + IP
1.8. Vim
1.9. GCC
GCC compiles, typically by specifying, controlling the generated files
-O + file name: Generates an executable obj file, default is A.out
-S: Compile the source code as a compilation not seen, GCC hello.c–s–o nhello.asm
-E: Preprocessing, which does not generate files, needs to relocate itself to text files gcc hello.c–e > Yuchuli.txt
2.0, Tcpdump and Tcptraceroute
2.1, Makefile
Makefile's Rules:
Goal: Reliance
tab+ command//Here must be TAB, cannot be a space, otherwise error
A) write makefile, automate the C file, compile the executable file
hello:hello.o
GCC Hello.c–o Hello
Hello.o:hello.c
GCC Hello.c–o hello.o
b) Modify the C file and invoke the API of the third-party library file
HELLO:HELLO.O FILE1.O
GCC hello.o file1.o–o Hello
Hello.o:hello.c
GCC Hello.c–o hello.o
file1.o:file1.c
GCC File.c–o FILE.O
Clean:
RM–RF hello.o FILE.O
Common wildcard characters:
[email protected]: represents the target
$^: Represents all dependent objects
$<: Represents the first dependent object
So the above can be modified to://target is [email Protected]→hello, all dependencies are hello.0 file.0
HELLO:HELLO.O FILE1.O
GCC $^–o [email protected]
Hello.o:hello.c
GCC $<–o [email protected]
File.o:file.c
GCC $<–o [email protected]
Need to learn by yourself, "Learn Makefile with Me"
2.2. Learn the Shell
A) Understanding variables
Variables are both string, variable names are capitalized (and system variables are distinguished, can be viewed through set)
Abc=xxxx, the left and right sides of the equals sign cannot have spaces.
When a variable is obtained as a command:
abc=$ (date)
Use of variables:
Echo ${ABC}, echo $ABC both are possible,
b) Understanding conditional statements
if [condition]; Then
Xxxxxx
Fi
Or:
if [condition]; then//There are semicolons here, don't forget
Xxxxxx
Else
Xxxx
Fi
c) Understanding Loop statements
For i in {numbers, numbers separated by commas}
Do
XXXXXXX
Done
For file in character (' ls ')
Do
Xxxx
Done
While loop body:
While [condition]//No semicolon
Do
Xxxxx
Done
d) write a footstep file, loop processing: 1, read the contents of/proc/meminfo, 2, analyze the size of Memfree and cached, 3, if the two add, less than 5Mbyte, prompted memory leaks, exit the loop.
(1) through the while loop body, has been implemented detection, but wasted CPU resources
While [1]
does
for i in {2,3}
& nbsp; do
if [ ${i} = 2];then
memfree=$ (cat/proc/meminfo | sed ' 2 p '-n | awk ' {print $} ')
echo "memfree = ${memfree}"
fi
if [${i} = 3];then
cache=$ (cat/proc/meminfo | sed ' 4 p '-n | awk ' {print $} ')
echo "cache = ${cache}"
Fi
Done
addnum=$ (Expr ${memfree} + ${cache})
echo "addnum = ${addnum}"
mm=$ (Expr ${addnum}/1024)
echo "MM = ${mm}"
If [${mm}-le 5];then
echo "Warning"
Else
echo "OK"
Fi
Done
(2) Execution by means of timer execution:
For i in {2,3}
Do
if [${i} = 2];then
memfree=$ (cat/proc/meminfo | sed ' 2 p '-n | awk ' {print $} ')
echo "Memfree = ${memfree}"
Fi
if [${i} = 3];then
cache=$ (cat/proc/meminfo | sed ' 4 p '-n | awk ' {print $} ')
echo "cache = ${cache}"
Fi
Done
addnum=$ (Expr ${memfree} + ${cache})
echo "addnum = ${addnum}"
mm=$ (Expr ${addnum}/1024)
echo "MM = ${mm}"
If [${mm}-le 5];then
Echo-e "\033[31;43m warning \033[0m" >/DEV/PTS/4//terminal, printing in different colors,
Else
Echo-e "\033[31;43m ok\033[0m" >/DEV/PTS/4//Interrupt
Fi
Timed execution:
Crontab–e
*/1 * * * */xxx/xxx/xx/1.sh
The script file runs every minute,
Because the printout is output through the console, so print the console:/DEV/PTS/4, if you do not know, can be determined by the TTY command, because different consoles are not the same, to be based on the actual console to replace.
2.3, DD
Implement copy between files, copy and support format conversion at the same time
if: Input file
Of: Output file
Bs:ibs + OBS, both forcing the input and output of data to specify the size of the data block
Count: When writing, specify the block to write to,
Copy from device A to device B
DD if=/xxx/x/a of=/xxx/xx/b bs=8k//copy of the data, each copy of the size of 8K, not specified count is all copied over
Test Disk write capability:
Time DD If=/dev/zero of=/xxx/xx/device name bs=8k count=30000
/dev/zero: Is the device that produces ASCII 0, which is always generating 0, will these zeros, every 18 K, altogether 30,000 times, write to the specified device, and the entire process time out.
Test disk read-out capability:
TIME DD if=/dv/device name Of=/dev/null bs=8k
/dev/null is an empty file, is a black hole, so the device data, every 8k copy come over, finally the process time to print out,
2.4. diff
Compare two files, typically used to make a patch pack
Format:
Diff option File1 File 2
Compare File1 to File 2. When making a patch package, File1 is the source file, File2 is the latest destination file,
-R: Supports recursion,
-N: Make sure the file is created,
-U: In a uniform format,
To generate a patch file:
Diff-urn old file Destination files > Xxxxxx.path
Using patch files: With the patch command
PATCH–P[0-N] < Xxxx.patch//The information inside contains the path to the file, the name of the file, etc.
The value after-P is, ignoring the path,
2.5, Ln
Create links, the connection is divided into soft links and hard connections, whether soft or hard, the files are kept in sync, as long as the source file changes, the connection file will follow the change.
To create a soft link:
Ln–s source file or directory destination file, generated soft link size is very small, similar to window icon, 4KB
To create a hard link:
ln source file Destination file//created for destination file and source file size is identical
2.6. Top
Top command to see the system using CPU, memory, and other information
top-14:41:28 up 497 days, 4:21,//to current position system start time
Users,//user number
Load average:0.21, 0.19, 0.24//system load, recorded is 1 minutes, 5 minutes, 15 minutes, to the current average
tasks:209 Total, 2 running, 207 sleeping, 0 stopped, 0 Zombie//Total task number, running, sleep, stop, zombie number
CPU (s): 0.0%us, 0.0%sy, 0.0%ni, 95.8%id, 4.1%wa, 0.0%hi, 0.0%si, 0.1%st//user space, kernel space occupy CPU usage
mem:7901184k Total, 4514476k used, 3386708k free, 332896k buffers//
swap:4088532k Total, 49312k used, 4039220k free, 3735268k cached
2.7. Free
View memory and other usage status
2.8. Tar
For packaging or decompression
Format:
Tar command output file input file//unzip the file when there is no output
Command:
-V: Show details, all can
-F: Can be used with files
-C: Package, use when packaging
X: Unzip
J:bzip2
Z:zip/gzip
Packaged:
TAR–CVF 1.sh.tar 1.sh//Package 1.sh, C is lowercase
Unpack
Tar xvf 1.sh.tar//Because there is no format involved in the decompression, you do not have to use J or Z
Unzip the specified format:
TAR-JXVF xxxx.tar.bz2//uncompressed bz2 format, so use J
TAR–ZXVF xxxx.tar.zip/gzip//uncompressed ZIP format, so use Z
2.9, Zip/unzip
Zip: Implementing zip compression
Zip command compresses files that are compressed to generate files
Compress \ Unzip file:
Zip 1.sh.zip 1.sh
Unzip 1.sh.zip
Compressed directory \ Unzip directory:
Zip–r Xxxx.zip Directory
Unzip xxxx.zip-d path//–d can specify the decompression path
One months of entry assessment study