重点内容笔记

1、图形界面直接root 账号登录:

cd /etc/gdm/
[root@centos7 gdm]# grep -Ev '^#|^$' custom.conf     
[daemon]
AutomaticLoginEnable=ture
AutomaticLogin=root


2、查看管理员编号;uid为 0是超级用户

[root@centos7 ~]# id root -u 

0


3、查看终端命令tty 

blob.png


4、
[root@centos7 ~]# w
 19:55:27 up 54 min,  1 user,  load average: 0.00, 0.01, 0.05
USER     TTY      FROM             LOGIN@   IDLE   JCPU   PCPU WHAT
root     pts/0    192.168.30.1     19:25    7.00s  0.23s  0.04s w

5、init 3 进入字符界面; init 5 ,init 0,init 6;

runlevel 查看运行级别

chvt 代替快捷键


6、查看bash

echo $SHELL ; echo ${SHELL}

cat /etc/shells 

7、切换shell程序 /bin/csh

8、命令提示符:

echo $PS1

man bash

文档搜索PROMPTING 查看ps1配置

blob.png

blob.png

[root@centos7 network-scripts]#vim /etc/profile.d/env.sh
PS1="\[\e[1;32m\][\u@\h \W]\\$\[\e[0m\]"

[root@centos7 ~]#PS1="\[\e[1;31m\][\u@\h \W]\\[\e[0m\]"


9、内部/外部命令

查看内部命令:

enable .

enable :

enable [

enable alias

enable bg

enable bind

enable break

enable builtin

enable caller

enable cd

enable command

enable compgen

enable complete

enable compopt

enable continue

enable declare

enable dirs

enable disown

enable echo

enable enable

enable eval

enable exec

enable exit

enable export

enable false

enable fc

enable fg

enable getopts

enable hash

enable help

enable history

enable jobs

enable kill

enable let

enable local

enable logout

enable mapfile

enable popd

enable printf

enable pushd

enable pwd

enable read

enable readarray

enable readonly

enable return

enable set

enable shift

enable shopt

enable source

enable suspend

enable test

enable times

enable trap

enable true

enable type

enable typeset


enable ulimit

enable umask

enable unalias

enable unset

enable wait


确认内部命令:type

[root@centos7 ~]#type enable
enable is a shell builtin

路径变量

echo $PATH

[root@centos7 ~]#echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

清空缓存:hash -d ; hash -r 


[root@centos7 ~]#hash 
hits    command
   1    /usr/bin/w
[root@centos7 ~]#hash -d  w
[root@centos7 ~]#hash
hash: hash table empty


10、别名:alias

which who 

whereis who 

[root@centos7 ~]#which ls 
alias ls='ls --color=auto'
        /usr/bin/ls
修改家目录别名
[root@centos7 network-scripts]#grep -Ev "^#|^$" /root/.bashrc
alias cdnet='cd /etc/sysconfig/network-scripts/'
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
 . /root/.bashrc


使用原始命令:\ls

取消所有别名,相对当前终端;unalias 

查看路径

[root@centos7 ~]#which ls 
alias ls='ls --color=auto'
        /usr/bin/ls
[root@centos7 ~]#which --skip-alias ls 
/usr/bin/ls

blob.png

11 命令格式:

iptables -nvL (有前后关系

ctrl +c 强制退出

ctrl +d logout 正常退出

命令长格式换行

[root@centos7 ~]#host\
> name
centos7.magedu.com

12、date 

date -R  查看时区

centos7:
timedatectl list-timezones

timedatectl  status

tiemdatectl set-timezone  Asia/Shanghai

hwclock -s  硬件时间同步软件时间

hwclock -w  软件时间同步硬件时间

date +%s

date -d @1580137760

date "+%F %T"

date -d "-2 day" +%A

date -d "-1day" +%F


date -s "-1day" 

日历:

cal -y 

cal 8 2010 查看某年的日志表


13、关机重启;


shutdown 指定时间关机

[root@centos7 network-scripts]#shutdown 15:41
Shutdown scheduled for Tue 2020-01-28 15:41:00 CST, use 'shutdown -c' to cancel.


修改中文:


[root@centos7 network-scripts]#echo $LANG
en_US.UTF-8
vim /etc/sysconfig/i18n
LANG="zh_CN.UTF-8"
. /etc/sysconfig/i18n

广播:

wall "hello 你们好"

14、

blob.png


15、screen 

安装screen 

192.168.30.101

192.168.30.102 ;ssh 192.168.30.101

[root@centos7 Packages]#rpm -ivh ./screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm 
warning: ./screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
        installing package screen-4.1.0-0.25.20120314git3c2946.el7.x86_64 needs 4KB on the /run filesystem

1、共享会话

[root@centos7 Packages]#mkdir -pv /run/media/root/Centos\ 7\ x86_64  

[root@centos7 Packages]#mount /dev/sr0  /run/media/root/Centos\ 7\ x86_64  

cd

cd /run/media/root/Centos\ 7\ x86_64/Packages


[root@centos7 Packages]#rpm -ivh ./screen-4.1.0-0.25.20120314git3c2946.el7.x86_64.rpm

2、开启screen

blob.png

screen -S help 创建会话

screen -x help 加入会话

ctrl +a,d 剥离会话

screen -ls 查看会话

screen -r 恢复会话

exit 退出


3、拷贝文件需要30分钟,开启会话screen ;异常时,可以通过screen -r 恢复会话

    [root@centos7 ~]#screen -r



16、echo

echo -e "\a"


hexdump f1 查看二进制

blob.png

[root@centos7 ~]#bc

bc 1.06.95

Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

This is free software with ABSOLUTELY NO WARRANTY.

For details type `warranty'. 

ibase=16

61

97

quit

[root@centos7 ~]#bc

bc 1.06.95

Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc.

This is free software with ABSOLUTELY NO WARRANTY.

For details type `warranty'. 

obase=16

97

61


[root@centos7 ~]#echo -e "\033[1;31mmagedu\033[0m"

magedu

blob.png

修改登录提示界面motd:

[root@centos7 ~]#cat /etc/motd


拷贝信息文件:

cp `which --skip-alias ls ` /data 

``  变量命令

""  变量

''  字符串


echo {1..10}

echo {10..20..2}

echo {a..z}

echo f{1..3}


17 历史 命令:

history

[root@centos7 ~]#echo $HISTSIZE

1000

cat /etc/profile 配置文件修改HISTSIZE

[root@centos7 ~]#vim ~/.bash_history  记录了内存命令历史;


ctrl +r搜索

ecs . 调用最后一个参数

history 清空 历史:


[root@centos7 ~]#rm -f  ~/.bash_history 

histroy -c  清空历史


history -a 保存历史到文件中 ~/.bash_history 

man bash  查看历史帮助

history 历史变量


vim /etc/profile # /etc/profile.d/env.sh
HISTTIMEFORMAT="%F %T "
HISTSIZE=1000

[root@centos7 ~]#echo $HISTFILE
/root/.bash_history



18获取帮助:

whatis 显示命令的简短描述

whatis rm 

makewhatis   censots6  制作数据库

mandb centos7  制作数据库


内部命令

help command

man command


man 章节:


/usr/share/man

whereis ls 


[root@centos7 Packages]#whereis ls

ls: /usr/bin/ls /usr/share/man/man1/ls.1.gz /usr/share/man/man1p/ls.1p.gz

man 1 ls 


man 查看文件所在的章节


[root@centos7 Packages]#whereis passwd 

passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz /usr/share/man/man5/passwd.5.gz

[root@centos7 Packages]#whatis passwd 

passwd (1)           - update user's authentication tokens

sslpasswd (1ssl)     - compute password hashes

passwd (5)           - password file


man 搜索:

/keyword 向文件尾部

n:

N:

?KEYWORD  向文件首部

n:

N:



/usr/share/doc

[root@centos7 ~]#sosreport  搜集系统日志信息


19 cat /etc/issue

[root@centos7 ~]#cat /etc/issue
\S
Kernel \r on an \m
tty is \l
hostname is \n

[root@centos7 ~]#man  8 agetty

blob.png

       l      Insert the name of the current tty line.
       m      Insert the architecture identifier of the machine. Same as `uname -m'.
       n      Insert the nodename of the machine, also known as the hostname. Same as `uname -n'.
       o      Insert the NIS domainname of the machine. Same as `hostname -d'.
       O      Insert the DNS domainname of the machine.
       r      Insert the release number of the OS. Same as `uname -r'.
       t      Insert the current time.
       u      Insert the number of current users logged in.
       U      Insert  the  string "1 user" or "<n> users" where <n> is the number of current users
              logged in.


20 bash快捷键:

ctrl +l

ctrl +d/c

ctrl +a 

ctrl +e 

ctrl +u

ctrl +k



猜你喜欢

转载自blog.51cto.com/13718453/2468470