ubuntu的普通用戶相關配置

1.切換到普通用戶下,不出現,用戶名@主機ip, 環境變量被破壞,

參考:一文教你快速修改ubuntu終端顯示的主機名和用戶名_ubuntu終端名稱-CSDN博客

2.如果登陸進去無法使用ls,cd,vi等命令

2.1 環境變量

如果?PATH?被清空,用戶無法執行任何命令。
臨時恢復?PATH(如果當前 Shell 允許):

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

然后檢查是否能運行?lsvi?等命令。

永久:此用戶下 vi ~/.bashrc? ? ?(不用sudo)

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples# If not running interactively, don't do anything
case $- in*i*) ;;*) return;;
esac# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth# append to the history file, don't overwrite it
shopt -s histappend# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; thendebian_chroot=$(cat /etc/debian_chroot)
fi# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" inxterm-color|*-256color) color_prompt=yes;;
esac# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yesif [ -n "$force_color_prompt" ]; thenif [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then# We have color support; assume it's compliant with Ecma-48# (ISO/IEC-6429). (Lack of such support is extremely rare, and such# a case would tend to support setf rather than setaf.)color_prompt=yeselsecolor_prompt=fi
fiif [ "$color_prompt" = yes ]; thenPS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
elsePS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1";;
*);;
esac# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; thentest -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"alias ls='ls --color=auto'#alias dir='dir --color=auto'#alias vdir='vdir --color=auto'alias grep='grep --color=auto'alias fgrep='fgrep --color=auto'alias egrep='egrep --color=auto'
fi# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.if [ -f ~/.bash_aliases ]; then. ~/.bash_aliases
fi# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; thenif [ -f /usr/share/bash-completion/bash_completion ]; then. /usr/share/bash-completion/bash_completionelif [ -f /etc/bash_completion ]; then. /etc/bash_completionfi
fi
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
export PATH=/opt/mips-gcc540-glibc222-64bit-r3.3.0/bin:$PATH

再source ~/.bashrc(不用sudo)

2.2或者權限問題:權限問題用root進去修改如下:

root@ubuntu:~# sudo usermod -s /bin/bash lhj
root@ubuntu:~# sudo chmod 755 /home/lhj
root@ubuntu:~# sudo chown -R lhj:lhj /home/lhj

cd ~回到家目錄

3.su - lhj?切換后無法正確加載環境變量

? 可能原因:

1.?~/.bashrc?或?~/.profile?未被正確加載

su - lhj?應該會加載?~/.profile?或?~/.bash_profile,但可能:

# 查看 ~/.profile 是否存在
ls -l ~/.profile# 查看 ~/.bashrc 是否存在
ls -l ~/.bashrc# 如果文件不存在,從 /etc/skel 復制默認配置
cp /etc/skel/.bashrc ~/
cp /etc/skel/.profile ~/

確保?PATH?正確設置?

export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH"

source ~/.profile

2.?/etc/environment?或?/etc/profile?覆蓋了?PATH

cat /etc/environment

sudo nano /etc/environment

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

檢查?/etc/profile,如果發現?export PATH=?被錯誤修改,可以恢復默認。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/902788.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/902788.shtml
英文地址,請注明出處:http://en.pswp.cn/news/902788.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

騰訊云×數語科技:Datablau DDM (AI智能版)上架云應用!

在數據爆炸式增長的時代,傳統的數據建模方式已難以滿足企業對敏捷性、智能化、自動化的需求。數語科技聯合騰訊云推出的 Datablau DDM 數據建模平臺(AI智能版),基于AI語義建模技術,深度融合騰訊混元大模型能力&#xf…

Spark-streaming(一)

Spark-Streaming概述 Spark Streaming 用于流式數據的處理。 和 Spark 基于 RDD 的概念很相似,Spark Streaming 使用離散化流(discretized stream)作為抽象表示,叫作 DStream。 DStream 是隨時間推移而收到的數據的序列。 Spark-Streaming的特點&…

CS144 Lab 6 實戰記錄:構建 IP 路由器

1 實驗背景與目標 在 CS144 的 Lab 6 中,我們需要在之前實現的 NetworkInterface(Lab 5)基礎上構建一個完整的 IP 路由器。路由器的主要任務是根據路由表將接收到的 IP 數據報轉發到正確的網絡接口,并發送給正確的下一跳&#xf…

【網絡安全】社會工程學策略

1. 社會工程學簡介 社會工程攻擊是威脅行為者常用的攻擊方式。這是因為,誘騙人們提供訪問權限、信息或金錢通常比利用軟件或網絡漏洞更容易。 您可能還記得,社會工程學是一種利用人為錯誤來獲取私人信息、訪問權限或貴重物品的操縱技術。它是一個涵蓋性…

【含文檔+PPT+源碼】基于SpringBoot的開放實驗管理平臺設計與實現

項目介紹 本課程演示的是一款基于SpringBoot的開放實驗管理平臺設計與實現,主要針對計算機相關專業的正在做畢設的學生與需要項目實戰練習的 Java 學習者。 1.包含:項目源碼、項目文檔、數據庫腳本、軟件工具等所有資料 2.帶你從零開始部署運行本套系統…

鴻蒙NEXT開發定位工具類 (WGS-84坐標系)(ArkTs)

import geoLocationManager from ohos.geoLocationManager; import { BusinessError, Callback } from ohos.base; import { LogUtil } from ./LogUtil; import { PermissionUtil } from ./PermissionUtil; import { map, mapCommon } from kit.MapKit; /*** 定位工具類 (WGS-8…

SSM從入門到上手-全面講解SSM框架的使用.

一、SSM框架整合 將Spring、Spring MVC和MyBatis結合在一起,形成一個高效且易于維護的Web應用程序架構。具體整合的方式如下: Spring管理Bean:Spring負責管理所有的Java對象,包括Service層、DAO層等。通過Spring的IoC容器進行依賴…

學員答題pk知識競賽小程序怎么做

制作學員答題PK知識競賽小程序,主要有以下步驟: 一、規劃設計 明確需求:確定小程序的使用場景是校園知識競賽、培訓機構考核還是企業內部培訓等。答題功能,規定答題的具體規則,包括題目類型(單選、多選、…

視頻分析設備平臺EasyCVR視頻技術驅動下,監控上墻全組件解析與組網應用方案

隨著數字化進程的加速推進,視頻監控技術在工業、商業、社區等諸多領域得到了廣泛應用。盡管不同場景對監控功能的具體需求存在差異,但底層硬件架構具有顯著的共性特征。實際部署中,僅需依據網絡環境等實際情況,靈活調整設備的連接…

idea使用docker插件一鍵部署項目

一、首先保證我們電腦上已經安裝了docker docker -v查看docker版本,如果不能識別,需要先下載docker destop,在官網下載正常安裝即可。 安裝成功就可以使用docker 命令了 二、idea下載docker插件并配置docker參數 我是通過tcp連接docker服務…

SQL Tuning Advisor

什么是SQL Tuning Advisor STA可以用來優化那些已經被發現的高負載SQL. 默認情況下, Oracle數據庫在自動維護窗口中自動認證那些有問題的SQL并且執行優化建議,找尋提升高負載SQL執行計劃性能的方法. ** 如何查看自動優化維護窗口產生的報告? ** SQL> set ser…

uniapp-商城-31-shop頁面中的 我的訂單

前面的章節講了很多關于頁面 布局 的知識。 現在來看看其他欄目,我的訂單頁面。 1 頁面樣式圖 基本的樣式包含shop頁面 我的訂單 點擊我的訂單,跳轉到訂單頁面 點擊訂單的每一條訂單,跳轉到訂單詳情 2、創建訂單頁面 2.1 創建sub頁面文件…

深入探討JavaScript性能瓶頸與優化實戰指南

JavaScript作為現代Web開發的核心語言,其性能直接影響用戶體驗與業務指標。隨著2025年前端應用的復雜性持續增加,性能優化已成為開發者必須掌握的核心技能。本文將從性能瓶頸分析、優化策略、工具使用三個維度,結合實戰案例,系統梳理JavaScript性能優化的關鍵路徑。 一、Ja…

基于AI與drawio的圖表生成技術及其在學術研究中的應用前景分析

一、研究背景與沖突 在當今數字化時代,學術研究與信息傳播的方式發生了深刻變革。隨著數據量的爆炸式增長以及研究內容的日益復雜,高效、精準地呈現研究成果變得至關重要。圖表作為一種直觀、簡潔且信息承載量大的表達方式,在學術研究中扮演著…

uniapp 仿小紅書輪播圖效果

通過對小紅書的輪播圖分析&#xff0c;可得出以下總結&#xff1a; 1.單張圖片時容器根據圖片像素定高 2.多圖時輪播圖容器高度以首圖為錨點 3.比首圖長則固高左右留白 4.比首圖短則固寬上下留白 代碼如下&#xff1a; <template><view> <!--輪播--><s…

【ORACLE】記錄一些ORACLE的merge into語句的BUG

【ORACLE】記錄一些ORACLE的merge into語句的BUG 一、自相矛盾-DML重啟動行為差異,違反acid原則 發現版本&#xff1a;10g ~ 23ai 這個用例在我之前的文章里有提過&#xff0c;ORACLE和PG系關于并發事務行為有一個非常大的差異&#xff0c;就是ORACLE在某些并發沖突的場景下會…

2025上海車展:光峰科技全球首發“靈境”智能車載光學系統

當AI為光賦予思想&#xff0c;汽車將會變成什么樣&#xff1f;深圳光峰科技為您揭曉答案。 2025年4月23日&#xff0c;在剛剛開幕的“2025上海車展”上&#xff0c;全球領先的激光核心器件公司光峰科技舉辦了主題為“AI光影盛宴&#xff0c;智享未來出行”的媒體發布會&#x…

密碼學的hash函數,哈希碰撞, collision resistance, BTC用到的SHA-256簡介

密碼學中的哈希函數、哈希碰撞、抗碰撞性&#xff08;collision resistance&#xff09;以及比特幣中使用的 SHA-256 的簡明介紹&#xff1a; &#x1f9e9; 一、哈希函數&#xff08;Hash Function&#xff09; 定義&#xff1a; 哈希函數是一種將任意長度的輸入&#xff08;…

unity TEngine學習4

上一篇我們學習了UI部分&#xff0c;這一篇我們學習其他部分&#xff0c;按照老規矩還是先打開官方文檔 ResourceModule 在官方文檔里介紹了當前加載的設置&#xff0c;但是我們是小白看不懂&#xff0c;那就不管他內部怎么實現的&#xff0c;我們主要看下面的代碼給的方法&am…

【AI訓練環境搭建】在IDE(Pycharm或VSCode)上使用WSL2+Ubuntu22.04+Conda+Tensorflow+GPU進行機器學習訓練

本次實踐將在IDE&#xff08;Pycharm或VSCode&#xff09;上使用WSL2Ubuntu22.04TensorflowGPU進行機器學習訓練。基本原理是在IDE中拉起WSL2中的Python解釋器&#xff0c;并運行Python程序。要運行CondaTensorflowGPU你可能需要進行以下準備工作。 1. 此示例中將使用一個mnis…