第六单元 文本处理工具
一、diff 命令
1.diff 命令用于比较两个文件的内容 , 以了解其区别。它还可用于创建补丁文件。补丁文件用于在企业环境的多台计算机之间对相似文件进行更改
-c 显示上下文周围的行
-u 使用统一输出格式(对于生成补丁文件很有用)
-r 从指定的目录开始文件执行递归式比较
eg:[root@localhost Desktop]# vim file ###两个文件内容相似
[root@localhost Desktop]# cat file
hello world
hello linux
[root@localhost Desktop]# vim file1
[root@localhost Desktop]# cat file1
hello world
123
hello linux
[root@localhost Desktop]# diff file file1 ###比较两个文件的内容,了解区别
1a2
> 123
[root@localhost Desktop]# diff -u file file1 ###使用统一输出格式(对于生成补丁文件很有用)
--- file 2017-04-06 21:20:54.872551171 -0400
+++ file1 2017-04-06 21:21:28.328551171 -0400
@@ -1,2 +1,3 @@
hello world
+123
hello linux
[root@localhost Desktop]# diff -c file file1 ###显示上下文周围的行
*** file 2017-04-06 21:20:54.872551171 -0400
--- file1 2017-04-06 21:21:28.328551171 -0400
***************
*** 1,2 ****
--- 1,3 ----
hello world
+ 123
hello linux
[root@localhost Desktop]# mkdir dir
[root@localhost Desktop]# mkdir dir1
[root@localhost Desktop]# touch dir/file
[root@localhost Desktop]# touch dir1/file
[root@localhost Desktop]# touch dir1/file1
[root@localhost Desktop]# diff -r dir dir1 ###从指定的目录开始文件执行递归式比较
只在 dir1 存在:file1
[root@localhost Desktop]#
二、修补命令 patch
1.patch 采用补丁文件 patchfile ( 包含由 diff 生成的差异列表 ) 并将这些差异应用于生成补丁版的一个或多个原始文件。通常 , 补丁版替换原始文件 , 但当指定 -b 选项时 , 可以制作备份。将用 .orig 文件名后缀重命名原始文件
2.patch 可用于将简单的补丁文件应用于使用以下语法的单个文件
– [root@host etc]# patch issue patchfile
Patching file issue
3.以下命令显示如何使用通过 diff -Naur 创建的补丁文件。用户更改为与从中创建补丁文件的原始目录相似的可比较目录后 , 将执行 patch
– [user@host orig-dir]$ patch -b < /tmp/patchfile
Patching file hosts
Patching file network
eg:[root@localhost Desktop]# yum reinstall patch -y ###下载patch
已加载插件:langpacks
正在解决依赖关系
--> 正在检查事务
---> 软件包 patch.x86_64.0.2.7.1-8.el7 将被 已重新安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
重新安装:
patch x86_64 2.7.1-8.el7 rhel_dvd 110 k
事务概要
================================================================================
重新安装 1 软件包
总下载量:110 k
安装大小:210 k
Downloading packages:
patch-2.7.1-8.el7.x86_64.rpm | 110 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : patch-2.7.1-8.el7.x86_64 1/1
验证中 : patch-2.7.1-8.el7.x86_64 1/1
已安装:
patch.x86_64 0:2.7.1-8.el7
完毕!
[root@localhost Desktop]# ls
file file1
[root@localhost Desktop]# diff -c file file1 >file.path ###显示上下文周围的行,定向到file.path
[root@localhost Desktop]# patch file file.path ###同步文件
patching file file
[root@localhost Desktop]# cat file
hello world
123
hello linux
三、grep 命令
1.grep 将显示文件中与模式匹配的行。其也可以处理标准输入
2.模式可以包含正则表达式元字符 , 因此始终为正则表达式加引号通常被视为一种好办法
-i 执行不区分大小写搜索
-n 前置返回行的行号
-r 对文件执行递归式搜索,从命名目录开始
-c 显示具有匹配模式的行的计数
-v 返回不包含模式的行
eg:[root@localhost Desktop]# cat passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
ROOT:test:root:test
test:root:test:root
test:root:test
[root@localhost Desktop]# grep root passwd
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
ROOT:test:root:test
test:root:test:root
test:root:test
[root@localhost Desktop]# grep -i root passwd ###返回有关键字root的行,不区分大小写
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin
ROOT:test:root:test
test:root:test:root
test:root:test
[root@localhost Desktop]# grep -ic root passwd ###返回有关键字root(不区分大小写)的行数
5
[root@localhost Desktop]# grep -in root passwd ###前置返回行号
1:root:x:0:0:root:/root:/bin/bash
4:operator:x:11:0:operator:/root:/sbin/nologin
5:ROOT:test:root:test
6:test:root:test:root
7:test:root:test
[root@localhost Desktop]# grep -iv root passwd ###返回不包含关键字root的行
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
[root@localhost Desktop]# grep ^root passwd ###返回关键字root在行首的行
root:x:0:0:root:/root:/bin/bash
[root@localhost Desktop]# grep root$ passwd ###返回关键字root在行尾的行
test:root:test:root
[root@localhost Desktop]# grep root passwd | grep -v -E "^root|root$" ###返回有关键字root,但关键字不在行首或行尾
operator:x:11:0:operator:/root:/sbin/nologin
ROOT:test:root:test
test:root:test
[root@localhost Desktop]# grep root passwd | grep -iv -E "^root|root$" ###返回不包含关键字不在行首或行尾模式的行,即root在行中间
operator:x:11:0:operator:/root:/sbin/nologin
test:root:test
[root@localhost Desktop]# grep student -r /etc/ ###对文件执行递归式搜索,从命名目录开始
/etc/group:wheel:x:10:student
/etc/group:student:x:1000:
/etc/gshadow:wheel:::student
/etc/gshadow:student:!::
/etc/shadow-:student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80:16261:0:99999:7:::
/etc/passwd:student:x:1000:1000:Student User:/home/student:/bin/bash
/etc/shadow:student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80:16261:0:99999:7:::
/etc/cron.deny:student
/etc/passwd-:student:x:1000:1000:Student User:/home/student:/bin/bash
/etc/security/limits.conf:#@student hard nproc 20
/etc/security/limits.conf:#@student - maxlogins 4
/etc/group-:wheel:x:10:student
/etc/group-:student:x:1000:
/etc/gshadow-:wheel:::student
/etc/gshadow-:student:!::
/etc/at.deny:student
/etc/cron.allow:student
[root@localhost Desktop]# grep student -rn /etc/ ###前置返回行的行号
/etc/group:11:wheel:x:10:student
/etc/group:43:student:x:1000:
/etc/gshadow:11:wheel:::student
/etc/gshadow:43:student:!::
/etc/shadow-:25:student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80:16261:0:99999:7:::
/etc/passwd:25:student:x:1000:1000:Student User:/home/student:/bin/bash
/etc/shadow:25:student:$6$8oIjLCsc$/n1iQXYh1E6.uOEuJKgioqAtmqm2TQmkJGF2RwyteIr1tIfrPdiRYgWe6Sjen5/eMij2uHM/a1tue/QRlo3X80:16261:0:99999:7:::
/etc/cron.deny:1:student
/etc/passwd-:25:student:x:1000:1000:Student User:/home/student:/bin/bash
/etc/security/limits.conf:55:#@student hard nproc 20
/etc/security/limits.conf:59:#@student - maxlogins 4
/etc/group-:11:wheel:x:10:student
/etc/group-:43:student:x:1000:
/etc/gshadow-:11:wheel:::student
/etc/gshadow-:43:student:!::
/etc/at.deny:1:student
/etc/cron.allow:1:student
四、Cut 命令
1.cut 用于 “ 剪切 ” 文件中的文本字段或列并将其显示到标准输出
-d 指定用于提取字段的分隔符(Tab是默认值)
-f 指定要从每行中提取的字段
-c 指定要从每行中提取的文本列
eg:[root@localhost Desktop]# cut -d : -f 1 passwd ###指定用于提取字段的分隔符":",指定要从每行中提取的字段"1"
root
bin
daemon
operator
ROOT
test
test
[root@localhost Desktop]# cut -c 4-10 passwd ###指定要从每行中提取的文本列"4-10"
t:x:0:0
:x:1:1:
mon:x:2
rator:x
T:test:
t:root:
t:root:
[root@localhost Desktop]# cut -d " " -f 1 passwd ###以空格为分隔符
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
ROOT:test:root:test
test:root:test:root
test:root:test
[root@localhost Desktop]# cut -d / -f 1 passwd ###以“/”为分隔符
root:x:0:0:root:
bin:x:1:1:bin:
daemon:x:2:2:daemon:
operator:x:11:0:operator:
ROOT:test:root:test
test:root:test:root
test:root:test
[root@localhost Desktop]# awk -F : '{print $1,$3}' passwd ###以“:”为分隔符,显示第一个和第三个字符串
root 0
bin 1
daemon 2
operator 11
ROOT root
test test
test test
[root@localhost Desktop]# awk -F : '{print $1$3}' passwd
root0
bin1
daemon2
operator11
ROOTroot
testtest
testtest
[root@localhost Desktop]# awk -F : '{print $1" "$3}' passwd
root 0
bin 1
daemon 2
operator 11
ROOT root
test test
test test
[root@localhost Desktop]# awk -F : '{print $1/$3}' passwd
awk: cmd. line:1: (FILENAME=passwd FNR=1) fatal: division by zero attempted
[root@localhost Desktop]# awk -F : '{print $1"/"$3}' passwd
root/0
bin/1
daemon/2
operator/11
ROOT/root
test/test
test/test
[root@localhost Desktop]# awk -F : '{print $1":"$3}' passwd
root:0
bin:1
daemon:2
operator:11
ROOT:root
test:test
test:test
[root@localhost Desktop]# ifconfig eth0 | grep inet | grep inet6 -v | awk -F " " '{print $2}'
172.25.42.10
五、sort 命令
1.sort 用于排序文本数据。该数据可以位于文件中或其他命令输出中。 Sort 通常与管道一起使用
-n 按数值而非字符排序
-k 设置排序字段
-t 指定其他字段分隔符(默认为空格)
-r 倒叙
-u 唯一的
eg:[root@localhost Desktop]# cat file
1
3
2
4
1
4
11
8
34
21
9
[root@localhost Desktop]# sort file ###排序,以第一个数字为基准,排序
1
1
11
2
21
3
34
4
4
8
9
[root@localhost Desktop]# sort -n file ###按数值而非字符排序
1
1
2
3
4
4
8
9
11
21
34
[root@localhost Desktop]# vim file
[root@localhost Desktop]# cat file
2:a:1
4:a:3
1:a:2
3:a:4
2:a:1
1:a:4
4:a:11
11:a:8
22:a:34
33:a:21
44:a:9
[root@localhost Desktop]# sort -n file ###按数值而非字符排序
1:a:2
1:a:4
2:a:1
2:a:1
3:a:4
4:a:11
4:a:3
11:a:8
22:a:34
33:a:21
44:a:9
[root@localhost Desktop]# sort -t : -k 3 -n file ###以“:”为分隔符,第三个字符排序
2:a:1
2:a:1
1:a:2
4:a:3
1:a:4
3:a:4
11:a:8
44:a:9
4:a:11
33:a:21
22:a:34
[root@localhost Desktop]# sort -t : -k 3 -rn file ###以“:”为分隔符,第三个字符倒序
22:a:34
33:a:21
4:a:11
44:a:9
11:a:8
3:a:4
1:a:4
4:a:3
1:a:2
2:a:1
2:a:1
[root@localhost Desktop]# sort -t : -k 3 -rnu file ###以“:”为分隔符,第三个字符倒序,不显示重复的
22:a:34
33:a:21
4:a:11
44:a:9
11:a:8
3:a:4
4:a:3
1:a:2
2:a:1
[root@localhost Desktop]#
六、uniq 命令
1.uniq“ 删除 ” 文件中重复的相邻行。若要只打印文件中出现的唯一行(“ 删除 ” 所有重复行 ), 必须首先对 uniq 的输入进行排序。由于可以为uniq 指定其决策所基于的字段或列 , 因此这些字段或列是对其输入进行排序所必须的字段或列。如果未与选项一起使用 , uniq 会使用整个记录作为决策键 , 删除其输入中的重复行
-u 仅显示唯一行
-d 显示重复行
-c 每行显示一次(包括出现计数)
eg:[root@localhost Desktop]# cat file
1
3
2
4
1
4
11
8
34
21
9
[root@localhost Desktop]# sort -n file | uniq -u ###显示唯一行
2
3
8
9
11
21
34
[root@localhost Desktop]# sort -n file | uniq -d ###显示重复行
1
4
[root@localhost Desktop]# sort -n file | uniq -c ###每行仅显示一次,并计数
2 1
1 2
1 3
2 4
1 8
1 9
1 11
1 21
1 34
[root@localhost Desktop]# cat file
2:a:1
4:a:3
1:a:2
3:a:4
2:a:1
1:a:4
4:a:11
11:a:8
22:a:34
33:a:21
44:a:9
[root@localhost Desktop]# sort -t : -k 3 -n file | uniq -u
1:a:2
4:a:3
1:a:4
3:a:4
11:a:8
44:a:9
4:a:11
33:a:21
22:a:34
[root@localhost Desktop]# sort -t : -k 3 -n file | uniq -c
2 2:a:1
1 1:a:2
1 4:a:3
1 1:a:4
1 3:a:4
1 11:a:8
1 44:a:9
1 4:a:11
1 33:a:21
1 22:a:34
七、tr 命令
1.tr 用于转字符 : 即 , 如果给定了两个字符范围 , 则只要发现某个字符位于第一个范围中 , 就会将其转换为第二个范围中对等的字符。该命令通常在 shell 脚本中使用 , 以按预期情况转换数据
2.tr 'A-Z' 'a-z' <file
八、sed 命令
1.sed 命令是流编辑器 , 用于对文本数据流执行编辑。假定要处理一个文件名 , sed 将对文件中的所有行执行搜索和替换 , 以将修改后的数据发送到标准输出 ; 即 , 其实际上并不修改现有文件。与 grep 一样 , sed 通常在管道中使用
2.由于 sed 命令通常包含可以解释为 shell 元字符的字符 ,因此请按下面示例所示引用 sed 命令。默认情况下 , sed对文件中的所有行执行操作。在提供 sed 时 , 可带有地址
s/old/new 执行字符串转换,将old替换为new
d 删除匹配的行
eg:[root@localhost Desktop]# vim create_users.sh
[root@localhost Desktop]# cat create_users.sh
#!/bin/bash
max=`wc -l /root/Desktop/userfile|awk -F ' ' '{print $1}'`
for NUM in $(seq 1 $max)
do
username=`sed -n "$NUM"p $1`
passwd=`sed -n "$NUM"p $2`
useradd $username
echo $passwd | passwd --stdin $username
done
[root@localhost Desktop]# ./create_users.sh /root/Desktop/userfile /root/Desktop/passfile
更改用户 user1 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 user2 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 user3 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 user4 的密码 。
passwd:所有的身份验证令牌已经成功更新。
更改用户 user5 的密码 。
passwd:所有的身份验证令牌已经成功更新。
[root@localhost Desktop]#
第九单元 部署 ftp 文件共享服务
一、部署 FTP 服务器
1.FTP ( 文件传输协议 ) 是 INTERNET 上仍常用的最老的网络协议之一 , 它为系统提供了通过网络与远程服务器进行传输的简单方法
2.在 RED HAT ENTREPRISE LINUX 6 中。 FTP 服务器包的名称为 VSFTPD , 它代表 Very Secure File TransferProtocol Damon 服务器名称也叫做 vsftpd
3.默认配置文件让 ANONYMOUS 用户只能下载位于CHROOT 目录中的内容。 /var/ftp/ 这意味着远程 FTP客户端能以用户 anonymous 或 ftp 身份连接到服务器( 无需密码 ), 并从 ftp 服务器上的 /var/ftp/ 目录下载文件( 其本地 ftp 用户可以读取这些文件 )
二、部署网络服务的四个步骤
1.安装服务软件
2.启动服务
3.启用服务
4.测试服务
三、安装 vsftpd 包并启动服务
1.yum install vsftpd -y
2.systemctl start vsftpd
3.systemctl enable vsftpd
四、启用 vsftpd 服务
1.Applications-->Sundry-->Firewall
五、测试服务
1.cd /var/ftp/pub/
2.touch file{1..3}
3.lftp 172.25.0.10
lftp 172.25.0.10:~> ls
drwxr-xr-x 2 0 0 42 Nov 20 07:19 pub
lftp 172.25.0.10:/> cd pub/
lftp 172.25.0.10:/pub> ls
-rw-r--r-- 1 0 0 0 Nov 20 07:19 file1
-rw-r--r-- 1 0 0 0 Nov 20 07:19 file2
-rw-r--r-- 1 0 0 0 Nov 20 07:19 file3
六、FTP 服务器配置
1.默认配置为匿名 FTP 服务器 , 仅允许匿名客户端 下载 , 并且禁用所有本地用户 , 禁止上传
2.vsftpd 配置件 : /etc/vsftpd/vsftpd.conf ,document root 位于 /var/ftp/ 中 , 配置修改后 , 需重新启动服务
3.选项示例 :
– anonymous_enable=YES
– local_enable=NO
– write_enable=NO
七、Vsftpd 服务配置
eg:[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# ls
rhel_dvd.repo
[root@localhost yum.repos.d]# vim rhel_dvd.repo ###修改yum源
[root@localhost yum.repos.d]# cat rhel_dvd.repo
# Created by cloud-init on Thu, 10 Jul 2014 22:19:11 +0000
[rhel_dvd]
gpgcheck = 0
enabled = 1
baseurl = http://172.25.254.250/rhel7
name = Remote classroom copy of dvd
[root@localhost yum.repos.d]# yum clean all ###重启yum服务
已加载插件:langpacks
正在清理软件源: rhel_dvd
Cleaning up everything
[root@localhost yum.repos.d]# yum install vsftpd -y ###下载vsftpd软件
已加载插件:langpacks
rhel_dvd | 4.1 kB 00:00
(1/2): rhel_dvd/group_gz | 134 kB 00:00
(2/2): rhel_dvd/primary_db | 3.4 MB 00:00
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-9.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
================================================================================
Package 架构 版本 源 大小
================================================================================
正在安装:
vsftpd x86_64 3.0.2-9.el7 rhel_dvd 166 k
事务概要
================================================================================
安装 1 软件包
总下载量:166 k
安装大小:343 k
Downloading packages:
vsftpd-3.0.2-9.el7.x86_64.rpm | 166 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : vsftpd-3.0.2-9.el7.x86_64 1/1
验证中 : vsftpd-3.0.2-9.el7.x86_64 1/1
已安装:
vsftpd.x86_64 0:3.0.2-9.el7
完毕!
[root@localhost yum.repos.d]# systemctl start vsftpd ###开启vsftpd服务
[root@localhost yum.repos.d]# systemctl enable vsftpd ###开机vsftpd服务自启动
ln -s '/usr/lib/systemd/system/vsftpd.service' '/etc/systemd/system/multi-user.target.wants/vsftpd.service'
[root@localhost yum.repos.d]# firewall-cmd --list-all ###查看火墙状态
public (default, active)
interfaces: eth0
sources:
services: dhcpv6-client ssh ###仅对于ssh服务,火墙永久关闭
ports:
masquerade: no
forward-ports:
icmp-blocks:
rich rules:
[root@localhost yum.repos.d]# firewall-config ###设置防火墙状态
#添加ftp,选择permanent,以及options->reload firewalld ###对于ftp服务,防火墙永久关闭
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142 ###匿名用户连接
lftp 172.25.254.142:~> ls ###连接成功,打开的是/var/ftp/目录
drwxr-xr-x 2 0 0 6 Mar 07 2014 pub
lftp 172.25.254.142:/> quit
[kiosk@foundation42 Desktop]$
[root@localhost yum.repos.d]# cd /var/ftp/
您在 /var/spool/mail/root 中有新邮件
[root@localhost ftp]# ls
pub
[root@localhost vsftpd]# vim /etc/vsftpd/vsftpd.conf ###ftp服务配置文件
#12 anonymous_enable=yes ###匿名用户,yes可连接,no不可连接
#16 local_enable=no ###本地用户,yes可连接,no不可连接
[root@localhost vsftpd]# systemctl restart vsftpd.service ###重启vsftpd
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142 -u student
口令:
lftp student@172.25.254.142:~> ls
ls: 登录失败: 530 This FTP server is anonymous only.
lftp student@172.25.254.142:~> quit
[kiosk@foundation42 Desktop]$
[root@localhost vsftpd]# cd /var/ftp/
[root@localhost ftp]# touch file{1..5}
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142
lftp 172.25.254.142:~> ls
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file1
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file2
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file3
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file4
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file5
drwxr-xr-x 2 0 0 6 Mar 07 2014 pub
lftp 172.25.254.142:/> quit
[kiosk@foundation42 Desktop]$
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142 -u student
口令:
lftp student@172.25.254.142:~> ls
lftp student@172.25.254.142:~> put /etc/passwd
put: Access failed: 553 Could not create file. (passwd)
lftp student@172.25.254.142:~> quit
[kiosk@foundation42 Desktop]$
[root@localhost ftp]# setenforce 0
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142 -u student
口令:
lftp student@172.25.254.142:~> ls
lftp student@172.25.254.142:~> put /etc/passwd
2270 bytes transferred
lftp student@172.25.254.142:~> quit
[kiosk@foundation42 Desktop]$
[root@localhost ftp]# vim /etc/vsftpd/vsftpd.conf
# 19 write_enable=no
[root@localhost ftp]# systemctl restart vsftpd.service
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142 -u student
口令:
lftp student@172.25.254.142:~> ls
-rw-r--r-- 1 1000 1000 2270 Apr 07 06:23 passwd
lftp student@172.25.254.142:~> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
lftp student@172.25.254.142:~> quit
[kiosk@foundation42 Desktop]$
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142
lftp 172.25.254.142:/> put /etc/passwd
put: Access failed: 550 Permission denied. (passwd)
lftp 172.25.254.142:/> quit
[kiosk@foundation42 Desktop]$
[root@localhost ftp]# vim /etc/vsftpd/vsftpd.conf
#29 anon_upload_enable=YES
[root@localhost ftp]# systemctl restart vsftpd.service
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142
lftp 172.25.254.142:~> ls
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file1
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file2
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file3
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file4
-rw-r--r-- 1 0 0 0 Apr 07 06:17 file5
drwxr-xr-x 2 0 0 6 Mar 07 2014 pub
lftp 172.25.254.142:/> put /etc/passwd
put: Access failed: 553 Could not create file. (passwd)
lftp 172.25.254.142:/> quit
[kiosk@foundation42 Desktop]$
[root@localhost var]# chgrp ftp /var/ftp/pub/
[root@localhost var]# chmod 775 /var/ftp/pub/
[root@localhost var]# ls -ld /var/ftp/pub/
drwxrwxr-x. 2 root ftp 6 Mar 7 2014 /var/ftp/pub/
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142
lftp 172.25.254.142:~> cd /pub/
lftp 172.25.254.142:/pub> ls
lftp 172.25.254.142:/pub> put /etc/passwd
2270 bytes transferred
lftp 172.25.254.142:/pub> quit
[kiosk@foundation42 Desktop]$
[kiosk@foundation42 Desktop]$ lftp 172.25.254.142
lftp 172.25.254.142:~> cd pub/
lftp 172.25.254.142:/pub> ls
-rw------- 1 14 50 2270 Apr 07 06:46 passwd
lftp 172.25.254.142:/pub> get passwd
get: Access failed: 550 Failed to open file. (passwd)
lftp 172.25.254.142:/pub> mkdir test
mkdir: Access failed: 550 Permission denied. (test)
lftp 172.25.254.142:/pub> rm -fr passwd
lftp 172.25.254.142:/pub> ls
-rw------- 1 14 50 2270 Apr 07 06:46 passwd
lftp 172.25.254.142:/pub> quit
[kiosk@foundation42 Desktop]$