1、在系统中以自己名字首字母创建账号,该账号密码为123456,该账号所属组为hehe;
首先创建用户组hehe
groupadd hehe
再创建用户hhy
useradd hhy -g hehe
设置密码
passwd hhy
提示简单不用管,输入两边123456搞定
创建hehecici账号,该账号密码为123456。
useradd hehecici
passwd hehecici
如果想查看用户所属组
id hhy就可以查看
2、在/root/hehe/haha目录下创建文件a和b,a文件内容为aaaaa,b文件内容为bbbbb,其中a的所有者和所属组为root:hehe,b的所有者和所属组为自己名字首字母账号:hehe;
首先创建文件夹,再创建文件并加入内容,在/root/hehe/haha目录下执行以下
chown root:hehe a
chown hhy:hehe b
没有涉及到子文件夹,如果涉及到子文件夹需要加-R
3、a文件所有者可读、可写、不可执行,所属组不可读、可写、可执行,其他人不可读、不可写、可执行
chmod 631 a
或者字符法
r可读4 w可写3 x可执行1
chmod u=rw a
chmod g=wx a
chmod o=x a
4、b文件所有人不可读、不可写、不可执行。
chmod 000 b
或者字符法
chmod u= b
chmod g= b
chmod o= b
5、复制b文件,复制后的文件名为c。
cp b c
1、安装ftp,设置共享目录为/root/hehe/haha,要求hehecici账号能够上传下载文件,自己名字首字母账号只能上传,不能下载。
首先安装
yum install -y vsftpd ftp
关闭防火墙
setenforce 0 #临时关闭
systemctl stop firewalld.service #关闭防火墙
创建用户
useradd -d /root/hehe/haha/ vuser -s /sbin/nologin
设置权限
chmod 755 /root/hehe/haha/
创建虚拟用户
vim /etc/vsftpd/vuser-list
ljh
123456
hehecici
123456
5.加密用户文件生成数据库文件
cd /etc/vsftpd/
db_load -T -t hash -f vuser-list vuser-list.db
chmod 600 vuser-list.db
6.创建pam认证文件
vim /etc/pam.d/vuser.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser-list
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vuser-list
7.修改配置文件
这个和之前不一样,需要把原有的改了,把这个加上
cd /etc/vsftpd/
编辑vsftpd.conf
vim vsftpd.conf
进去之后输入ggdG就清空了
*********************************************
anonymous_enable=yes
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
listen=NO
listen_ipv6=YES
chroot_local_user=YES
local_root=/root/hehe/haha
anon_root=/root/hehe/haha
pam_service_name=vuser.vu
user_config_dir=/etc/vsftpd/vuser_config
userlist_enable=YES
tcp_wrappers=YES
allow_writeable_chroot=YES
one_process_model=NO
guest_enable=YES
guest_username=vuser
pasv_promiscuous=YES
yum --enablerepo=remi-php70 install -y php php-cli php-mysqlnd php-fpm php-devel php-opcache php-common php-embedded php-gd php-mbstring php-xml php-pdo
***************************************************************************
到这里结束,然后进入
mkdir -p /etc/vsftpd/vuser_config
cd /etc/vsftpd/vuser_config
自己名字开头,不可下载,可上传
cd /root/hehe/haha vim l chmod 777 l
cd /root vim h chmod 777 h chmod -R 777 /root
vim ljh
local_root=/root/hehe/haha/
write_enable=yes
anon_upload_enable=YES
download_enable=NO
root里 hehe/haha里建立文件
进入/root/hehe/haha目录
创建一个文件并写入内容 下载get用 chmod 777 文件 get用
在根目录下建立一个文件 上传用 put chmod 777 文件 chmod -R 777 /root put用
hehecici 可下载,可上传
cd /root/hehe/haha vim he chmod 777 he
cd /root vim ci chmod 777 ci
vim hehecici
local_root=/root/hehe/haha/
write_enable=YES
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
很重要!!!!!
要在阿里云后台放行21端口
重启vsftpd服务
systemctl restart vsftpd
然后ftp 地址就可以了
**********samba操作*************
端口是139
root里 hehe/haha里
安装samba
yum install -y samba samba-client
systemctl start smb nmb
创建smb账号密码,首先要在创建之前useradd账号
useradd hehecici
useradd hhy
smbpasswd -a hehecici
smbpasswd -a hhy
创建共享文件夹
mkdir -p /root/hehe/haha
然后编辑共享配置文件
vim /etc/samba/smb.conf
[hehe]
comment = sharing
path = /root/hehe/haha
readonly = yes
write list = hehecici
进入/root/hehe/haha目录
创建一个文件并写入内容 下载get用 chmod 777 文件
在根目录下建立一个文件 上传用 put chmod 777 文件 chmod -R 777 /root
然后就可以登陆samba服务器了
登陆方法:
smbclient //你的公网地址/hehe -U hehecici
put 根目录下文件 可以
get haha目录下文件 可以
smbclient //你的公网地址/hehe -U hhy
put 根目录下文件 可以
get haha目录下文件 不可以