Shell Features Login / Nologin

vim /etc/passwd

login shell: su - wesley

nologin shell: su wesley

Added middle bar-switched to the past shell, called login shell, not added middle bar-switched to the past shell, called nologin shell, and there is no user environment for loading new users.

[root@localhost ~]# rpm -qc bash
/etc/skel/.bash_logout
/etc/skel/.bash_profile
/etc/skel/.bashrc
[root@localhost ~]# usradd wesley
-bash: usradd: command not found
[root@localhost ~]# useradd wesley
[root@localhost ~]# usermod -s /bin/bash wesley
usermod: no changes
[root@localhost ~]# su wesley
[wesley@localhost root]$ ls  # 当前目录还是homt/root,普通用户无权访问root目录
ls: cannot open directory .: Permission denied
[wesley@localhost root]$ exit
exit
[root@localhost ~]# su - wesley # 加-,会跟着用户名一起切换到普通用户的home目录
Last login: Thu Apr  9 18:23:08 EDT 2020 on pts/0
[wesley@localhost ~]$ pwd
/home/wesley
[wesley@localhost ~]$ exit
logout
[root@local

No user plane is added after su, switch to root by default

[root@localhost ~]# ll /etc/profile
-rw-r--r--. 1 root root 1983 Oct 27 08:25 /etc/profile
[root@localhost ~]# ll /etc/bashrc
-rw-r--r--. 1 root root 2853 Oct 30  2018 /etc/bashrc
[root@localhost ~]#
[root@localhost ~]# ll .bash_profile
-rw-r--r--. 1 root root 302 Nov  9 11:15 .bash_profile
[root@localhost ~]# ll .bashrc
-rw-r--r--. 1 root root 176 Dec 28  2013 .bashrc

Red / blue files are executed when entering the shell. Yellow file, executed when leaving the shell

The login (plus bar-) shell executes four files, and the non-login (without add bar) shell executes only 2 files.

As long as bash-completion is installed in bash, there will be an automatic completion function

[root@localhost ~]# rpm -qa |grep bash-com
bash-completion-2.1-6.el7.noarch
[root@localhost ~]# date
Thu Apr  9 18:58:53 EDT 2020
[root@localhost ~]# !!
date
Thu Apr  9 18:58:54 EDT 2020
[root@localhost ~]# !$
date
Thu Apr  9 18:58:58 EDT 2020
[root@localhost ~]# !10
ls
anaconda-ks.cfg  c  paramiko  test
[root@localhost ~]#
[root@localhost ~]# alias   查看别名
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@localhost ~]# unalias
unalias: usage: unalias [-a] name [name ...]
[root@localhost ~]# yum install -y sl
[root@localhost ~]# alias yang='sl'
[root@localhost ~]# yang    # 查看小火车程序

Published 385 original articles · won 130 · 110,000 views

Guess you like

Origin blog.csdn.net/f2157120/article/details/105425049