My linux FAQ

Source: Internet
Author: User
Tags snmp mysql command line
  1. Query whether the system is 32-bit or 64-bit by using commands
    Getconf LONG_BIT or getconf WORD_BIT
    For example:
    [Root @ sy02/] # getconf LONG_BIT
    64

    File command
    For example:
    [Root @ sy02/] # file/bin/ls
    /Bin/ls: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), for GNU/Linux 2.4.0, dynamically linked (uses shared libs), stripped

  2. View files in Mb
    Ls-lh
  3. Filter display files
    For example, only the ending xml file ls *. xml is displayed.
  4. View the remaining disk space:
    Df-hl
  5. Download files from ssh to the local machine:
    Session sftp tab option: Set the local Destination path
    Sz filename. filetype
  6. Copy files between two servers
    Scp-P 2188 user @ ip:/path/file.
  7. Clear files:
    True> des.txt
  8. Svn file submission:
    Svn-m "message" filename does not write "-m" information cannot be submitted, and message is a good habit!
  9. Tar command to decompress the file:
    Tar xzvf this.tar.gz "tar xzvf this.tar.gz./" this command indicates that it is unavailable after being decompressed to this directory.
  10. Create FILE command
    Touch filename
  11. Line breaks in Windows and linux are inconsistent
    In Linux, the line feed is \ n, while in Windows, the line feed is \ r \ n. If the two files are not processed, problems may occur when they are displayed. For example, if a Linux text file is opened in Windows notepad, the line feed format is not messy, if a Windows file is opened with VI in Linux, ^ M characters will appear.
    Solution:
    Use CMD: dos2unix and unix2dos in Linux
    Dos2unix/unix2dos included in the Tofrodos installation package
    DOS text files traditionally have CR/LF (carriage return/line feed) pairs as their new line delimiters while
    Unix text files traditionally have LFs (line feeds) to terminate each line.
    Tofrodos comprises one program, "fromdos" alias "todos", which converts text files to and from these formats.
    Use "fromdos" to convert DOS text files to the Unix format, and "todos" to convert Unix text files to the DOS format.
    This functionality is also available via the dos2unix/unix2dos symlinks.
    Install dos2unix/unix2dos in UBUNTU:
    $ Sudo apt-get install tofrodos
  12. Alias directory alias for easy access
    Vi ~ /. Bashrc
    Alias scserver = "cd/usr/local/netqin/boss/netqin/BOSS_ SC _SERVICE/trunk/src"
    Valid only when a user enters ssh again
  13. View the total number of files in the current directory:
    Ls-l | grep "^-" | wc-l
  14. Vi jump
    The "home" "end" key does not work.
    To the end of a line: "$" command
    Start with a line: "0" command
    The command to scroll a whole screen forward is a CTRL-F (minus two lines ). The reverse command is CTRL-B.
  15. Vi Delete multiple rows: ndd Delete n rows starting with the current row
  16. When you delete a large number of files in linux, an error occurs when you directly use rm:-bash:/bin/rm: The parameter list is too long.
    You can use the find command in combination. Example: 1. Change rm *-rf to find.-name "*" | xargs rm-rf. 2. Change rm test *-rf to find.-name "test *" | xargs rm-rf "test *"
  17. Remotely log on to other servers through ssh-p 2188 username @ ip
  18. BotNet cleanup method
    Kill-18 PPID (PPID is its parent process)
    This signal tells the parent process that the child process has died. Please reclaim the resources allocated to it.
  19. Search for a string in a file
    Grep-n "str"-r./This is to find all files containing the str string under the current directory and under the subdirectories
    Grep-R abc * searches for the string abc in the files in the local directory and all its subdirectories.
  20. Manually install the rz sz package in Linux
    Wget http://freeware.sgi.com/source/rzsz/rzsz-3.48.tar.gz
    Tar zxvf rzsz-3.48.tar.gz
    Install cd rzsz-3.48
    Modify the fourth line of Makefile OFLAG =-O to OFLAG =-O-DREGISTERED.
    Make posix (make and several configuration options generally use posix)
    Cp rz sz/usr/bin /.
  21. Linux File Cutting
    Split-B 10 m filename.txt m must be lowercase cut to 10 m each file
  22. View open files
    When the disk of the tmp directory on the server is full, it is invalid to directly clear or delete files, and the space cannot be released. You need to run the root user lsof command to check the files occupied by the program and find the program, kill and restart.
    Lsof (list open files) is a tool used to list open files in the current system. In linux, everything exists in the form of a file. Through a file, you can not only access common data, but also access network connections and hardware.
    Enter lsof in the terminal to display the files opened by the system. Because lsof needs to access the core memory and various files, it must be run as the root user to make full use of its functions.
  23. Secure CRT rz File Upload Error
    The size of the File Uploaded By rz is not the same as that of the local file. After 10 MB of the file is uploaded, only 343 bytes are left. Later, it was found that the rz dialog box was accidentally hooked up.
    Upload file as ascii, normal after Removal
  24. Install Net: SNMP
    1) By CPAN (best)
    On command line, as root:
    [Your_host] # perl-MCPAN-e shell
    Cpan shell -- CPAN registration and modules installation (v1.76)
    ReadLine support enabled
    Cpan> install Net: SNMP
  25. Ulimit: Modify the maximum number of opened files

    Linux has default ulimit restrictions on users. This file can be used to configure users' hard configuration and soft configuration. Hard configuration is an upper limit.
    If the modification exceeds the upper limit, an error such as "operation not allowed" will occur.
    Add/etc/security/limits. conf
    * Soft noproc 10240
    * Hard noproc 10240
    * Soft nofile 10240
    * Hard nofile 10240
    If nginx is used, it is best to adjust the configuration in it.

  26. Load Analysis
    Use ps faux to view the current process status
    R-Running
    S-Sleeping
    D-Waiting for something
    If a process is D for a long time, it indicates that the process may have problems, resulting in other process requests in the waiting state, the system load will rise sharply (http://www.andymillar.co.uk/blog/2006/12/24/linux-load-average-explained)
  27. Change the file owner
    Chown username somefile
    Chown-R username somedir (directory and sub-file)
    Chown username: usergroup somefile
  28. Linux Timestamp
    Http://tool.chinaz.com/Tools/unixtime.aspx
  29. How to decompress files in batches in linux-
    Find-maxdepth 1-name "*. bz2" | xargs-I tar xvjf {}
  30. Find.-name "*. java" | xargs wc-l
  31. Add route/sbin/route add-net 10.74.0.109 netmask route 255.255.255.255 gw 172.16.54.1 (machine to be added) (Local gateway)
    /Sbin/route to view the route table
  32. Crontab location
    For example, the true location of CentOS is/var/spool/cron.
  33. Curl display connection time
    Curl-o/dev/null-s-W' % {time_total} 'http://www.miotour.com
  34. Save the SQL running result of MySQL to a file
    Method 1: Use tee in mysql> prompt
    Mysql> tee output.txt
    Logging to file 'output.txt'
    Mysql> notee
    Outfile disabled.
    Method 2: Use the -- tee parameter of mysql command line tool
    $ Mysql --teew.ot.txt
    Logging to file 'ot.txt'
    Mysql>
    This will record all input and output content to the specified file (until exit ). If an existing file is specified, the result is appended to the file.
  35. Delete logs that have exceeded three days
    Find.-name "*. log. *"-mtime + 3 | xargs rm-rf
  36. Ssh password-less connection
    Access B from A without A password, then generate ssh-keygen-t rsa-p'-f/root/on /. the/root /. ssh/iauthorized_keys
    You need to enable/etc/ssh/sshd_config:

    PubkeyAuthentication yes
    AllowUsers root
    AuthorizedKeysFile. ssh/authorized_keys

  37. Linux java installation
    Http://lelong.iteye.com/blog/349549 settings. bashrc does not work, you need to set/etc/profile

    Export JAVA_HOME =/root/jre1.6.0 _ 31/
    Export PATH = $ PATH: $ JAVA_HOME/bin
    Export CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar
    And source/etc/profile

  38. Nc usage
    Detailed description of http://www.huanxiangwu.com/477/linux-nc-netcat
    1. chat function host nc-l 1234 client nc $ ip 1234 note version, some parameters must be added-lp
    2. telnet redis and add the command
    Echo-e "get test \ r \ n" | nc localhost 6379 redis must add the "\ r \ n" echo parameter-e to identify the backslash.
    3. telnet memcache and add the command
    Printf "set zhangyan 0 0 5 \ r \ n12345 \ r \ n" | nc 127.0.0.1 11211
    Printf "get zhangyan \ r \ n" | nc 127.0.0.1 11211
    Incr decr delete is similar
    From: http://blog.s135.com/post/384/
  39. Mac vim for python settings
    You need to install ctags gcc. gcc is best to use pkg version (I am using lion OS). All kinds of problems packaged with tar must be compiled with python before Automatic completion of full-featured mvim.
    After ctags is installed, you need to set it to vimrc. Otherwise, you cannot generate the member list (ctags: illegal option)
    Let Tlist_Ctags_Cmd = '/usr/local/bin/ctags'

    Left and right window switch Ctrl + ww more shortcuts http://www.clovery.org/tree-explorer-plugin-nerdtree-for-vim.html

    Ctrl + x followed by ctrl + o to display the Code Completion Function
    Vim python http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/

  40. Mysql int bigint range

    INT[(M)] [UNSIGNED] [ZEROFILL] 

    A normal-size integer. The signed range is-2147483648To2147483647. The unsigned range is0To4294967295.

    BIGINT[(M)] [UNSIGNED] [ZEROFILL] 

    A large integer. The signed range is-9223372036854775808To9223372036854775807. The unsigned range is0To18446744073709551615.

    If the range of project generation IDS is small and parseInt is used for parsing, an error occurs when the value exceeds 2147483647. The parsing method is changed to parseLong, but there are still risks. The database type is set to INT instead of BIGINT, if the number is exceeded, it cannot be generated.

  41. When installing python mysqldb in linux, the following error occurs: command 'gcc 'failed with exit status 1.

    Yum install gcc python-devel

  42. Create a folder in the mac/home Directory
    Sudo vim/etc/auto_master comment out the line of home and restart. If it is not restarted, only the execution of sudo automount is invalid after the local test.
  43. Iptables port editing

    Set the firewall in Linux. Take CentOS as an example to open the iptables configuration file:

     

    1. Vi/etc/sysconfig/iptables
    2.  

     

    Run the/etc/init. d/iptables status Command to check whether port 80 is enabled. If port 80 is not enabled, you can use either of the following methods:

    1. Modify the vi/etc/sysconfig/iptables command to add the firewall to open port 80

     

    1. -A RH-Firewall-1-INPUT-m state -- state NEW-m tcp-p tcp -- dport 80-j ACCEPT
    2.  

     

    2. Disable/enable/restart the Firewall

     

    1. /Etc/init. d/iptables stop
    2.  
    3. # Start
    4.  
    5. # Restart

     

     

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.