Common Linux commands. (Continuous update)

Source: Internet
Author: User

1. GDB: The Flash builder simulates the program running on the client. When the server is suspended in the memory, debugging is required if a request is sent and a module in the program is not running properly, GDB is a good tool. Common commands are GDB + executable files and GDB-C core files and executable files. To generate a core file, you must first use the command ulimit-C unlimited, another method is to use the GDB-P + process number. This method is especially applicable here, because the requests sent by the front-end cannot be simulated in the first two methods, this method can better track error modules. View process no.: netstat
-LPN | grep program name.

GDB-C Core File + Executable File: it is a useful tool for program debugging to generate core files. You can directly use the command BT to print the error location, which is very convenient.

Set follow-fork-mode child: used to track the child processes generated by fork. GDB tracks the parent process by default.

Usually some string content needs to be printed during GDB debugging. If the string length is too long, the print command will not print the string completely. In this case, the command p str @ str_len, in Linux, the length limit is generally 200. If you cannot print it completely, run the set print element 0 command. If hexadecimal is to be output, P/x str @ str_len is used. Usually, hexadecimal is used when Chinese encoding content is output.

2. If you only want to view the first five lines of the file, you can use the head command, for example:
Head-5/etc/passwd
If you want to view the last 10 lines of the file, you can use the tail command, such:
Tail-10/etc/passwd
Tail-F/var/log/messages
The parameter-F enables tail to constantly read the latest content, so as to monitor the content in real time.

3. netstat: This command can be used to view network information. It is particularly useful:

Netstat
-LPN | grep process number or port number. You can view the network connection information of a process.

4. dos2unix: When copying or moving UNIX files in the DOS operating system, some strange characters are often added to the files. This is the time to use this command.

Dos2unix + file name.

5. ls-L/proc/+ process number: view all file descriptors opened by a process. Such as LS-L/proc/8090.

6. lsof-P + process number: similar to the previous command, you can view all files opened by a process.

7. Find/-name + file name: Start from the root directory to find the location of a file.

8. today, I downloaded a software package in Linux. After the software is decompressed, compiled and installed, it is displayed as cannot open a dynamic library, but I open/etc/lD. so. check the default dynamic library link directory under the conf file and find that the dynamic library can be found in a directory/usr/local/lib. I am wondering why. Then I searched the internet and found that I had to use the ldconfig command to clear the cache, and then it was successful. Therefore, ldconfig is a dynamic link library management command.

To share the dynamic link library with the system, you also need to run the dynamic link library management command-ldconfig
The ldconfig command is mainly used in the default search directory (/lib and/usr/lib) and dynamic library configuration file/etc/lD. so. find the shared dynamic link library under the directory listed in conf (format as described earlier, lib *. so *) to create a dynamic loader (LD. so) the required connection and cache file. the default cached file is/etc/lD. so. cache. This file stores the list of Dynamic Linked Library names in the sorted order.

Ldconfig is usually run when the system starts. When you install a new dynamic link library, you need to manually run this command.
The ldconfig command line is used as follows:
Ldconfig [-v | -- verbose] [-N] [-N] [-x] [-F conf] [-C cache] [-r root] [-L] [-p | -- print-Cache] [-C format] [-- format = format] [-V] [-| -- help | -- usage] path...
The options available in ldconfig are described as follows:
(1)-V or -- verbose: When this option is used, ldconfig displays the directory being scanned, The searched dynamic link library, and the name of the connection it created.
(2)-N: When this option is used, ldconfig only scans the directory specified by the command line and does not scan the default directory (/lib,/usr/lib ), nor scan the configuration file/etc/lD. so. conf directory.
(3)-N: This option indicates that ldconfig does not recreate the cache file (/etc/lD. So. cache). If the-x option is not used, ldconfig updates the file connection as usual.
(4)-X: This option indicates that ldconfig does not update the file connection. If the-n option is not used, the cached file will be updated normally.
(5)-f conf: This option specifies that the configuration file of the dynamic link library is Conf, and the default value is/etc/lD. So. conf.
(6)-C cache: This option specifies that the generated cache file is cache. The default value is/etc/lD. so. cache. This file stores the list of dynamically linked libraries that can be shared in the sorted order.
(7)-R root: This option changes the root directory of the application to root (implemented by calling the chroot function ). when this option is selected, the system default configuration file/etc/lD. so. conf, which corresponds to root/etc/lD. so. conf. for example, when-r/usr/ZZZ is used, open the configuration file/etc/lD. so. in Conf,/usr/ZZZ/etc/LD is actually enabled. so. CONF file. this option can greatly increase the flexibility of dynamic link library management.
(8)-L: Generally, ldconfig automatically establishes a connection to the dynamic link library when searching for a dynamic link library. when this option is selected, the expert mode is enabled. You need to manually set the connection. this option is not required for general users.
(9)-P or -- print-Cache: This option indicates that ldconfig prints the names of all the shared libraries saved in the current cache file.
(10)-C format or -- format = format: This option is used to specify the format used by the cache file. There are three types: LD (old format), new (new format) and compat (compatible format, which is the default format ).
(11)-V: This option prints the version information of ldconfig and then exits.
(12)-Or -- help or -- Usage: the three options share the same role, so that ldconfig prints the help information and then exits.

9. RZ: This command supports uploading files from windows to Linux. You only need to execute RZ-Bey to bring up an upload interface, which is very convenient.

10. SZ: In contrast to the previous command, this command can download the Linux file to the local Windows. The upload and download directories are set in securecrt session option-terminal-x/y/zmodem.

11. Locate: this command is similar to find/-name, but it runs faster than find/-name,The reason is that it does not search for a specific directory, but searches for a database (/var/lib/locatedb)The database contains information about all local files. The Linux system automatically creates the database and updates the database once a day. Therefore, the latest changed files cannot be found using the locate command. To avoid this problem, you can,Use the updatedb command to manually update the database.. Specific Use: http://www.cnblogs.com/flysnail/archive/2012/05/16/2504266.html

12. chkconfig: this command is used when MySQL is installed today: chkconfig -- add mysqld, add the mysqld server, and let the chkconfig command manage it, at the same time, add relevant data in the system startup description file. Specific usage: http://www.cnblogs.com/flysnail/archive/2012/05/16/2504266.html

13. perl-I-PE: Perl tools are very common. For example, you can use the following command to change a field of all files in a directory to another field: perl-I-PE's/Port = "18/Port =" 17/G '. /*. XML. Convert the Port = "18 field of all. xml files in the current directory to the Port =" 17 field for automatic match.

14. telnet: used to connect to the remote IP port. It is useful when you need to test whether the remote IP address can be connected.

15. mySQL server startup command :. /mysqld -- defaults-file =/etc/My. CNF -- user = root or. /mysqld_safe -- defaults-file =/etc/My. CNF -- user = root & or/etc/init. d/mysqld start.

16. Touch: Create an empty file.

17. VI ~ /. Bash_profile: used to modify environment variables. You can add a directory after path in the format of paht = $ path: $ home/bin followed by: + directory name, in this way, Common commands cannot be used, but directories must be added. If the modification takes effect immediately, run the source. bash_profile or. bash_profile command. This is a file under the root account, while common users can use VI ~ /. Bashrc modify the environment variable in the format of export Path =/usr/bin:/bin. Use the source command to take effect immediately.
. Bashrc or. bashrc.
18. crontab: to add a scheduled execution task in a Linux environment, you can use this command to add or delete the execution script. Parameters:

-U indicates that the user executes the task. Generally, the root user needs this parameter when executing this command.

-L listing details of a user's cron service-r deleting a user's cron service-e editing a user's cron Service

The edited format is:

01 *** root run-parts/etc/cron. Hourly

The task description format is as follows:

Minute hour day month dayofweek command Minute-Integer from 0 to 59

Hour-Integer from 0 to 23
Day-Integer from 1 to 31 (must be the valid date of the specified month)
Month-An integer from 1 to 12 (or a month abbreviated as Jan or FeB)
Dayofweek-An integer ranging from 0 to 7. The integer 0 or 7 is used to describe Sunday (or abbreviated as sun or Mon)
Command-Commands to be executed (as ls/proc>/tmp/proc or commands to execute custom scripts)
Root indicates running as root user
Run-parts indicates that a folder is followed by all the scripts in the folder.

Run the/etc/init. d/crond restart command to restart the crond process. See: http://www.blogjava.net/decode360/archive/2009/09/18/287743.html

18. xargs: xargs is a common command for UNIX and Unix-like operating systems. It is used to convert the parameter list into small segments and pass it to other commands to avoid the problem that the parameter list is too long.

For example, the following command:
rm `find /path -type f`
If there are too many files in the path directory, an error will be reported because the "parameter list is too long" and cannot be executed. However, after xargs is used, the problem is solved.
find /path -type f -print0 | xargs -0 rm
In this example, xargs splits the long string file list generated by find into multiple substrings and calls RM for each substring. For example, it is much more efficient to use the find command.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.