第三天
1.修改主机名:
查看主机名
2.查看日期
使用指定格式输出日期 YY-mm-DD HH:MM:SS
3.将"We are learning RHCSA"输出在屏幕上
4.使用timedatectl查看时间状态
列出所有已知时区
修改时区为列出时区的某一个
5.使用wget命令在https://www.pearvideo.com/这个网站下载任意一个视频
6.查看ip的命令(多种)
1.修改主机名称 查看主机名称
[root@rhcsa ~]# hostname lll
[root@rhcsa ~]# hostname
lll
2.查看日期
[root@rhcsa ~]# date
2021年 11月 25日 星期四 18:02:10 CST
使用指定格式输出
[root@rhcsa ~]# date "+%y-%m-%d %H:%M:%S"
21-11-25 18:12:35
3.将"We are learning RHCSA"输出在屏幕上
[root@rhcsa ~]# echo "We are learning RHCSA"
We are learning RHCSA
4.查看时间状态
[root@rhcsa ~]# timedatectl status Local time: 四 2021-11-25 18:15:24 CSTUniversal time: 四 2021-11-25 10:15:24 UTCRTC time: 四 2021-11-25 10:15:23Time zone: Asia/Shanghai (CST, +0800)
System clock synchronized: yesNTP service: activeRTC in local TZ: no
列出所有已知时区
[root@rhcsa ~]# timedatectl list-timezones
修改为列表中的某一个
[root@rhcsa ~]# timedatectl set-timezone Asia/Shanghai
5.下载视频
6.查看IP命令
ifconfig
ip a
...
第五天
20211110作业
1.Linux中的文件类型以及符号的表示
2.创建目录test
3.使用两种方式在test目录中创建文本文件text1.txt, text2.txt
使用Vim在文件text1.txt中写入
Welcome to my Linux.
You are the best.
This is my first file to create on linux
4.将test中的文件拷贝到test2目录
5.将test2目录中的test1.txt重命名为test111.txt
6.在test2目录中新建test111.txt的软链接文件 test111_soft.txt
7.在test2目录中新建test111.txt的软链接文件 test111_hard.txt
8.删除test目录中test1.txt
9.删除test目录
1.
Linux的文件类型大致可分为:
普通文件:用于存放数据、程序等信息的文件。---“-”
目录文件:是由文件系统中一个目录所包含的目录项组成的文件。---“d”
链接文件:又称符号链接文件, 用于不同目录下文件的共享。实际上它指向另一个文件。 设备文件:用于与I/O设备提供连接的一种文件,分为 块设备文件:表示磁盘、光盘等 字符设备文件:联系着按照字符进行操作的终端、键盘等设备。---“l”
管道文件:主要用于在进程间传递数据。---“p”
套接字文件 :套接字(socket)文件通常用于网络数据连接。
2.
[root@rhcsa ~]# mkdir test //创建test目录
3.
第一种方式
[root@rhcsa test]# touch text1.txt
第二种方式
[root@rhcsa test]# vim text2.txt(里面要写东西才能保存)
[root@rhcsa test]# vim text1.txt //在text1.txt中写入
4.
[root@rhcsa ~]# cp -a test test2 //复制目录要加参数-a
5.
[root@rhcsa test2]# mv text1.txt text111.txt //将text1.txt重命名为text111.txt
6.
[root@rhcsa test2]# ln -s text111.txt text111_soft.txt //建立软连接文件
7.
[root@rhcsa test2]# ln text111.txt text111_hard.txt //建立硬连接文件
8.
[root@rhcsa test]# rm text1.txt
rm:是否删除普通文件 'text1.txt'?y //删除文件
9.
[root@rhcsa ~]# rm -fr test //递归删除文件目录
第六天
1. 管道练习:
将echo "This is my first time to use pipe"内容输出到屏幕上,且保存到pipe_data.txt中
2.2. 重定向:
a.新建一个文件redirect.txt,并在其中写入20210804RHCSA,保存并退出
b.将cat redirect.txt 的输出结果重定向到 redirect1.txt中
c.将cat redirect.txt noexist.txt的标准输出重定向到redirect2.txt, 标准错误输出重定向到error1.txt
d.将cat redirect.txt noexist.txt的标准输出和错误输出都从定向到redirect3.txt中
e.输入重定向:将从键盘输入Welcome to my zone.换行
YYDS
然后输入EOF结束键盘输入,且重定向到my_input.txt中
1.
[root@rhcsa ~]# echo "This is my first time to use pipe" | tee pipe_data.txt
This is my first time to use pipe
[root@rhcsa ~]# more pipe_data.txt
This is my first time to use pipe
2.
a.
[root@rhcsa ~]# vim redirect.txt
b.
[root@rhcsa ~]# cat redirect.txt > redirect1.txt
c.
[root@rhcsa ~]# cat redirect.txt noexist.txt 2> redirect_file > redirect2.txt
d.
[root@rhcsa ~]# cat redirect.txt noexist.txt &> redirect3.txt
[root@rhcsa ~]# more redirect3.txt
20210804RHCSA
cat: noexist.txt: 没有那个文件或目录
e.
[root@rhcsa ~]# cat << EOF >my_input.txt
> Welcome to my zone
> YYDS
> EOF
第七天
1.使用whereis 查找 locate命令
使用which查找whereis命令
使用locate查找rm命令
2.find命令使用:
使用find命令在当前路径下查找所有的普通文件
使用find命令查找当前路径下的file1.txt,file2.txt,file3.txt
使用find命令查找文件所有者为root的普通文件
使用find命令查找修改时间在1天以内的普通文件
3.cut命令使用:
给定文件cut_data.txt且内容为:
No Name Score
1 zhang 20
2 li 80
3 wang 90
4 sun 60
使用默认定界符切割文件内容,且输出切割后的第一个字段
切割文件内容,且输出切割后的第一个字段和第三个字段
按字节切割:输出切割的第一个字节到第10个字节的内容
按字符切割:输出切割后的第一个字符和第5个字符的内容
按指定分界符去切割:内容如下, 输出第一个字段和第三个字段内容
No|Name|Score
1|zhang|20
2|li|80
3|wang|90
4|sun|60
1.使用whereis 查找 locate命令
使用which查找whereis命令
使用locate查找rm命令
[root@rhcsa ~]# whereis locate
locate: /usr/bin/locate /usr/share/man/man1/locate.1.gz
[root@rhcsa ~]# which whereis
/usr/bin/whereis
[root@rhcsa ~]# updatedb
[root@rhcsa ~]# locate rm
2.使用find命令在当前路径下查找所有的普通文件
[root@rhcsa ~]# find -type f
使用find命令查找当前路径下的file1.txt,file2.txt,file3.txt
使用find命令查找文件所有者为root的普通文件
使用find命令查找修改时间在1天以内的普通文件
[root@rhcsa ~]# find -name file1.txt
./file1.txt
[root@rhcsa ~]# find -name file2.txt
./file2.txt
[root@rhcsa ~]# find -name file3.txt
./file3.txt
[root@rhcsa ~]# find -type f -user root
[root@rhcsa ~]# find -type f -mtime -1
3.
[root@rhcsa ~]# cut -d " " cut_data.txt -f1
NO
1
2
3
4
[root@rhcsa ~]# cut -d " " cut_data.txt -f1,3
NO Score
1 20
2 80
3 90
4 60
[root@rhcsa ~]# cut -d " " cut_data.txt -f1-10
NO Name Score
1 zhang 20
2 li 80
3 wang 90
4 sun 60
[root@rhcsa ~]# cut cut_data.txt -d"|" -f 1,3
No|Score
1|20
2|80
3|90
4|60
第八天
1.使用tar命令对文件进行打包压缩与解压缩:
使用gzip方式对文件进行压缩,并指定压缩名为 tar_gzip.tar.gz
使用bzip2方式对文件夹进行压缩,并指定压缩名为 tar_bzip2.tar.bz2
使用xz方式对文件进行压缩,并指定压缩名为 tar_xz.tar.xz
新建文件file1.txt,file2.txt,file3.txt
对文件file1.txt和file2.txt,进行压缩(使用gzip方式),排除file3.txt(即不对file3进行压缩)
并指定压缩名为tar_file.tar.gz
新建文件file4.txt,将file4.txt添加到tar_file.tar.gz中
查看压缩包tar_file.tar.gz有哪些文件及目录(不解压,只查看)
解压tar_gzip.tar.gz到指定目录tar_test(没有这个目录就创建)
解压tar_xz.tar.xz
2.在Linux上的/root目录创建一个Linux.txt,在windows上创建windows.txt
通过sftp的 get和put命令,将windows上的windows.txt推送到linux上
通过sftp的 get和put命令,将linux上的linux.txt推送到windows上
使用rz上传文件windows.txt到linux上
使用sz下载文件linux.txt到windows上
1.
[root@rhcsa ~]# tar -cvzf tar_gzip.tar.gz find_test1
find_test1
[root@rhcsa ~]# tar -cvjf tar_bzip.tar.bz find_test1
find_test1
[root@rhcsa ~]# tar -cvJf tar_xz.tar.xz find_test1
find_test1
[root@rhcsa ~]# tar --exclude=file3.txt -cvzf tar_file.tar.gz file1.txt file2.txt file3.txt
file1.txt
file2.txt
第九天
1.创建普通变量local_data=1并访问
创建环境变量root_data, 只有root用户可以访问到
创建环境变量normal_user_data, 只有普通用户可以访问到
创建环境变量root用户和普通用户都可以访问到
2.创建3个文件test1.txt, test2.txt, test3.txt
使用find查找test1.txt,test2.txt, test3.txt
使用别名: 将上边命令命名为myfind
取消别名
3.查看最近使用的10条历史命令
4.在一行上打印123和以及从root切换到普通用户
5.通配符使用
创建3个文件 file1, file2, file3
1.* 去匹配3个文件
2.? 匹配3个文件
3.[]匹配file1和file3
4.[^]匹配file2
5.[!]匹配file2
6.{}匹配file1和file3
6.引号的使用举例: 无引号,单引号,双引号,反引号,$()
7.linux中用户的类型
linux中用户组的类型
linux中存储用户信息的文件是哪个?且其中的字段是什么意思
linux中存储组信息的文件是哪个?且其中的字段是什么意思?
1.
[root@rhcsa ~]# local_data=1
[root@rhcsa ~]# echo $local_data
1
第十天
1.创建下列用户、组和组成员资格:
1.创建名为 sysmgrs 的组
2.创建用户 natasha 同时指定sysmgrs作为natasha的附加组
3.创建用户 harry 同时指定 sysmgrs作为natasha的附加组
4.创建用户 sarah 指定shell类型为/sbin/false(无权访问系统上的交互式 shell)
且不是 sysmgrs 的成员
5.设置natasha 、 harry 和 sarah 的密码都是 123
6.创建用户lockuser, 并指定家目录为/home/lock, 然后锁定该用户
7.创建用户limituser, gid为1555,userid为1666, 让其密码在10天后过期
8.解锁lockuser, 并设定下次登录时必须修改密码
9.让natasha具备修改 harry密码的权限(sudo)
10.创建用户testuser并设置密码,修改用户名为normaluser
11.删除lockuser
2. 755-》对应什么权限
600-》对象什么权限
644-》对应什么权限
1.
[root@rhcsa ~]# groupadd sysmgrs
2.
[root@rhcsa ~]# useradd -G sysmgrs natasha
3.
[root@rhcsa ~]# useradd -G natasha harry
4.
[root@rhcsa ~]# useradd -s /sbin/false sarah
5.
[root@rhcsa ~]# passwd natasha
[root@rhcsa ~]# passwd harry
[root@rhcsa ~]# passwd sarah
6.
[root@rhcsa ~]# useradd lockuser -d /home/lock
[root@rhcsa ~]# passwd -l lockuser
7.
[root@rhcsa ~]# passwd limituser -n 10
8.
[root@rhcsa ~]# passwd lockuser -fu
[root@rhcsa ~]# passwd lockuser -e
9.
10.
[root@rhcsa ~]# useradd testuser -p 123
[root@rhcsa ~]# usermod -l normaluser testuser
11.
[root@rhcsa ~]# userdel lockuser -r
12.755 对应 组内用户可以读写执行 用户组可读可执行 其他用户可读可执行
600 对应 组内用户可读可写 用户组不可以读写执行 其他用户不可读写执行
644 对应 组内用户可读可写 用户组仅可读 其他用户仅可读
第十一天
1.创建文件,并赋予权限611(两种方式,一种guoa,一种nnn)
2.创建目录,并赋予权限755(两种方式,一种guoa,一种nnn)
3.创建文件,并将文件的属主和属组修改其他用户
4.设置suid,为文件设置suid(两种方式 u+s和nnnn)的方式
5.设置sgid, 为文件设置sgid(两种方式 g+s和nnnn)的方式
6.设置sbit,为目录设置sbit(两种方式 o+t和nnnn)的方式
7.创建文件,查询文件的acl
为文件设置acl 用户为testuser1 权限为 rwx
为文件设置acl的mask: 权限为r-x
1.
[root@rhcsa ~]# chmod g+w work
[root@rhcsa ~]# chmod o-r work
[root@rhcsa ~]# chmod o+x work
[root@rhcsa ~]# chmod 611 work
2.
[root@rhcsa ~]# chmod 755 work_dir
3.
[root@rhcsa ~]# chown beixin.beixin work
4.
[root@rhcsa ~]# chmod u+s work
[root@rhcsa ~]# chmod 4000 work
5.
[root@rhcsa ~]# chmod g+xs work
[root@rhcsa ~]# chmod 2000 work
6.
[root@rhcsa ~]# chmod o+t work
[root@rhcsa ~]# chmod 1000 work
7.
[root@rhcsa ~]# getfacl work
# file: work
# owner: beixin
# group: beixin
# flags: --t
user::---
group::---
other::---
[root@rhcsa ~]# setfacl -m u:beixin:rwx work
[root@rhcsa ~]# setfacl -m m:rx work
第12天
今日作业:
20211124
1.查询ip的几种方式: ip, ifconfig, nmcli,nmtui
2.nmcli命令使用:
a.在ens160网卡上新建连接static_con,并配置静态ip
b.在ens160网卡上新建连接auto_con, 配置动态ip
c.修改static_con的ip的方式: nmtui,nmcli c modify, nmcli c edit, 修改配置文件
d.激活static_con的方式: up, reapply, reload, load
e.删除auto_con
f.添加一个网卡,并查看设备状态
h:如果是connected,断开连接
i:将断开的网卡状态设为connected
1. ip, ifconfig, nmcli,nmtui
2.
a.
[root@rhcsa ~]# nmcli c add type ethernet con-name static_con ifname ens160 ipv4.addresses 192.168.120.128 ipv4.gateway 192.168.120.2 ipv4.dns 8.8.8.8 ipv4.method manual
b.
[root@rhcsa ~]# nmcli c add type ethernet con-name auto_con ifname ens160 ipv4.method auto
e.
[root@rhcsa ~]# nmcli c delete auto_con