安装ubuntu 一定记得安装openssh 服务  
tom@tom:~$ lsb_release -a  查看系统版本
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:    20.04
Codename:   focal
...............................................................
tom@tom:~$ uname -r  查看内核版本 
5.4.0-42-generic
tom@tom:~$ uname -a  查看比较全
Linux tom 5.4.0-42-generic #46-Ubuntu SMP Fri Jul 10 00:24:02 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
...............................................................
工作中,尽量不要root 登录  注意ubuntu 的系统默认不允许使用root 登录。
学习使用root
...............................................................
/root  是root 的家目录,其他用户的家目录在/home 下
terminal  终端
管理员登录是 #  普通用户是$  登录时显示login 进入KDE,类似于windows 界面 开始按钮
...............................................................
[root@192 ~]# cat /etc/redhat-release   查看操作系版本
CentOS Linux release 7.6.1810 (Core) 
[root@192 ~]# cat /etc/os-release       查看操作系版本
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
crtl alt + f1----f7 打开终端
who 
whoami
tty
init 3 关闭图行界面 (windows 必须要有图形化界面) 
init 5 图形界面 
init 0 关机
init 6 重启
runlevel 运行级别查看
[root@centos6 ~]# runlevel 
5 3  之前是5  现在是3
[root@centos6 ~]# who -r
run-level 5  2020-07-25 19:11                   last=3
root 用户  [root@centos6 ~]# id -u root
0  为0 才是管理员
普通用户  权限很小
[root@pxe mnt]# id tom
uid=1000(tom) gid=1000(tom) 组=1000(tom)  6版本默认从500 开始编号
判断账户是否是管理员,依靠的是uid 是否等于0
/dev/console
tty  /dev/tty#
crtl+alt+ F#
/dev/tty7  startx,xwindows
centos6 crtl+alt+ F7
centos7 在哪个终端启动,即位于哪个虚拟终端
[root@192 ~]# tty  伪终端   pty ssh终端
/dev/pts/0  
GUI:X protcol,window manager ,desktop
desktop
GNOME (C,图形库gtk)
KDE   (C++,图形库qt)
XFCE  (轻量级桌面)
CLI: 命令行模式  效率高 
shell 程序
shell 解释器 到内核
sh 
csh
ksh
bash 常用 默认
tom@tom:~$ echo $SHELL  默认的
/bin/bash
tom@tom:~$ cat /etc/shells 
#/etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/usr/bin/tmux
/usr/bin/screen
[root@centos6 ~]# cat /etc/shells
/bin/sh
/bin/bash
/sbin/nologin   禁止用户登录
/bin/dash
/bin/tcsh
/bin/csh
主机名:guizhou-st-k8s-node1-100-10.zhanghau.com 示例
命令提示符:prompt
管理员登录是 # 
普通用户是$
[root@centos6 ~]# echo $PS1
[\u@\h \W]\$
tom@tom:~$ echo $PS1
[\e]0;\u@\h: \w\a]${debian_chroot:+($debian_chroot)}\u@\h:\w\$
31--37字体颜色  
41--47背景颜色
PS1="[\e[1;5;41;33m][\u@\h \W]\$[\e[0m]"
PS1="[\e[1;32m][[\e[0m]\t [\e[1;33m]\u[\e[36m]@\h[\e[1;31m] \W[\e[1;32m]][\e[0m]\$" centos7
\e  控制符\033   0m 颜色结束            \u 当前用户
\h  主机名简称              \H 主机名
\w 当前工作目录             \W 当前工作目录基名
\t  24小时时间格式          \T  12小时时间格式
!  命令历史数              # 开机后命令历史数
PS1="[\e[35m][\u@\h \W]\$[\e[0m]"  ubuntu 
PS1="[\e[1;33m][\u@\h \W]\$[\e[0m]" centos6 
要保存住 ,需要修改文件,写到磁盘文件上
/etc/profile.d/ 在这个目录下,并以sh 后缀结尾
[root@centos6 ~]#cd /etc/profile.d/
[root@centos6 profile.d]#ls
colorls.csh  cvs.csh  glib2.csh  gnome-ssh-askpass.csh  lang.csh  less.csh  qt.csh  udisks-bash-completion.sh  vim.sh
colorls.sh   cvs.sh   glib2.sh   gnome-ssh-askpass.sh   lang.sh   less.sh   qt.sh   vim.csh                    which2.sh
[root@centos6 profile.d]#vim env.sh
[root@centos6 profile.d]#cat env.sh 
PS1="[\e[1;34m][\u@\h \W]\$[\e[0m]"
注意unbuntu 需要切换身份
sudo -i  输入普通用户密码
root@unbuntu1804:~# pwd
/root
[tom@unbuntu1804 ~]$pwd
/home/tom
root@unbuntu1804:~# vim .profile   两个目录都要添加,切换账户时,才不会影响 这个文件每个家目录有
追加  
PS1="[\e[1;35m][\u@\h \W]\$[\e[0m]"
root@unbuntu1804:~# source .profile 
[tom@unbuntu1804 ~]$cat /etc/profile 需要小心配置,影响范围大,所以才去家目录改
pstree 
sleep 1 
[14:48:26 root@centos7 ~]#type cat  显示磁盘路径即为外部命令
cat 已被哈希 (/usr/bin/cat)
[14:48:42 root@centos7 ~]#type cd
cd 是 shell 内嵌 (builtin)
内嵌 (builtin) 即使内部命令又是外部命令,优先执行内部命令
[14:52:40 root@centos7 ~]#type -a echo
echo 是 shell 内嵌
echo 是 /usr/bin/echo  备用的效果,预防其他shell 没有该命令
[14:53:21 root@centos7 ~]#cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
/bin/tcsh
/bin/csh
[15:20:26 root@centos7 ~]#ls /bin/ 外部命令 为磁盘文件
[15:20:27 root@centos7 ~]#enable  内部命令
[15:23:15 root@centos7 ~]#help  
echo [-neE] [参数 ...]  查看到  号,就被禁用了
[15:24:43 root@centos7 ~]#enable echo  启用命令 临时生效,重新打开终端就可以了
[15:25:16 root@centos7 ~]#enable -n echo  禁用命令 临时生效
enable -n 查看禁用的命令情况
bc
obase=2  转换成十进制
97
1100001
quit
bc
ibase=2   准换成二进制
100010
34
quit
[15:33:27 root@centos7 ~]#whereis cat
cat: /usr/bin/cat /usr/share/man/man1/cat.1.gz /usr/share/man/man1p/cat.1p.gz
which -a | --skip-alias
[15:34:53 root@centos7 ~]#which echo
/usr/bin/echo
[15:35:03 root@centos7 ~]#which is echo
/usr/bin/which: no is in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
/usr/bin/echo
[15:36:03 root@centos7 ~]#echo $PATH  环境变量,执行命令先内部查找,再依次循环找,找到就不往后找了
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
原文:https://blog.51cto.com/8683332/2513374