1. 程式人生 > >個人雜記-Ubuntu開機自啟動程式-啟動終端自動執行命令

個人雜記-Ubuntu開機自啟動程式-啟動終端自動執行命令

開機啟動到文字介面:

vi /etc/default/grub 將“quiet splash”改為“quiet splash text”

Ubuntu新增開機啟動項:

一.、直接新增啟動路徑:

將需要執行的程式啟動命令新增到 vi /etc/rc.local 文字檔案中。

二、 開機使用root自動登入:

1、修改/etc/lightdm/lightdm.config

將使用者名稱改為root

2、修改/root/.profile

將最後一行改為   tty -s && mesg n

三、啟動終端時自動執行命令(如自動切換目錄)

將命令新增至~/.bashrc文字最下面即可。

四、非桌面tty模式下自啟動方法如下(嵌入式中使用):

1、 需要開機自動登入root

在/usr/bin/下建立 autologin檔案--》#touch autologin

賦予可執行許可權--》 #chmod +x autologin

編輯檔案--》 #vi autologin

新增內容:

#!/bin/bash

/bin/login -f root

2、編輯tty檔案:

vi /etc/init/tty1.conf

將 exec /sbin/getty -8 38400 tty1

改為exec /sbin/getty -n -l /usr/bin/autologin -8 38400 tty1

3、 登入自啟動程式:

自動登入後,按次序查詢檔案:

/.bash_profile

/.bash_login

/.profile

修改查詢到的第一個檔案,將啟動命令新增到檔案末尾既可。

4、 reboot 重啟生效

五、 在嵌入式中自啟動:

1、 系統文字模式下自動登入

按照第四條建立 autologin檔案。

開啟etc/inittab

末尾一行修改為:

1:res.../sbin/getty -n -l /usr/bin/autologin 38400 tty1

2、 登陸後自啟動:

將啟動命令新增到 /etc/profile 末尾行 (在環境變數全部生效之後,在自動執行程式)