bash
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# pwd
/tmp
bash[root@localhost tmp]# ls
dir1 message1.log message.log systemd-private-05911ea40d594b119513d1155474e3ec-systemd-hostnamed.service-RQjG7b yum
bash[root@localhost tmp]# mkdir test
[root@localhost tmp]# ls
dir1 message1.log message.log systemd-private-05911ea40d594b119513d1155474e3ec-systemd-hostnamed.service-RQjG7b test yum
bash[root@localhost tmp]# cd test/
[root@localhost test]# pwd
/tmp/test
bash# 5. 创建一个名为 example.txt 的新文件
[root@localhost test]# vim example.txt
# 6、在文件中输入一行文本:Hello, Vim!
## 按i切换到编辑模式
## 输入Hello, Vim!
Hello, Vim!
# 7、保存文件并退出 vim。
## 可以使用:wq 保存并退出
:wq
## 也可以按esc进入命令模式
## 直接输入ZZ也可保存并退出(需要有内容修改)
# 8、重新打开example.txt,插入行的一行内容,Hello,World!
## 在命令模式下输入o即可插入 Hello,World!
# 9、将光标移动到第一行,复制从光标位置开始的2行内容
## 命令模式下按gg跳转到第一行行首
## 按esc键切换到命令模式
## 输入2yy即可复制从当前行开始的两行
# 10、将光标移动到文件的末尾,粘贴之前复制的文本,保存文件并退出
## 在命令模式下,按G即可跳转到最后一行
## 按下pp键即可粘贴之前复制的文本
## :wq 保存并退出
bash# 显示有48字节(byte)的大小
[root@localhost test]# ls -l
total 4
-rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt
# 添加了 -h 选项,这个选项会使 ls 命令以人类可读的格式显示文件大小
[root@localhost test]# ls -lh
total 4.0K
-rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt
bash[root@localhost test]# stat example.txt
File: ‘example.txt’
Size: 48 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 8434464 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root)
Context: unconfined_u:object_r:user_tmp_t:s0
Access: 2024-04-07 00:45:06.091038333 +0800
Modify: 2024-04-07 00:45:10.062038423 +0800
Change: 2024-04-07 00:45:10.063038423 +0800
Birth: -
bash[root@localhost test]# cat example.txt
Hello vim!
Hello,World!
Hello vim!
Hello,World!
[root@localhost test]# tac example.txt
Hello,World!
Hello vim!
Hello,World!
Hello vim!
[root@localhost test]# head example.txt
Hello vim!
Hello,World!
Hello vim!
Hello,World!
[root@localhost test]# tail example.txt
Hello vim!
Hello,World!
Hello vim!
Hello,World!
[root@localhost test]# more example.txt
Hello vim!
Hello,World!
Hello vim!
Hello,World!
[root@localhost test]# less example.txt
# 按q退出
bash[root@localhost test]# head -n 1 example.txt
Hello vim!
bash[root@localhost test]# tail -n 1 example.txt
Hello,World!
bash[root@localhost test]# mkdir -m 777 test2
[root@localhost test]# ll
total 4
-rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt
drwxrwxrwx. 2 root root 6 Apr 7 00:53 test2
bash[root@localhost test]# useradd nebula
[root@localhost test]# useradd natasha
[root@localhost test]# su - nebula
[nebula@localhost ~]$
bash[nebula@localhost tmp]$ touch /tmp/nebula.file
[nebula@localhost tmp]$ cd ~
[nebula@localhost ~]$ touch /tmp/nebula.file
[nebula@localhost ~]$ ls -l > /tmp/nebula.file
[nebula@localhost ~]$ exit
logout
[root@localhost test]#
bash[root@localhost test]# su - natasha
[natasha@localhost ~]$ touch /tmp/natasha.file
[natasha@localhost ~]$ ls -l /tmp > /tmp/natasha.file
[natasha@localhost ~]$ ls -l /tmp >> /tmp/natasha.file
[natasha@localhost ~]$ exit
logout
[root@localhost test]#
bash[root@localhost test]# sudo chmod o+w /tmp/nebula.file
bash[root@localhost test]# su - natasha
Last login: Sun Apr 7 01:05:05 CST 2024 on pts/0
[natasha@localhost ~]$ ls -l >> /tmp/nebula.file
[natasha@localhost ~]$ exit
logout
[root@localhost test]#
bash[root@localhost test]# cp /etc/init.d/functions /tmp/
bash[root@localhost test]# mv /tmp/functions /tmp/func
bashgrep 'system' /tmp/func > /tmp/func-system.log
bash[root@localhost test]# grep -c 'system' /tmp/func
20
bash[root@localhost test]# sudo chattr +i /tmp/func-system.log
[root@localhost test]# ll /tmp/func
func func-system.log
[root@localhost test]# ll /tmp/func-system.log
-rw-r--r--. 1 root root 1079 Apr 7 01:09 /tmp/func-system.log
[root@localhost test]# lsattr /tmp/func-system.log
----i----------- /tmp/func-system.log
bash[root@localhost test]# which head
/usr/bin/head
bash[root@localhost test]# find / -name file
/sys/fs/selinux/class/file
/sys/fs/selinux/initial_contexts/file
/usr/bin/file
/usr/share/file
[root@localhost test]# find / -mtime -3
bash[root@localhost ~]# ll /
drwxrwxrwt. 10 root root 4096 Apr 7 15:33 tmp
bash[root@localhost test2]# su - nebula
Last login: Sun Apr 7 00:56:06 CST 2024 on pts/0
[nebula@localhost ~]$ touch /tmp/test/test2/nebbab
[nebula@localhost ~]$ ls /tmp//test/test2/
nebbab
[nebula@localhost ~]$ ll /tmp/test/
total 4
-rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt
drwxrwxrwx. 2 root root 20 Apr 7 15:43 test2
[nebula@localhost ~]$ ll /tmp/test/test2/
total 0
-rw-rw-r--. 1 nebula nebula 0 Apr 7 15:43 nebbab
bash[root@localhost test2]# su - natasha
Last login: Sun Apr 7 15:46:19 CST 2024 on pts/0
[natasha@localhost ~]$ touch /tmp/test/test2/natasha1
[natasha@localhost ~]$ ls /tmp/test/test2/
natasha1 nebbab
[natasha@localhost ~]$ ll /tmp/test/test2/
total 0
-rw-rw-r--. 1 natasha natasha 0 Apr 7 15:47 natasha1
-rw-rw-r--. 1 nebula nebula 0 Apr 7 15:43 nebbab
[natasha@localhost ~]$ ll /tmp/test/
total 4
-rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt
drwxrwxrwx. 2 root root 36 Apr 7 15:47 test2
不可以
因为nebula用户在natasha1文件权限中属于其他用户(other) , 然而其他用户权限只有读取权限(r--)想要修改文件至少需要读取和写入权限(rw-),所以不可以编辑
bash[natasha@localhost ~]$ ll /tmp/test/test2/ total 0 -rw-rw-r--. 1 natasha natasha 0 Apr 7 15:47 natasha1 -rw-rw-r--. 1 nebula nebula 0 Apr 7 15:43 nebbab [natasha@localhost ~]$ ll /tmp/test/ total 4 -rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt drwxrwxrwx. 2 root root 36 Apr 7 15:47 test2
bash[natasha@localhost ~]$ ll /tmp/test/test2/ total 0 -rw-rw-r--. 1 natasha natasha 0 Apr 7 15:47 natasha1 -rw-rw-r--. 1 nebula nebula 0 Apr 7 15:43 nebbab [natasha@localhost ~]$ ll /tmp/test/ total 4 -rw-r--r--. 1 root root 48 Apr 7 00:45 example.txt drwxrwxrwx. 2 root root 36 Apr 7 15:47 test2
bash[root@localhost ~]# vim /tmp/iplist.txt
[root@localhost ~]# sort /tmp/iplist.txt | uniq -c | sort -n
1
2 10.230.31.87
47 10.230.20.237
80 10.230.20.47
93 10.230.28.5
196 10.230.27.138
sort /tmp/iplist.txt
:将文件中的行排序。uniq -c
:删除重复的行,并在每行前面显示该行在输入中出现的次数。sort -n
:将结果按照数值(在这个情况下是每个IP地址出现的次数)进行排序。打开虚拟机设置
在CD/DVD选项中, 将ISO镜像切换为Everything
在设备状态中选择启动时
bash[root@centosMini03 ~]# mount /dev/sr0 /media/
mount: /dev/sr0 is write-protected, mounting read-only
bash[root@centosMini03 ~]# cd /etc/yum.repos.d/
[root@centosMini03 yum.repos.d]# ls
CentOS-Base.repo CentOS-CR.repo CentOS-Debuginfo.repo CentOS-fasttrack.repo CentOS-Media.repo CentOS-Sources.repo CentOS-Vault.repo
[root@centosMini03 yum.repos.d]# mkdir back
[root@centosMini03 yum.repos.d]# mv * ./back/
[root@centosMini03 yum.repos.d]# ls
back
[root@centosMini03 yum.repos.d]# cp back/CentOS-Media.repo .
[root@centosMini03 yum.repos.d]# ls
back CentOS-Media.repo
[root@centosMini03 yum.repos.d]# mv CentOS-Media.repo local.repo
[root@centosMini03 yum.repos.d]# ls
back local.repo
bashvim local.repop
repo# This is Local yum repo [c7-media] name=Local repo baseurl=file:///media gpgcheck=0 enabled=1
清除并更新 YUM 缓存:
bash[root@centosMini03 yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: c7-media
Other repos take up 211 M of disk space (use --verbose for details)
[root@centosMini03 yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
c7-media | 3.6 kB 00:00:00
(1/4): c7-media/group_gz | 153 kB 00:00:00
(2/4): c7-media/primary_db | 6.1 MB 00:00:00
(3/4): c7-media/filelists_db | 7.2 MB 00:00:00
(4/4): c7-media/other_db | 2.6 MB 00:00:00
Metadata Cache Created
bash[root@centosMini03 yum.repos.d]# yum install httpd
bash[root@centosMini03 ~]# wget https://nginx.org/download/nginx-1.24.0.tar.gz
--2024-04-18 20:56:55-- https://nginx.org/download/nginx-1.24.0.tar.gz
Resolving nginx.org (nginx.org)... 198.18.0.189
Connecting to nginx.org (nginx.org)|198.18.0.189|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1112471 (1.1M) [application/octet-stream]
Saving to: ‘nginx-1.24.0.tar.gz’
100%[==================================================================================================================>] 1,112,471 888KB/s in 1.2s
2024-04-18 20:56:59 (888 KB/s) - ‘nginx-1.24.0.tar.gz’ saved [1112471/1112471]
[root@centosMini03 ~]# tar -xzf nginx-1.24.0.tar.gz
[root@centosMini03 ~]# ls
anaconda-ks.cfg nginx-1.24.0 nginx-1.24.0.tar.gz
bashyum install gcc yum install pcre pcre-devel yum install zlib zlib-devel
bash[root@centosMini03 nginx-1.24.0]# ./configure
bash[root@centosMini03 nginx-1.24.0]# make
bash[root@centosMini03 nginx-1.24.0]# make install
bash[root@centosMini03 nginx-1.24.0]# cd /usr/local/nginx/
[root@centosMini03 nginx]# ls
conf html logs sbin
bash[root@centosMini03 nginx]# cd sbin/
[root@centosMini03 sbin]# ls
nginx
[root@centosMini03 sbin]# ./nginx
bash[root@centosMini03 sbin]# iptables -F
bash[root@centosMini03 conf]# cd ..
[root@centosMini03 nginx]# ls
client_body_temp conf fastcgi_temp html logs proxy_temp sbin scgi_temp uwsgi_temp
[root@centosMini03 nginx]# cd html/
[root@centosMini03 html]# ls
50x.html index.html
[root@centosMini03 html]# mv index.html index.html.bak
[root@centosMini03 html]# vim index.html
bashvim index.html
html<h1> Hi! GYC </h1>
<hr>
bash[root@centosMini03 html]# rpm -q basesystem --qf '%{installtime:date}\n'|cut -d " " -f 2-6
18 Apr 2024 07:15:38 PM
本文作者:GYC
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!