1. 程式人生 > >GRUB2的配置方法【涉及/etc/default/grub,/etc/grub.d/*】

GRUB2的配置方法【涉及/etc/default/grub,/etc/grub.d/*】

介紹 

GRUB 2 通過執行/etc/grub.d/folder  目錄下的指令碼來 建立配置檔案 (grub.cfg) ,並且/etc/default/grub這個檔案也可以配置。update-grub命令(手動執行,或更新核心的時候會被執行)  可以自動更新grub.cfg .這個命令會啟用上面的指令碼,並且會尋找系統中存在的作業系統和核心。一旦發現作業系統或核心,那麼它們會被加入到 GRUB 2 的啟動選單當中。 

通過以下兩個命令中的任意一個 可以知道,GRUB2被安裝在了哪個分割槽:

  • Device: sudo grub-probe -t device /boot/grub

  • UUID: sudo grub-probe -t fs_uuid /boot/grub

例如: 

$ grub-probe -t device /boot/grub/
/dev/sda1
$ sudo grub-probe -t fs_uuid /boot/grub/
efa0f8fd-d69d-4931-8275-d25f8871511d
$ sudo grub-probe -t device /boot/grub/
/dev/sda1
$
$ df -h
檔案系統            容量  已用  可用 已用%% 掛載點
/dev/sda5              19G   16G  2.3G  87% /
none                  1.5G  672K  1.5G   1% /dev
none                  1.5G  104K  1.5G   1% /dev/shm
none                  1.5G  356K  1.5G   1% /var/run
none                  1.5G     0  1.5G   0% /var/lock
/dev/sda1             3.7G  132M  3.4G   4% /boot     # 我這臺機的 grub2是裝在 /boot 分割槽的

/dev/sda8             426G  303G  102G  75% /home
/dev/sda7             5.6G  417M  4.9G   8% /opt
df: "/home/swtd1/.gvfs": 無效的跨裝置連線
/home                 426G  303G  102G  75% /home

安裝 在 sda1 的作業系統接管 grub2。

主目錄和檔案 -- Main Directories & Files

The Menu: /boot/grub/grub.cfg

grub.cfg 這個檔案,在以前的grub版本( GRUB 0.97')是 menu.lst

    。grub.cfg這個檔案不像 menu.list這個檔案, menu.list是直接編輯的。

而grub.cfg是用命令(每個命令負責這個配置檔案中的某一塊的更新)來更新的。

grub.cfg 通過執行update-grub    來更新的。update-grub 其實就跟如下命令是一個作用。

      grub-mkconfig -o /boot/grub/grub.cfg.

如果使用者希望在一個不同的位置建立一個不同名字的啟動選單的話,就需要通過 “-o” 選項來指定新的路徑。

當 grub-install  命令執行的時候,並不建立或者更新 grub.cfg 檔案。

直接修改 grub.cfg  --- Editing grub.cfg directly

手動修改 grub.cfg 需要注意:

如果其他的任務會執行 update-grub ,那麼應該在 update-grub 執行之後, 再編輯 grub.cfg  。也就是說在編輯grub.cfg之前,應該所有需要的核心和相關資源已經有了。

當然,你手動編輯的內容,一般來說在下次執行update-grub  之後,都會被覆蓋掉。update-grub 是根據它自己的規則來更新grub.cfg。

 grub.cfg的部分內容 是/etc/grub.d     下的指令碼生成的。使用者可以根據需要編輯這個目錄下的指令碼。

使用者設定: /etc/default/grub

/etc/default/grub 檔案包含了很多預設配置。

 /usr/sbin$ ls grub-*
grub-install   grub-mkdevicemap  grub-probe   grub-set-default
grub-mkconfig  grub-mknetdir     grub-reboot  grub-setup

 在 /usr/sbin 目錄下,以 grub- 開頭的檔案都是 指令碼檔案,並非二進位制可執行檔案。

很多預定義的變數包含在/usr/sbin/grub-mkconfig    這個檔案中,用如下命令可以列出這些預定義的變數:

grep "export GRUB_DEFAULT" -A50 /usr/sbin/grub-mkconfig | grep GRUB_

/usr/sbin$ grep "export GRUB_DEFAULT" -A50 /usr/sbin/grub-mkconfig | grep GRUB_
export GRUB_DEFAULT \
  GRUB_HIDDEN_TIMEOUT \
  GRUB_HIDDEN_TIMEOUT_QUIET \
  GRUB_TIMEOUT \
  GRUB_DEFAULT_BUTTON \
  GRUB_HIDDEN_TIMEOUT_BUTTON \
  GRUB_TIMEOUT_BUTTON \
  GRUB_BUTTON_CMOS_ADDRESS \
  GRUB_BUTTON_CMOS_CLEAN \
  GRUB_DISTRIBUTOR \
  GRUB_CMDLINE_LINUX \
  GRUB_CMDLINE_LINUX_DEFAULT \
  GRUB_CMDLINE_XEN \
  GRUB_CMDLINE_XEN_DEFAULT \
  GRUB_CMDLINE_NETBSD \
  GRUB_CMDLINE_NETBSD_DEFAULT \
  GRUB_TERMINAL_INPUT \
  GRUB_TERMINAL_OUTPUT \
  GRUB_SERIAL_COMMAND \
  GRUB_DISABLE_LINUX_UUID \
  GRUB_DISABLE_RECOVERY \
  GRUB_VIDEO_BACKEND \
  GRUB_GFXMODE \
  GRUB_BACKGROUND \
  GRUB_THEME \
  GRUB_GFXPAYLOAD_LINUX \
  GRUB_DISABLE_OS_PROBER \
  GRUB_INIT_TUNE \
  GRUB_SAVEDEFAULT \
  GRUB_BADRAM

指令碼: /etc/grub.d/

$ ls /etc/grub.d/
00_header        10_linux      20_memtest86+  40_custom  README
05_debian_theme  20_linux_xen  30_os-prober   41_custom

 在 /etc/grub.d/ 目錄下的指令碼,當 update-grub執行的時候,會被讀取,併合併到 /boot/grub/grub.cfg   這個檔案中。

grub.cfg檔案中的 選單條目的放置,是由 /etc/grub.d/   目錄下的指令碼執行的順序來決定的。檔名以數字開頭的的指令碼會被先執行,並且數字小的先執行。比如10_linux20_memtest之前執行。而20_memtest   會在40_custom  之前執行。檔名以字母開頭的(alphabetic)的指令碼在數字命名的指令碼之後執行。

 自定義的 啟動選單入口(menu entries)可以被新增到40_custom   這個檔案中,或者單獨建立一個檔案。40_custom  中的選單入口將會出現在啟動選單的最底部。一個以“06_”開頭的自定義檔案,將出現在 啟動選單的最頂部。

 update-grub執行的時候,  /etc/grub.d/ 下的指令碼會被執行。

指令碼描述:

  • 00_header

  • 設定環境變數,比如 系統檔案位置、video設定和之前儲存的入口(previously saved entries 。這個也匯入了一些相關的東西(儲存在/etc/default/grub)。使用者通常不需要改變這個檔案。

  • 05_debian_theme

  • 10_linux

  • 識別在 root device中作業系統正在使用的核心,並且為這些核心建立(menu entries) . 這個包含了相應的“recovery mode (恢復模式)”選項。在GRUB 1.99和之後的版本中, 在 啟動主選單頁面,僅顯示最新的核心。其他的核心被包含在了子啟動選單中( submenu)。 更多submenu相關資訊請參考Grub2/Submenus  。

    Note:對於早期的GRUB 2版本, 所有位於 boot目錄的核心都包含在 main menu 中. 如果要減少顯示的核心,那就要刪除/boot資料夾下的舊核心,或者使用一個有效的的grub2自定義應用。

  • 20_memtest86+

  • 尋找 /boot/memtest86+.bin ,並且把它作為一個選項加入到 GRUB 2 啟動選單(boot menu)當中。當前沒有任何方式可以從這個啟動選單當中去除這個“memtest86+”的入口。但是,可以通過去掉檔案可執行許可權,並執行update-grub的方式來禁止ofmemtest86+ 的顯示:

    • sudo chmod -x /etc/grub.d/20_memtest86+
      sudo update-grub
  • 30_os-prober

  • 這個指令碼使用“os-prober” 去搜索linux和其他作業系統,並且把結果放置到GRUB 2 的選單中。

    1. 這個檔案包含如 Windows, Linux, OSX, 和 Hurd 這些作業系統的選項。
    2. 在這個檔案中的一些變數,決定了 在/boot/grub/grub.cfg  檔案中GRUB 2 menu 中 最終被顯示的某系名字的格式(format of the displayed names)。 熟悉基本指令碼的使用者可以改變這些變數,以達到改變 GRUB2選單入口格式 的目的。

    3. The user can insert an entry into /etc/default/grub which disables this script (seeConfiguring GRUB 2). Removing the executable bit from the file will also prevent it from searching for other operating systems.

    4. By default os-prober ignores any disks that possess "dmraid" signatures, which can be listed via sudo dmraid -r -c (if installed).

    5. If the script finds another Ubuntu/Linux operating system, it will attempt to use the titles contained in the10_linux section of that installation'sgrub.cfg file. If not found, the script will construct a menuentry from the actual boot information it locates.

  • 40_custom 

    這個檔案是一個新增自定義啟動選單入口的模板。當執行 update-grub的時候,這個檔案的內容會被加入到grub.cfg總。

    1. The contents of this file, below the "exec tail -n +3 $0" line and the default comments, are imported directly into/boot/grub/grub.cfg without any changes.

      1. As the comments at the top of the file state, add custom lines below those already contained in the40_custom file.

    2. The file can be renamed or copied. The file must be executable to be incorporated into the GRUB 2 menu.
      1. As mentioned in the introduction of this section, the name of the file determines the location of its contents in the GRUB 2 menu. As a general rule, if using numerals at the start it is advisable to allow the00_header and05_debian_theme scripts to be run before the first custom menu. These files contain no menuentries and thus will not interfere with a menuentry from a custom script with a lower priority.

Configuring GRUB 2

Configuration changes are normally made to /etc/default/grub and to the custom files located in/etc/grub.d. Any changes made directly to the/boot/grub/grub.cfg are overwritten wheneverupdate-grub is executed either by the user or when called automatically by various system functions.

After editing /etc/default/grub or the scripts in the/etc/grub.d folder the user should runsudo update-grub to incorporate the changes into the GRUB 2 menu.

info.png Some of the most common changes, such as the default OS/kernel and menu timeout, can be changed from within a GUI applications such as Grub Customizer.

/etc/default/grub

This file contains basic settings which would be considered normal for the user to configure. Options include the time the menu is displayed, the default OS to boot, etc. The default options included in file upon installation are only a small number of the variables which GRUB 2 can recognize. The GRUB 2 defined variables can be identified using the command previously documented in theGRUB 2 Settings section or at the end of this section.

In addition to the defined variables, the user may introduce self-created variable(s) and use them in the scripts contained in the/etc/grub.d folder.

Editing the File

The grub file is a system file, therefore any editing must be done by a user with 'Administrator/root' privileges. The file is a simple text file and can be edited by any text editor. The default text editor in Ubuntu is Gedit, and the file can be edited with the following command. "gksu" is the graphical equivalent of "sudo" and the "&" allows the terminal to be used to update GRUB 2 once the user saves the file.

  • gksu gedit /etc/default/grub &

After making changes and saving the file, the GRUB 2 menu must be updated to include the changes by running:

  • sudo update-grub

Specific Entries

This section details some of the entries available in the /etc/default/grub file. Much of this information can also be found by referring the theGnu GRUB manual or on the system itself by running the following command:

  • info -f grub -n 'Simple configuration'
  • GRUB_DEFAULT=

    • Sets the default menu entry. Entries may be numeric, a complete menuentry quotation, or "saved"
      1. GRUB_DEFAULT=0 Sets the default menu entry by menu position. The first "menuentry" ingrub.cfg is 0, the second is 1, etc.

        • Note: Grub 1.99 introduces a submenu menu structure. For a menu item in a submenu, the entry becomes a two-digit entry. The first entry is the position of thesubmenu title in the main menu. The second entry is the position within thesubmenu. If the submenu is the 3rd entry in the main entry, and the user wishes to boot the first entry in thesubmenu, it would be designated as "2>0".See the community documentation for a fuller explanation:Grub2/Submenus.

      2. GRUB_DEFAULT="xxxx" An exact menu entry, including the quotation symbols, may also be used. In this case, location in the menu will not matter.

        • Example: GRUB_DEFAULT="Ubuntu, Linux 2.6.31-9-generic"

        • Example (Submenu Entry): GRUB_DEFAULT="2>Ubuntu, Linux 2.6.38-8-generic"

      3. GRUB_DEFAULT=savedThe information in this section applies to GRUB 1.98 and later. The "saved" entry enables the "grub-reboot" and "grub-set-default" commands to set the default OS for future boots.

        • The default OS for future boots will not be set merely by selecting an OS when booting.

        1. grub-set-default Sets the default boot entry until changed.

          • The format is sudo grub-set-default X, withX being the menu entry position (starting with 0 as the first entry) or the exact menu string.

            • Example: sudo grub-set-default 3

            • Example: sudo grub-set-default "Ubuntu, Linux 2.6.32-15-generic"

          • To obtain the existing menu entry choice number (starting from 0) or the menu entry "string", run:
            • grep menuentry /boot/grub/grub.cfg

  • grub-reboot This command sets the default boot entryfor the next boot only. The format of the command is the same as forgrub-set-default (see above).

GRUB_SAVEDEFAULT=

  • If set to true this setting will automatically set the last selected OS from the menu as the default OS on the next boot.

    • No commands need be run to set the default OS.
    • Any time a menu entry is manually selected from the GRUB 2 menu, it becomes the default OS.
    • This option currently does not work if your /boot directory resides on an LVM partition or RAID.
    • For this to work you must also set GRUB_DEFAULT=saved.

    Note: Ubuntu's version of Grub 1.99 introduced the submenu feature. Designating a default boot option located in thePrevious Linux versions submenu requires special formatting. For information regarding the submenu feature, please refer toGrub2/Submenus

GRUB_HIDDEN_TIMEOUT=0

  • Wait this many seconds for the user to press a key. During this period no menu is shown unless the user presses a key. If no key is pressed, control is passed to GRUB _TIMEOUT when the GRUB_HIDDEN_TIMEOUT expires. See the note regarding bugs to this feature at the end of this section.
    • The developers envisioned using this setting with a GRUB_TIMEOUT value of 0. This would give users a period of time (GRUB_HIDDEN_TIMEOUT) to display the menu by pressing a key, after which the system would boot without the menu being displayed (GRUB_TIMEOUT=0).
  • GRUB_HIDDEN_TIMEOUT=0

    • No menu is displayed. The system is immediately booted to the default OS.
    • This is the default setting with only one identified operating system.
      • To display the menu under this condition, place a # symbol at the start of the line and ensure the GRUB_TIMEOUT setting is a positive integer.

    • If the value is set to 0, a keystatus check is performed to determine if theSHIFT key is depressed. If GRUB 2 determines theSHIFT key is depressed during the boot process, the menu will be displayed. This gives the user a method of interrupting an automatic boot which would normally not display the menu.

  • GRUB_HIDDEN_TIMEOUT=X

    • X is a positive integer (e.g. 1, 5, 10, etc)

    • The boot process will pause and display a blank screen or the designated splash image forX seconds. At the end of the time period, the system will boot. No menu will be displayed.

    • While GRUB_HIDDEN_TIMEOUT is active, the menu can be displayed by pressing any key.
  • GRUB_HIDDEN_TIMEOUT=

    • No value entered after the = sign

    • The menu will be displayed for the number of seconds designated by GRUB_TIMEOUT.

GRUB_HIDDEN_TIMEOUT_QUIET=true

  • Determines whether a countdown timer is displayed on a blank screen when using theGRUB_HIDDEN_TIMEOUT feature.

    • true No countdown is displayed. The screen will be blank.

    • false A counter will display on a blank screen for the duration of the GRUB_HIDDEN_TIMEOUT value.

    Note: There is a longstanding confirmed bug on the hidden menu feature in GRUB 1.97 to GRUB 1.99. The menu may not hide as specified in the description on this page. While editing the30_os-prober script can fix this issue, it is beyond the scope of this page.

GRUB_TIMEOUT=10

  • Sets the time period in seconds for the menu to be displayed before automatically booting unless the user intervenes.
    • This instruction begins at the expiration of GRUB_HIDDEN_TIMEOUT.
    • Setting this value to -1 will cause the menu to display until the user makes a selection.
    • On a single OS system, by default this setting is not used and the menu will not display.
      • To display the menu on each boot:
        • Place a comment symbol (#) in front of the GRUB_HIDDEN_TIMEOUT entry

        • Make the GRUB_TIMEOUT value 1 or higher.

GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian

  • Retrieves the descriptive name in the menu entry. (Ubuntu, Xubuntu, Debian, etc.)

GRUB_CMDLINE_LINUX

  • Entries on this line are added to the end of the 'linux' command line (GRUB legacy's "kernel" line) for both normal and recovery modes. It is used to pass options to the kernel.

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

  • This line imports any entries to the end of the 'linux' line (GRUB legacy's "kernel" line). The entries are appended to the end of the normal mode only.
    • To view a black screen with boot processes displayed in text, remove "quiet splash".To see the grub splash image plus a condensed text output, use "splash".

#GRUB_TERMINAL=console

  • Uncomment to disable graphical terminal. This may provide help if the GRUB 2 menu is too large or unreadable. It also may help when using the GRUB_HIDDEN_TIMEOUT feature.

#GRUB_DISABLE_LINUX_UUID="true"

  • Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
    • The search line will still use UUIDs. The linux line will use the/dev/sdXY convention when this option is enabled.

#GRUB_GFXMODE=640x480

  • GRUB 2 will automatically set the menu resolution to what it thinks is the best option. Uncommenting this line will set the resolution to 640x480, or you may change the value to another GRUB-compatible setting.
    • The setting applies only to the boot menu display, not the resolution of the operating system that boots.
      • Tip: Setting the same resolution in GRUB 2 and the operating system will decrease boot times slightly.
    • Although not required, the user can also specify the color bit depth by appending it to the resolution setting. An example would be 1280x1024x24 or 640x480x32.
    • The user can also add multiple resolutions. If GRUB 2 cannot use the first entry, it will try the next setting. Settings are separated by a comma. Example:1280x1024x16,800x600x24,640x480.

    • If using a splash image, the resolution setting and the splash image size should be compatible for best results.
    • If using an entry that produces a "not found" message when runningupdate-grub, try adding or changing the color bitdepth.

    • Resolutions available to GRUB 2 can be displayed by typing vbeinfo in the GRUB 2 command line. The command line is accessed by typing "c" when the main GRUB 2 menu screen is displayed.

    • If this line is commented (#) or the resolution is unavailable GRUB 2 uses the default setting determined by/etc/grub.d/00_header.

      • In GRUB 1.99 (Natty) the 'optimum' resolution is selected by GRUB if no resolution is specified.

#GRUB_DISABLE_LINUX_RECOVERY=true

  • Allows the user to prevent the recovery options from inclusion on the GRUB 2 menu.
    • Uncomment (remove the # symbol) to prevent the "Recovery" mode kernel options from appearing in the menu. If you want a "Recovery" option for only one kernel, make a special entry in /etc/grub/40_custom.

GRUB_INIT_TUNE="480 440 1"

  • Removing the comment symbol (#) allows GRUB 2 to play a single beep just prior to the Grub 2 menu display. More complex tunes can be designed by expanding the pitch/duration values.

    • The format is tempo [pitch1 duration1] [pitch2 duration2] ...

      • tempo is set once and applies to all duration settings.

      • duration is the result of 60/tempo. A duration of 1 with atempo of 60 would produce a 1 second beep. Aduration of 1 with atempo of 480 produces a .125 second beep.

    • Caution: The menu is displayed after the tune is complete. Creating a long tune will delay the appearance of the menu.
    • Online documentation is available by typing info grub --index-search play in a terminal. It mentions the ability to play a tune with the commandplay file if the tune is composed with little-endian numbers.

GRUB_BACKGROUND

  • Sets the background image, enter the full path to the image here. See splash image configuration above for further details and other options.

GRUB_DISABLE_OS_PROBER=true

  • This entry is used to prevent GRUB from adding the results of os-prober to the menu. A value of "true" disables the os-prober check of other partitions for operating systems, including Windows, Linux, OSX and Hurd, during execution of theupdate-grub command. Using this option rather than removing the executable bit from the/etc/grub.d/30_os-prober file has several advantages:

    • The setting can be easily changed while making other changes to thegrub file.

    • While both methods prevent os-prober from running and placing items in the menu display, using this setting allows the30_os-prober script, but not theos-prober command, to run. This script enables the GRUB_HIDDEN_TIMEOUT setting and/or the ability to display a hidden menu by pressing the ESC key (depending on other settings). This functionality is lost if the30_os-prober script is disabled by making it unexecutable.

info.png To inspect the currenlty-available predesignated variables on your system's GRUB 2 library files, run:

    • grep DEVICE -A40 /usr/sbin/grub-mkconfig

User-Assigned Variables

  • Variables in the /etc/default/grub file are read and acted upon as needed. This allows users to add their own variables in a central location and then alter the GRUB 2 scripts to meet their needs. Keeping the user-defined variables within this file allows easier management of, and change to, those variables when desired. To add a variable, use the following format:

    • export <VARIABLE>

  • The following example would define a variable used to omit a specific Ubuntu partition from the menu:
    1. Define and export the variable in /etc/default/grub :

      • export GRUB_EXCLUDE_PARTITION="/dev/sda1"

    2. Establish the conditional in /etc/grub.d/30_os-prober in the10_linux section:

      • if [ $GRUB_EXCLUDE_PARTITION = $LROOT ]; then

      • or
      • if [ ! $GRUB_EXCLUDE_PARTITION = $LROOT ]; then

      • Complete the conditional at the appropriate point in the script
    3. Save the files and run sudo update-grub to incorporate the changes into the GRUB 2 menu.

相關推薦

GRUB2配置方法涉及/etc/default/grub/etc/grub.d/*

介紹  GRUB 2 通過執行/etc/grub.d/folder  目錄下的指令碼來 建立配置檔案 (grub.cfg) ,並且/etc/default/grub這個檔案也可以配置。update-grub命令(手動執行,或更新核心的時候會被執行)  可以自動更新gru

SQLyog恢復數據庫報錯解決方法Error Code: 2006 - MySQL server has gone away

bsp -s share con usr sqlyog owin depend def https://blog.csdn.net/niqinwen/article/details/8693044 導入數據庫的時候 SQLyog 報錯了 Error Code: 20

idea配置checkstyle 提高程式碼質量,檢查程式碼規範的工具 CheckstyleFindBugsPMDJtest

idea,配置checkstyle 【提高程式碼質量,檢查程式碼規範的工具 】Checkstyle,FindBugs,PMD,Jtest 2016年12月15日 14:19:02 common_util 閱讀數:18818更多 個人分類: 開發 版權宣告:本文為博主原創文章,可以轉載分

GRUB2配置詳解:預設啟動項超時時間隱藏引導選單配置檔案詳解圖形化配置

配置檔案詳解: /etc/default/grub # 設定預設啟動項,推薦使用數字 GRUB_DEFAULT=0 # 註釋掉下面這行將會顯示引導選單 #GRUB_HIDDEN_TIMEOUT=0 # 黑屏,並且不顯示GRUB_HIDDEN_TIMEOUT過程中的倒計

idea配置checkstyle 提高程式碼質量,檢查程式碼規範的工具 Checkstyle

CheckStyle是SourceForge下的一個專案,提供了一個幫助JAVA開發人員遵守某些編碼規範的工具。它能夠自動化程式碼規範檢查過程,從而使得開發人員從這項重要,但是枯燥的任務中解脫出來。 CheckStyle檢驗的主要內容 列表內容 Jav

HDU2609——How many最小表示法set去重

How many Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4190 &nbs

HDU 2544 最短路Dijkstra演算法堆優化Vector建圖

最短路 Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 55757    Accepted Submissi

C# RSA加密、解密、加簽、驗籤、支援JAVA格式公鑰私鑰、PEM格式公鑰私鑰、.NET格式公鑰私鑰 -變態模式支援私鑰加密公鑰解密(二)

RSA變態模式:【私鑰加密,公鑰解密】 一般這種寫法都是JAVA弄的。.NET原生不支援。為啥,我也不清楚,大概是因為安全性問題吧,畢竟公鑰是人人都可是持有的。私鑰只有自己擁有。 簽名一直都是【私鑰加簽、公鑰驗籤】只為證明該訊息是你發出來的。 這裡使用了BouncyC

胡侃學習(理論)計算機被大佬推薦轉載以膜拜

《胡侃學習(理論)計算機》 作者: Sir (阿澀)   我也來冒充一回高手,談談學習計算機的一點個人體會。由於我是做理論的,所以先著重談談理論。   記得當年大一,剛上本科的時候,每週六課時數學分析,六課時高等代數,天天作業不斷(那時是六日工作制)。頗有些同學驚呼

NYOJ129 樹的判定 || POJ1308 Is It A Tree? 並查集應用樹的定義

一個有向圖入度為1的節點僅有一個,並且無環,則是一顆樹。 #include<cstdio> #include <cstring> using namespace std; const int MAXSIZE = 10002; int pre[MA

C# RSA加密、解密、加簽、驗籤、支援JAVA格式公鑰私鑰、PEM格式公鑰私鑰、.NET格式公鑰私鑰、一般模式支援公鑰加密私鑰解密(一)

2017-12-04日更新:增加支援微信支付。程式碼註釋中//☆☆☆☆.NET 4.6以後特有☆☆☆☆的別用,那個不對。 RSA非對稱加密。簡明扼要吧,直說乾貨。(在此特別感謝下貳進位制,提供JAVA版的公鑰私鑰) C#RSA加簽解籤加密比較常見,一般遇到的問題是非.NET

bootstrap入門按鈕式下拉選單輸入框組

按鈕式下拉選單沒什麼好說的,就是以前學過的東西做了一個巢狀而已。注意dropup即可實現上拉 輸入框組分前面加《span》,後面加和兩頭加三種,還可以新增按鈕,下拉選單,單選複選框哦~ <!DOCTYPE html> <html> <hea

Linux操作系統下/etc/hosts文件配置方法

主機名 進行 問題 解釋 很快 中一 linux 同時 包括 1、關於/etc/host,主機名和IP配置文件   Hosts - The static table lookup for host name(主機名查詢靜態表)   hosts文件是Linux系統中一個負責

STORAGEQlogic FC存儲交換機cmd配置方法

dmi bsp pos add rac .net edi csdn clu *************************************************************** ****原文: blog.csdn.net/clark_xu

監控Jprofiler監控tomcat的配置方法及報錯解決過程

could CA 監聽端口 arch https img .net http 沒有 準備工作: 1.Jprofiler for Linux安裝包一個(服務端) 2.Jprofiler for windows安裝包一個(客戶端) 3.各自安裝、解壓 Linux:/opt/jp

Mac OS下安裝MongoDB以及配置方法總結筆記

用戶 base ces 內容 bsp 完成後 light roo reat 首先打開命令框,輸入: brew install mongodb   安裝完成後 啟動、停止、重啟如下 brew services start mongodb brew s

properties配置檔案修改後讀取不到的解決方法終極方案

相信很多人也都遇到過這個問題了,最近又一次遇到了,不是讀不到內容就是報 IllegalArgumentException: Malformed \uxxxx encoding.這次小結一下之前的解決方法。 1.將工程clean一下,然後繼續跑,如果解決就OK,不行看第二條。 2.終極方案:更換

CentOS防火牆的配置方法詳解iptables

CentOS6/7系統是基於linux中的,它的防火牆其實就是iptables了。 下面我來介紹在CentOS防火牆iptables的配置教程,希望此教程對各位朋友會有所幫助。 iptables是與Linux核心整合的IP資訊包過濾系統,其自帶防火牆功能,我們在配置完伺服器的角色功能後,需要修改iptab

CentOS防火墻的配置方法詳解iptables

config 虛擬機 朋友 主動模式 pop3 restart eve fig 0.10 CentOS6/7系統是基於linux中的,它的防火墻其實就是iptables了。 下面我來介紹在CentOS防火墻iptables的配置教程,希望此教程對各位朋友會有所幫助。 ipt

PE/vsVisual Studio自定義生成工具配置方法和相關vs系統變數含義

DATE: 2018.11.20 1、自定義生成工具配置方法 以x86純彙編編譯為例: x86純彙編的編譯需要yasm彙編器工具,在VC系統路徑下檢視當前系統中是否含有可用的yasm.exe: where yasm.exe 可以將yasm.exe放在C盤windo