Linux误删etc下的profile,Linux centos 7 的/etc/profile 被我改坏了 忘记原来是什么样的了,怎么恢复?...

用户在Linux CentOS 7系统中误删或修改了/etc/profile文件,导致系统环境出现问题。文章内容包括系统版本信息,以及/etc/profile的部分内容。作者尝试通过删除自增的环境变量来恢复,但遇到错误。寻求帮助以恢复默认的/etc/profile设置。
摘要由CSDN通过智能技术生成

系统版本:Linux linuxCentOS7 3.10.0-862.6.3.el7.x86_64 #1 SMP Tue Jun 26 16:32:21 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

这是第一次改这个文件,所以谁有默认的能发给我一份吗?

下面是我当前/etc/profile的内容,我只是在最后加个环境变量(后来为了恢复删了)

# /etc/profile

# System wide environment and startup programs, for login setup

# Functions and aliases go in /etc/bashrc

# It's NOT a good idea to change this file unless you know what you

# are doing. It's much better to create a custom.sh shell script in

# /etc/profile.d/ to make custom changes to your environment, as this

# will prevent the need for merging in future updates.

pathmunge () {

case ":${PATH}:" in

*:"$1":*)

;;

*)

if [ "$2" = "after" ] ; then

PATH=$PATH:$1

else

PATH=$1:$PATH

fi

esac

以下是 CentOS 7 中 `/etc/profile` 文件的默认代码: ```bash # /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi fi } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`id -u` UID=`id -ru` fi USER="`id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /sbin pathmunge /usr/sbin pathmunge /usr/local/sbin fi pathmunge /usr/local/bin pathmunge /usr/bin pathmunge /usr/local/go/bin pathmunge /usr/local/nodejs/bin pathmunge /usr/local/mysql/bin pathmunge /usr/local/php/bin pathmunge /usr/local/python3/bin pathmunge /usr/local/nginx/sbin pathmunge /root/bin after HOSTNAME=$(hostname) export HOSTNAME # Set the initial umask. Only users can change this setting. if [ $UID -gt 99 ] && [ "`id -gn`" = "`id -un`" ]; then umask 002 else umask 022 fi # Are we an interactive shell? if [ "$PS1" ]; then if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then # The file bash.bashrc already sets the default PS1. # PS1='\h:\w\$ ' if [ -f /etc/bashrc ]; then . /etc/bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi # Try to keep environment pollution down, EPA loves us. unset ENV RCFILE REPLY_HISTORY_FILE INPUTRC GLOBIGNORE unset -f pathmunge ``` 注意,这是默认代码,如果您对其进行了修改,可能会与此不同。建议在修改之前备份此文件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值