Linux Memo Recorder

Source: Internet
Author: User

Miscellaneous Records
  • Ubuntu /etc/network/interfaces does not seem to take effect by modifying the IP and restarting the network service. You can restart the computer for it to take effect, or perform:

  • Generate random Characters/numbers:

    • Using a Linux built-in variable $RANDOM , the variable will randomly output 0-32767 a range of numbers.
      ' shell 随机输出0-255范围的数字 echo expr $RANDOM/128 '

    Random output 1-255 range of numbers
    Echoexpr $RANDOM / 129 + 1
    ```

  • Tar package specified directory (relative path)

    tarthe "absolute path" is displayed when you use a packaged file/directory for decompression. Example: Pack now /etc/sysconfig/ , /var/log two directories

    [[email protected] tmp]# tar -zcpf test.tgz /etc/sysconfig /var/log[[email protected] tmp]# tar -zxf test.tgz [[email protected] tmp]# lsetc  test.tgz  var

    You can see tar that it is packaged by an absolute path. To package only sysconfig and log two directories, use the -C parameters

    [[email protected] tmp]# tar -zcpf test.tgz -C /etc sysconfig -C /var log[[email protected] tmp]# tar -zxf test.tgz [[email protected] tmp]# lslog  sysconfig  test.tgz
  • sedString Case Conversion

    大写转小写:echo ‘ABC‘ | sed ‘s/[A-Z]/\l&\g‘小写转大写:echo ‘abc‘ | sed ‘s/[a-z]/\u&\g‘
  • sedMultiple substitutions

    example, capitalize the string ABcd3+4/ZZ to lowercase, and remove the punctuation ([:p UNCT:] is a collection of punctuation marks):

    $ echo ‘ABcd3+4/ZZ‘ | sed ‘s/[0-9]//g;s/[A-Z]/\l&/g;s/[[:punct:]]//g‘abcdzz

Linux Memo Recorder

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.