Those powerful commands that improve the efficiency of Linux environment development

  
I believe that many users who use Linux systems will feel that command line operations are faster than graphical interface operations in many cases, and using command line commands reasonably will get twice the result with half the effort. For programmers developing in the Linux environment, the use of these commonly used commands introduced to you can effectively improve the efficiency of development work, including the package compression command tar, file search command find, file content search command grep, elf executable File analysis tools readelf, etc., let us take a look at these commands one by one.

1. Package compression command: tar
In Linux, you will often encounter the source code package decompression, etc. If you still use the Linux X window to do it, you will be out. The following are the common command parameters and application examples of the tool:
Main command:
-c Create package
-x Unpack
-t List the contents of the package
-r Add files To the specified package
-u update the file in the package
optional command:
-j Use bzip2 to compress or decompress when creating or unpacking the package;
-z When creating or unpacking the package Use gzip for compression or decompression;
-Z use compress to compress or decompress when creating or unpacking;
-f followed by the specified package file name;
-v shows the package/unpack process < Br>-C Specify the path after unpacking
Example:
tar -czf tmp.tar.gz /tmp Store the “/tmp” directory package as tmp.tar.gz;
tar - Xzf tmp.tar.gz -C /home Unpack the tmp.tar.gz package to the "/home” directory;
tar -t tmp.tar.gz View the file information in the tmp.tar.gz package;
2, file search command: find
Suddenly do not know xxx.c in that path, you will not use the X window inside Linux to search this file? Find is a simple and powerful search tool what.
The format of the command is:
find The path expression to be found
For example:
find . -name 1.txt Find the file in the current directory and its subdirectories “1.txt”;
find /tmp -name 1.txt Look for the file “1.txt” in the “/tmp” directory and its subdirectories.
In addition, find also supports fuzzy search:
find. -name *test*.c
For more advanced usage, please refer to the man page.
3, file content search command: grep
I am looking for a bug, look at the log ah look at the log, suddenly found a key log information, then this information is printed in that source file? I used grep.
File Content Search Command grep
The grep command is used to find the specified pattern match. The format is:
grep [command option] The matching pattern to be found [file to be found]
Example:
grep cams test.txt Find the strings string in the <quo;test.txt” file;
grep -r cams /root/cams In all files in the “/root/cams” directory and its subdirectories, Find the strings of the cams; the
grep command can redirect any output stream to grep in addition to finding files:
ps -ef |  Grep ora finds all process information with “ora” in the process name.
In fact, the above are the most simple and most commonly used usage of grep, more advanced usage can refer to grep man manual.
4, ELF file analysis tool: readelf
This command is a relatively advanced command, not the above commands are commonly used, but it is also a very practical software, here to introduce some simple usage.
Query file all information
readelf object-file-name -a
Query elf header
readelf object-file-name -h
Query symbol table
readelf object-file-name -s
Query all section details
readelf object-file-name -t or readelf object-file-name -S
dump a section information
readelf object-file-name -p Section-name| Section-index
readelf object-file-name -x section-name| Section-index
readelf object-file-name -R section-name| Section-index


Copyright © Windows knowledge All Rights Reserved