Ubuntu下锐捷linux客户端开机自启动的方法

时间:2023-01-17 15:38:52

    在本篇文章写作之前,首先要确定您已经正确安装了锐捷的linux客户端。我使用的是华中科技大学校园网官方网站提供的锐捷安装包。版本号为V1.01。下载链接如下:http://nc.hust.edu.cn/download/soft/Linux%20SU%20V1.01%E7%89%88.rar

    将锐捷安装包解压并且放在你的home文件夹下,如我的就是:/home/shawn/rjsupplicant。

    完成之后,可以自己写一个脚本,把需要的参数都写好,用于专门调用/home/shawn/rjsupplicant/rjsupplicant.sh这个脚本。

    如我就写了一个/home/shawn/ruijie.sh的脚本如下:

#!/bin/bash 
sudo /home/shawn/rjsupplicant/rjsupplicant.sh --dhcp 0 --nic eth0 --service internet --user username(这里换成你自己的用户名) --password password(这里换成你自己的密码) --save 1

    然后就是重头戏,相信尝试过的朋友都知道最难的地方在于如何给这个需要sudo的rjsupplicant.sh的脚本赋予root权限。

    尝试了好多遍都没能顺利的将权限赋给rjsupplicant.sh。所以最后想了另一个办法,只要在使用rjsupllicant.sh的时候输入sudo不要密码也就可以啦~

    于是就到网上搜索sudo不用输入的方法。找到一方法如下:

    http://love-love-l.blog.163.com/blog/static/21078304201071232234518/

     按照上面说的方法,我就编辑了/etc/sudoers这个文件。我在文件最后加了一句话:

shawnALL = NOPASSWD: /home/shawn/rjsupplicant/rjsupplicant.sh

    我整个文件的代码也贴给大家,供大家参考一下:
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaultsenv_reset
Defaultssecure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
rootALL=(ALL:ALL) ALL

# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudoALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

#When I run the rjsupplicant, I do not want to enter the password
shawnALL = NOPASSWD: /home/shawn/rjsupplicant/rjsupplicant.sh
    这个,你再运行/home/shawn/ruijie.sh脚本(前提是你要先把它设置为可执行的shell脚本)的时候就会发现不用再输入密码啦~

    然后,就只需要将/home/shawn/ruijie.sh这个脚本加入到系统启动项中就可以了。可以直接用ubuntu的图像化工具就可以了。即找到一个Startup Application...就可以了。