GVKun编程网logo

Ubuntu 设置系统环境变量和开机自启动(ubuntu 设置系统环境变量和开机自启动的区别)

1

本文将分享Ubuntu设置系统环境变量和开机自启动的详细内容,并且还将对ubuntu设置系统环境变量和开机自启动的区别进行详尽解释,此外,我们还将为大家带来关于apt-getupdate失败ubunt

本文将分享Ubuntu 设置系统环境变量和开机自启动的详细内容,并且还将对ubuntu 设置系统环境变量和开机自启动的区别进行详尽解释,此外,我们还将为大家带来关于apt-get update 失败 ubuntu:Tempory failure resolving 'cn.archive.ubuntu.com ubuntu、Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10 快速开启 BBR 加速 或 关闭 BBR 加速、install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd、Intel RealSense D435i Installation on Linux (Ubuntu 16.04 and Ubuntu 18.04)的相关知识,希望对你有所帮助。

本文目录一览:

Ubuntu 设置系统环境变量和开机自启动(ubuntu 设置系统环境变量和开机自启动的区别)

Ubuntu 设置系统环境变量和开机自启动(ubuntu 设置系统环境变量和开机自启动的区别)

Ubuntu 设置系统环境变量和开机自启动

Ubuntu系统环境变量详解

参考这篇文章,讲的非常详细

开机自启动

在Linux下设置软件开机自动有三种方式:

1、 自动启动应用程序——rc.local脚本
2、 自动启动服务——update-rc.d
3、 启动应用程序首选项
3、 使用Systemd

下面来逐一界面这三种方式:

一、自动启动应用程序——rc.local脚本

rc.local脚本是一个Ubuntu开机后会自动执行的脚本,在该脚本内添加命令行,开机时会自动执行。

  • 脚本路径/etc/rc.local

  • 需要root权限才能修改。

添加命令

打开文件,在exit 0前添加要执行的命令,里面可以直接写命令或者执行Shell脚本文件sh。

如下,添加的5行命令

第1,2行是用于输出log 的
第4,5行,是启动程序的

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.:
/bin/bash /usr/local/XX-Net-3.10.4/xx_net.sh 1>> /etc/mylog   # send stderr from rc.local to a log file 
2>&1   # send stdout to the same log file 
set -x    # tell sh to display commands before execution 
sudo miredo
sudo /usr/local/XX-Net-3.10.4/xx_net.sh start
exit 0

这里的设置开机自动执行的sudo命令也是可以执行的

rc.local命令不执行,程序不启动的问题

1、如下面所示,添加log,查看程序执行情况

2、rc.local文件头部/bin/sh修改为/bin/bash

3、如果是执行sh文件,那么要赋予执行权限sudo chmod +x xxx.sh,然后启动时加上sudo sh xxx.sh

二、自动启动服务——update-rc.d

使用 update-rc.d增加开机启动服务,给Ubuntu添加一个开机启动脚本,操作如下:

1、新建个脚本文件new_service.sh

#!/bin/bash
# command content

exit 0

2、设置权限

sudo chmod 755 new_service.sh
#或者
sudo chmod +x new_service.sh

3、把脚本放置到启动目录下

sudo mv new_service.sh /etc/init.d/

4、将脚本添加到开机启动脚本

执行如下指令,在这里90表明一个优先级,越高表示执行的越晚

cd /etc/init.d/
sudo update-rc.d new_service.sh defaults 90

5、移除开机启动脚本

sudo update-rc.d -f new_service.sh remove

6、通过sysv-rc-conf来管理上面启动服务的启动级别等,是否是开机启动

sudo sysv-rc-conf 

7、update-rc.d的详细参数

使用update-rc.d命令需要指定脚本名称和一些参数,它的格式看起来是这样的(需要在 root 权限下):

update-rc.d [-n] [-f] <basename> remove
update-rc.d [-n] <basename> defaults
update-rc.d [-n] <basename> disable|enable [S|2|3|4|5]
update-rc.d <basename> start|stop <NN> <runlevels>
  • -n: not really
  • -f: force

  • disable|enable:代表脚本还在/etc/init.d中,并设置当前状态是手动启动还是自动启动。

  • start|stop:代表脚本还在/etc/init.d中,开机,并设置当前状态是开始运行还是停止运行。(启用后可配置开始运行与否)

  • NN:是一个决定启动顺序的两位数字值。(例如90大于80,因此80对应的脚本先启动或先停止)

  • runlevels:则指定了运行级别。

实例:

(1)、添加一个新的启动脚本sample_init_script,并且指定为默认启动顺序、默认运行级别:

update-rc.d sample_init_script defaults
上一条命令等效于(中间是一个英文句点符号):
update-rc.d sample_init_script start 20 2 3 4 5 . stop 20 0 1 6

(2)、安装一个启动脚本sample_init_script,指定默认运行级别,但启动顺序为50:

update-rc.d sample_init_script defaults 50

(3)、安装两个启动脚本A、B,让A先于B启动,后于B停止:

update-rc.d A 10 40
update-rc.d B 20 30

(4)、删除一个启动脚本sample_init_script,如果脚本不存在则直接跳过:

update-rc.d -f sample_init_script remove

这一条命令实际上做的就是一一删除所有位于/etc/rcX.d目录下指向/etc/init.d中sample_init_script的链接(可能存在多个链接文件),update-rc.d只不过简化了这一步骤。

(5)禁止Apache/MySQL相关组件开机自启:

update-rc.d -f apache2 remove
update-rc.d -f mysql remove

8、服务的启动停止状态

sudo service xxx status
sudo service xxx start
sudo service xxx stop
sudo service xxx restart

9、查看全部服务列表

sudo service --status-all

三、启动应用程序首选项

可以通过在控制台运行 gnome-session-properties
就会打开下面的窗口,对应桌面上的启动应用程序

四、使用Systemd

Systemd 的使用有些复杂,未亲自尝试。有兴趣的小伙伴,可以来这里学习一下Systemd 入门教程:命令篇

参考:
Ubuntu下添加开机自动脚本

Ubuntu下添加开机启动项的2种方法

Ubuntu添加开机自动启动程序的方法

Ubuntu 16.04设置rc.local开机启动命令/脚本的方法

ubuntu如何用自启动软件,用root启动的那种(sudo)

ubuntu如何用自启动软件,用root启动的那种(sudo)

Ubuntu 设置 sudo 开机自启动项 无需输入密码

在ubuntu中如何管理startup application

XX-Net Ubuntu 16.04下开机自启动设置求助

 

apt-get update 失败 ubuntu:Tempory failure resolving 'cn.archive.ubuntu.com ubuntu

apt-get update 失败 ubuntu:Tempory failure resolving 'cn.archive.ubuntu.com ubuntu

当运行apt-get update后出现如下错误时:
E: Some index files Failed to download,they have been ignored,or old ones used instead.

可以将目录下/var/lib/apt/lists/partial/所有的文件清掉,再次运行apt-get update即可!自带源在大陆不好。


出现以下错误:

ubuntu:Tempory failure resolving ''cn.archive.ubuntu.com ubuntu


修改dns:

1,重启生效:

sudovi/etc/resolvconf/resolv.conf.d/base(这个文件默认是空的)

在里面插入:
nameserver8.8.8.8
nameserver8.8.4.4

如果有多个DNS就一行一个

修改好保存,然后执行

sudoresolvconf-u

再看/etc/resolv.conf,最下面就多了2行:

cat/etc/resolv.conf
#Dynamicresolv.conf(5)fileforglibcresolver(3)generatedbyresolvconf(8)
#DONOTEDITTHISFILEBYHAND--YOURCHANGESWILLBEOVERWRITTEN
可以看到我们的设置已经加上了,然后再ping一个域名,当时就可以解析了,无需重启。


2,重启失效:

配置文件地址 /etc/resolv.conf

使用编辑器打开

改为如下内容:
search localdomain
nameserver 202.96.128.86 希望修改成的DNS
nameserver 202.96.128.166 备用DNS

重启网络:sudo /etc/init.d/networking restart。即可

Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10 快速开启 BBR 加速 或 关闭 BBR 加速

Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10 快速开启 BBR 加速 或 关闭 BBR 加速

如果使用的是 Debian 9、Debian 10、Ubuntu 18.04、Ubuntu 18.10 等内核高于 4.9 版本的系统,均可以使用此方法开启 BBR 加速,若你使用了 Ubuntu 19.04 的系统无需开启,系统默认就开启了。虽然 BBR 没有锐速那么暴力,但是兼容性和稳定性占优势,推荐大家使用。对与什么是 BBR 我就不详细说明了,这是一款由谷歌推出的 TCP 单边加速的拥塞控制算法。

 

开启 BBR

1. 修改 sysctl.conf 系统参数

echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf

 

2. 保存并生效

sysctl -p

得到返回值如下:(最后两行有就可以了)

 

3. 查看是否已开启 BBR

sysctl net.ipv4.tcp_available_congestion_control

若得到返回值带有 bbr 则成功开启,如:

 

4. 检查 BBR 是否成功启动

lsmod | grep bbr

如返回信息则表示已经成功开启:

 

如果不确定自己的系统是支持快速开启 bbr 可以查看使用下面的命令查看内核,只要 4.9 及以上版本均可直接开启:

uname -r

 

关闭 BBR

若想要关闭 bbr 加速也很简单,只需要将第二步的返回内容在 sysctl.conf 内删除或注释掉即可。

 

1. 修改配置文件

vi /etc/sysctl.conf

进入配置文件,将添加的内容在最后,若找不到往下翻,按 i 键或 Insert 键开启编辑,注释或删除内容后,按 ESC 键退出编辑,键入

:wq

保存并退出。

 

2. 保存配置

sysctl -p

 

3. 重启系统生效

reboot

 

3. 查看是否已关闭 BBR

sysctl net.ipv4.tcp_available_congestion_control

 

 

install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd

install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd

Intel RealSense D435i Installation on Linux (Ubuntu 16.04 and Ubuntu 18.04)

Intel RealSense D435i Installation on Linux (Ubuntu 16.04 and Ubuntu 18.04)

1. Install 3rd-party dependencies

1.1 apt-get update

sudo apt-get update
  • 1

1.2 install libusb-1.0, libglfw, freeglut,

sudo apt-get install libusb-dev libusb-1.0-0-dev libglfw3 libglfw3-dev freeglut3 freeglut3-dev
  • 1

1.3 Install libpng12-dev

1.3.1 On Ubuntu 16.04, run the following command:

sudo apt-get install libpng12-dev

1.3.2 On Ubuntu 18.04, run the following command:

wget -q -O /tmp/libpng12.deb http://security.ubuntu.com/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1_amd64.deb

sudo dpkg -i /tmp/libpng12.deb

2. Debian Package Installation

2.1 Add Intel server to the list of repositories :

echo 'deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo xenial main' | sudo tee /etc/apt/sources.list.d/realsense-public.list
  • 1

It is recommended to backup /etc/apt/sources.list.d/realsense-public.list file in case of an upgrade.

2.2 Register the server’s public key :

sudo apt-key adv --keyserver keys.gnupg.net --recv-key 6F3EFCDE
sudo apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || sudo apt-key adv -- keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE
  • 1
  • 2

Refresh the list of repositories and packages available :

sudo apt-get update
  • 1

2.3 Install the librscalibrationtool package which includes Intel® RealSense™ Dynamic Calibrator:

sudo apt-get install librscalibrationtool
  • 1

说明:

librscalibrationtool适用设备为 Intel RealSense D400, D410, D415, D420, D430, D435.
安装后的使用说明见: /usr/share/doc/librscalibrationtool/README.md

2.4 Failure – (Optional) Developers shall also install librscalibrationapi package:

sudo apt-get install librscalibrationapi
  • 1

Problem:

librscalibrationapi : Depends: libpng12-dev but it is not installable
分析: 自Ubuntu18.04以后,libpng12-dev已经被弃用

3. Checking Package Installation

After the debian package install finishes, check for files installed. Under debian convention, the executables are installed under /usr/bin, library files under /usr/lib, and other files including sample code under /usr/share/doc.
For example, for Calibration Tool, librscalibrationtool, the files are installed as below:

sudo dpkg -L librscalibrationtool
  • 1

4. Video4Linux backend

  1. In order to run demos install:
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
  • 1
  • 2

The above two lines will deploy librealsense2 udev rules, kernel drivers, runtime library and executable demos and tools.
Reconnect the Intel RealSense depth camera and run: realsense-viewer

  1. Developers shall install additional packages:
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg
  • 1
  • 2

With dev package installed, you can compile an application with librealsense using g++ -std=c++11 filename.cpp -lrealsense2 or an IDE of your choice.

  1. Verify that the kernel is updated :
modinfo uvcvideo | grep "version:" 
  • 1

should include realsense string

5. Test Installation

  1. Print the tool version to screen:
/usr/bin/Intel.Realsense.DynamicCalibrator -v
  • 1
  1. To print device information to screen, connect a camera device to the system and execute the following command:
/usr/bin/Intel.Realsense.DynamicCalibrator -list
  • 1

6. Perform Calibration for Camera

/usr/bin/Intel.Realsense.DynamicCalibrator
  • 1

* Problem (not fixed):

I can see the RGB, Depth and Gyro information without problems when I run realsense-vieweror subscribe to the realsense-ros topics. But when I run/usr/bin/Intel.Realsense.DynamicCalibrator
And click on Start Calibration I get the Failed to start Calibration Error as seen:

PS: relative issue discussion on github:
https://github.com/IntelRealSense/librealsense/issues/3990

关于Ubuntu 设置系统环境变量和开机自启动ubuntu 设置系统环境变量和开机自启动的区别的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于apt-get update 失败 ubuntu:Tempory failure resolving 'cn.archive.ubuntu.com ubuntu、Debian 9 / Debian 10 / Ubuntu 18.04 / Ubuntu 18.10 快速开启 BBR 加速 或 关闭 BBR 加速、install nginx on ubuntu install ubuntu usb install ubuntu 14.04 ubuntu install jd、Intel RealSense D435i Installation on Linux (Ubuntu 16.04 and Ubuntu 18.04)的相关信息,请在本站寻找。

本文标签:

上一篇Ubuntu Codeblocks 配置 Eigen Sophus(ubuntu codeblocks不能编译)

下一篇Ubuntu 重置MySQL密码(ubuntu重置密码命令)