用户类型
root用户: 一个特殊的管理账户,也被成为超级用户,root已接近完整的系统控制,对系统损害几乎有无线能力,除非必要,不要登录为root
普通(非特权用户): 权限有限,造成损害的能力比较有限
终端terminal
终端类型
MBR、GPT磁盘分区表
主引导记录(Master Boot Rccord MBR) :可以安装启动引导程序的地方
分区表(partition):记录整块硬盘的分区状态
[root@192 ~]# w 10:38:53 up 18:48, 2 users, load average: 0.00, 0.11, 0.39 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root tty1 - Tue05 39:06 7.79s 7.79s -bash root pts/0 192.168.1.5 10:02 5.00s 0.01s 0.00s w [root@192 ~]# who root tty1 2022-03-22 05:26 root pts/0 2022-03-25 10:02 (192.168.1.5) [root@192 ~]# pwd /root [root@192 ~]# who am i root pts/0 2022-03-25 10:02 (192.168.1.5) [root@192 ~]#
linux 内核版本
[root@192 ~]# uname -a Linux 4.18.0-147.el8.x86_64 #主版本.次版本.发布版本-修改版本 [root@192 testing]# uname -r 4.18.0-147.el8.x86_64 [root@192 testing]# uname -m x86_64
时间
[root@lxfcentos8 ~]# date +$Y/%m/%d /03/25 [root@lxfcentos8 ~]# date +%Y/%m/%d 2022/03/25 [root@lxfcentos8 ~]# date +%H:%M 14:19 [root@lxfcentos8 ~]# date +%s 1648189242 [root@lxfcentos8 ~]# date --help #查看帮助
日历
[root@lxfcentos8 ~]# cal March 2022 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 [root@lxfcentos8 ~]# cal 2022 2022 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 4 5 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12 9 10 11 12 13 14 15 13 14 15 16 17 18 19 13 14 15 16 17 18 19 16 17 18 19 20 21 22 20 21 22 23 24 25 26 20 21 22 23 24 25 26 23 24 25 26 27 28 29 27 28 27 28 29 30 31 30 31 April May June Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 7 1 2 3 4 3 4 5 6 7 8 9 8 9 10 11 12 13 14 5 6 7 8 9 10 11 10 11 12 13 14 15 16 15 16 17 18 19 20 21 12 13 14 15 16 17 18 17 18 19 20 21 22 23 22 23 24 25 26 27 28 19 20 21 22 23 24 25 24 25 26 27 28 29 30 29 30 31 26 27 28 29 30 July August September Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 1 2 3 4 5 6 1 2 3 3 4 5 6 7 8 9 7 8 9 10 11 12 13 4 5 6 7 8 9 10 10 11 12 13 14 15 16 14 15 16 17 18 19 20 11 12 13 14 15 16 17 17 18 19 20 21 22 23 21 22 23 24 25 26 27 18 19 20 21 22 23 24 24 25 26 27 28 29 30 28 29 30 31 25 26 27 28 29 30 31 October November December Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 2 3 4 5 6 7 8 6 7 8 9 10 11 12 4 5 6 7 8 9 10 9 10 11 12 13 14 15 13 14 15 16 17 18 19 11 12 13 14 15 16 17 16 17 18 19 20 21 22 20 21 22 23 24 25 26 18 19 20 21 22 23 24 23 24 25 26 27 28 29 27 28 29 30 25 26 27 28 29 30 31 30 31 [root@lxfcentos8 ~]# cal 5 2011 May 2011 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
文件权限与目录配置
文件权限
[root@192 ~]# ls -al total 32 dr-xr-xr-x. 17 root root 224 Mar 22 05:10 .. 文件类型 权限 拥有者 所在组 文件大小 修改时间
chgrp:修改文件所属用户组
chown:修改文件拥有者
chmod:修改文件的权限,SUID、SGID、SBIT等的特性
[root@192 ~]# ls -lcd / -rw-r--r--. 1 root root 0 Mar 25 23:44 test [root@192 ~]# chgrp centos8_user test [root@192 ~]# ls -l -rw-r--r--. 1 root centos8_user 0 Mar 25 23:44 test [root@192 ~]# chgrp root test [root@192 ~]# ls -l -rw-r--r--. 1 root root 0 Mar 25 23:44 test [root@192 ~]# chown centos8_user test [root@192 ~]# ls -l -rw-r--r--. 1 centos8_user root 0 Mar 25 23:44 test [root@192 ~]# chown root test [root@192 ~]# chmod 666 test [root@192 ~]# ls -l -rw-rw-rw-. 1 root root 0 Mar 25 23:44 test
chmod u\g\o\a|+\-\=|r\w\x file_name
[root@192 ~]# chmod a+x test [root@192 ~]# ls -l test -rwxrwxrwx. 1 root root 0 Mar 25 23:44 test
文件与目录管理
ll --time=atime /root/anaconda-ks.cfg ;输出access时间
ll --time=ctime /root/anaconda-ks.cfg ;输出权限属性变更时间
ll /root/anaconda-ks.cfg ; 输出文件内容变更的时间
命令 | 功能 | 参数 |
---|---|---|
cd | 切换目录 | |
pwd | 显示当前目录 | -P 显示实际目录 |
mkdir | 创建目录 | |
rmdir | 删除目录 | -p 连同上层的空目录一起删除 |
ls | 查看目录 | -a 全部文件 -d 仅显示目录 -l 详细信息 -R显示子目录 |
cp | 复制文件 | -i 若目标文件存在询问 -p 连同文件的属性一并复制 -r递归复制 |
rm | 删除文件 | -f 强制 -r递归删除 |
mv | 移动文件 | |
dirname | [root@192 tmp]# basename /tmp/testing/ testing | |
basename | [root@192 tmp]# dirname /tmp/testing/ /tmp |
符号 | 说明 |
---|---|
. | 当前目录 |
.. | 上一级目录 |
- | 前一个工作目录 |
~[账号] | 当前使用者的home目录或指定用户的家目录 |
查看文件
命令 | 功能 | 说明 |
---|---|---|
cat | 从头看 | -n 打印行号 -A显示特殊字符 |
tac | 从尾看 | |
nl | 显示行号 | |
less | 翻页看 | Enter下一行 空格键下一页 n|N 向前向后查找取决于{/|?} |
tail | 只看最后几行 | tail -n 10 anaconda-ks.cfg 查看最后10行 |
od | 以二进制方式读取文件 | |
head | 查看前几行 | head -n 10 anaconda-ks.cfg 查看前10行 |
[root@192 ~]# cat -n anaconda-ks.cfg | head -n 20 | tail -n 10 11 keyboard --vckeymap=us --xlayouts='us' 12 # System language 13 lang en_US.UTF-8 14 15 # Network information 16 network --bootproto=dhcp --device=ens33 --onboot=off --ipv6=auto --no-activate 17 network --hostname=localhost.localdomain 18 repo --name="AppStream" --baseurl=file:///run/install/repo/AppStream 19 # Root password 20 rootpw --iscrypted $6$pu3H2LauUZyuWUto$0xWrLZgEbT2zegn0zGINhmqdJfyawY.Ta0D8TpxRh5LCMeXJVlNEnei2eJWw4KZnDMfx3z9/ItDcOMP9QL9Em/
创建文件
touch [option] file_name
-a 仅自定义access time
[root@192 ~]# touch test1 [root@192 ~]# ls -l total 8 -rw-------. 1 root root 1377 Mar 22 05:13 anaconda-ks.cfg -rw-r--r--. 1 root root 266 Mar 26 01:17 test -rw-r--r--. 1 root root 0 Mar 26 02:22 test1
文件默认的权限
umask
[root@192 ~]# umask 0022
文件隐藏属性
[root@192 ~]# chattr +i test #i 不可删除 [root@192 ~]# lsattr test ----i-------------- test [root@192 ~]# chattr Usage: chattr [-pRVf] [-+=aAcCdDeijPsStTu] [-v version] files...
The letters 'aAcCdDeijPsStTu' select the new attributes for the files:
append only (a), no atime updates (A), compressed (c), no copy on write (C), no dump (d), synchronous directory updates (D), extent format (e), immutable (i), data journalling (j), project hierarchy (P), secure deletion (s), synchronous updates (S), no tail-merging (t), top of directory hierarchy (T), and undeletable (u).
SUID、SGID、SBIT
[root@192 /]# ls -ld /tmp/;ls -ld /usr/bin/passwd drwxrwxrwt. 13 root root 4096 Mar 26 02:42 /tmp/ -rwsr-xr-x. 1 root root 34928 May 11 2019 /usr/bin/passwd
file 判断文件类型
[root@192 ~]# file test test: ASCII text [root@192 ~]# file /etc/passwd /etc/passwd: ASCII text [root@192 ~]# file /usr/bin/passwd /usr/bin/passwd: setuid ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=4ba7de752293f0c8e4a3547285ea1952492eb9e4, stripped
命令与文件的查找
#which [-a] command [root@192 bin]# which ls alias ls='ls --color=auto' /usr/bin/ls
[root@192 bin]# whereis passwd passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man1/passwd.1.gz
[root@192 ~]# find / -name "*testin*" /etc/pki/rpm-gpg/RPM-GPG-KEY-centostesting /usr/lib64/rsyslog/omtesting.so /usr/share/doc/xkeyboard-config/HOWTO.testing /tmp/testing /tmp/testing/testing [root@192 ~]#