首页 文章 精选 留言 我的

精选列表

搜索[linux内核],共10000篇文章
优秀的个人博客,低调大师

Linux 环境下/etc/profile和/etc/profile.d 的区别和用法!

区别: 1. 两个文件都是设置环境变量文件的,/etc/profile是永久性的环境变量,是全局变量,/etc/profile.d/设置所有用户生效 2. /etc/profile.d/比/etc/profile好维护,不想要什么变量直接删除/etc/profile.d/下对应的shell脚本即可,不用像/etc/profile需要改动此文件 用法: CentOS 中每个用户都要指定各自的环境变量,其中包括可执行的 path路径,这些路径决定了每个用户在执行时的命令工具。 一般情况下,可以再每个用户的环境变量里设定各自的 path变量值,然后再执行export PATH使其生效,但如果用户比较多,安装命令工具也原来越多,且出来本身用户可以执行这些工具,root用户或其他用户也可以执行命令,这时在每个用户环境变量里添加就比较复杂了。 所以可以用另外一种方法: 可以再 /etc/profile.d/ 目录下创建一个 path.sh 脚本,脚本内容如下: 例子: 用代码格式表示内容如下: # cat /etc/profile.d/path.sh exportPATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/sbin:/usr/local/nginx/sbin:/usr/local/php/bin:/usr/local/php/sbin:/usr/local/mysql/bin:/usr/local/redis/bin:/usr/local/daemontools/bin:/usr/local/daemontools/sbin:/usr/local/percona-xtrabackup/bin" 可以将需要各个用户需要执行的命令路径都写在该命令中,这样每次操作系统其中后,会自动执行path.sh脚本,将所有的环境变量生效,让各个用户都可以直接执行各自的命令。 以后安装了新软件后,只需要将软件相关路径加入 /etc/profile.d/path.sh 脚本中,不需要再多个地方重复添加,使脚本生效后,各个用户都可以使用了。

优秀的个人博客,低调大师

Linux下Dialog+Shell三层目录专业规范跳板机脚本

#Dialog+Shell介绍 Dialog+Shell结合使用,方能体现出Dialog图形化的效果,在运维的时候,使用图形化界面,能给你一个更直观的感受,相信你会喜欢上他的 #创建脚本目录 [root@localhost~]#mkdir-p/scripts/tiaoban/{qqandroid,qqios,qqwxandroid,wxios,menu_list} #禁止普通用户登陆 [root@localhost~]#cat/etc/profile.d/tiaoban.sh [$UID-ne0]&&sh/scripts/tiaoban/tiaoban.sh #脚本目录结构 [root@localhosttiaoban]#tree/scripts/tiaoban/ /scripts/tiaoban/ ├──menu_list │├──one_menu │└──one_option ├──qqandroid │├──three_directory ││├──ip.txt ││├──three_1_100_tiaoban.sh ││├──three_menu ││└──three_option │├──tow_menu │├──tow_option │└──tow_tiaoban.sh ├──qqios ├──qqwxandroid ├──tiaoban.sh └──wxios 6directories,10files #添加权限 [root@localhosttiaoban]#chmod+x/scripts/tiaoban/menu_list/{one_menu,one_option} [root@localhosttiaoban]#chmod+x/scripts/tiaoban/qqandroid/{tow_menu,tow_option} [root@localhosttiaoban]#chmod+x/scripts/tiaoban/qqandroid/three_directory/{three_menu,three_option} #第一层目录脚本 [root@localhosttiaoban]#cattiaoban.sh #!/bin/bash while: do sttysusp^@#$#屏蔽Crtl+z sttyintr^@$##屏蔽Ctrl+c sttyquit^*#$#屏蔽Ctrl+l LJ=`dirname$0` dialog--title"Menu"--no-cancel--menu"Leveldirectory"12355`cat$LJ/menu_list/one_menu`2>$LJ/menu_list/one_option SELECT=`cat$LJ/menu_list/one_option` if["$SELECT"==1];then sh$LJ/qqandroid/tow_tiaoban.sh elif["$SELECT"==2];then sh$LJ/qqios/tow_tiaoban.sh elif["$SELECT"==3];then sh$LJ/wxandroid/tow_tiaoban.sh else sh$LJ/wxios/tow_tiaoban.sh fi done #第一层目录菜单 [root@localhosttiaoban]#cat/scripts/tiaoban/menu_list/one_menu 1qqandroid 2qqios(功能未开发) 3wxandroid(功能未开发) 4wxios(功能未开发) #第二层目录脚本 [root@localhosttiaoban]#cat/scripts/tiaoban/qqandroid/tow_tiaoban.sh #!/bin/bash while: do LJ=`dirname$0` dialog--title"Menu"--menu"Secondarydirectory"133515`cat$LJ/tow_menu`2>$LJ/tow_option SELECT=`cat$LJ/tow_option` if["$SELECT"==1];then sh$LJ/three_directory/three_1_100_tiaoban.sh elif["$SELECT"==2];then sh$LJ/three_directory/three_101_200_tiaoban.sh elif["$SELECT"-eq3];then sh$LJ/three_directory/three_201_300_tiaoban.sh else sh/scripts/tiaoban/tiaoban.sh fi done #第二层目录菜单 [root@localhosttiaoban]#cat/scripts/tiaoban/qqandroid/tow_menu 1qqandroid1-100服 2qqandroid101-200服(功能未开发) 3qqandroid201-300服(功能未开发) 4返回上一级 #第三层目录脚本 [root@localhosttiaoban]#cat/scripts/tiaoban/qqandroid/three_directory/three_1_100_tiaoban.sh #!/bin/bash while: do LJ=`dirname$0` dialog--title"Menu"--menu"Threedirectory"133515`cat$LJ/three_menu`2>$LJ/three_option SELECT=`cat$LJ/three_option` functionconnect(){ yh=`id` user=`echo$yh|awk-F""'{print$2}'|awk-F"gid="'{print$2}'|awk-F"("'{print$2}'|awk-F")"'{print$1}'` ip=`head-$SELECT$LJ/ip.txt|tail-1` ssh-p22$user@$ip } if["$SELECT"==5];then sh/scripts/tiaoban/qqandroid/tow_tiaoban.sh elif["$SELECT"==6];then sh/scripts/tiaoban/tiaoban.sh else connect fi done 第三层目录菜单 [root@localhosttiaoban]#cat/scripts/tiaoban/qqandroid/three_directory/three_menu 1qq1服 2qqandroid2服(功能未开发) 3qqandroid3服(功能未开发) 4qqandroid...服(功能未开发) 5返回上一级目录 6返回首页 #IP文件展示 [root@localhosttiaoban]#cat/scripts/tiaoban/qqandroid/three_directory/ip.txt 192.168.1.103 192.168.1.104 192.168.1.105 192.168.1.106 192.168.1.107 192.168.1.108 192.168.1.109 192.168.1.110 192.168.1.111 192.168.1.112 #执行效果展示 1)普通用户登陆 2)第一级菜单栏 3)第二级菜单栏 4)第三级菜单栏 5)成功登陆展示 提示:在用普通用户登陆跳板机连接后端服务器的时候,普通用户按Crtl+c和Ctrl+z是没有效果的,所以普通用户只能直接连接到后端的服务器而不能直接登陆到跳板机终端

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码