题目名称 linux实验-基本指令1
题目关键字 linux实验-基本指令1
题目录入时间 2013-4-1 22:36:02
题目内容
1、root帐号登录,查看/tmp目录,如果/tmp目录下没有子目录myshare,则建立该目录。
2、创建帐号testuser。 //adduser
3、把myshare目录及其目录下的所有文件和子目录的拥有者该为testuser,工作组改为users。 //chown -R testuser:users /tmp/myshare
4、切换至testuser帐号。进入/tmp/myshare目录,采用vim编辑器编写以上程序,程序名称为hello.sh: //su testuser
!/bin/bash
echo “app start”
echo -e
func (){
echo “hello world!”
}
func
echo -e
echo “app end”
5、保存hello.sh后,给予hello.sh拥有者可读、可写和可执行的权限,同组可读可执行,其他人可执行权限。//chmod 751 hello.sh
6、输入./hello.sh,观察程序输出的效果。
7、进入testuser的用户主目录,在这个目录下创建hello.sh的软链接,同时拷贝hello.sh到该目录下并改名为hello.sh.bak,要求拷贝时保留文件属性值。
ln -s /tmp/myshare/hello.sh link & cp -p /tmp/myshare/hello.sh ./hello.sh.bak
./hello.sh.bak
8、退出testuser帐号,回到root帐号,从/开始查找后缀名为.conf的所有文件,把输出结果重定向到testuser帐号的主目录下的output.txt文件。
find / -name “*.conf” > output.txt
9、在上一步操作的.conf文件中找出文件容量最大的和最小那个,并把这两个文件的容量大小输出到output.txt文件中。
find / -name “*.conf” -ls | tr -s ’ ’ ’ ’ |cut -d’ ’ -f7 | sort -n|head -1 >>output.txt
find / -name “*.conf” -ls | tr -s ’ ’ ’ ’ |cut -d’ ’ -f7 | sort -n| tail -1 >>output.txt
10、统计出系统中有多少个用户帐号,把数量输出到output.txt文件中。cat /etc/passwd | wc -l >>output.txt
11、把output.txt文件转换为windows记事本可正规打开的格式。unix2dos output.txt
12、tar打包压缩testuser帐号主目录下的所有文件。 tar -zcvf pack.gz testuser/
13、用U盘把上一步打包压缩文件拷贝到U盘上。
fdisk -l
mkdir /mnt/usb
mount /dev/sdb1 /mnt/usb
cd usb
cp /home/pack.gz ./pack.gz
umount /dev/sdb1
umount /mnt/usb
fuser -m -k /mnt/usb 解除占用
14、执行userdel -r testuser,执行rm -fr myshare
题目创建人 邝颖杰
题目注释
实验过程记录:
1、
find /tmp/myshare
mkdir /tmp/myshare
2、
adduser testuser
3、
chown -R testuser:users /tmp/myshare
4、
su testuser
cd /tmp/myshare
vim hello.sh
!/bin/bash
echo “app start”
echo -e
func (){
echo “hello world!”
}
func
echo -e
echo “app end”
:wq
5、
chmod 751 hello.sh
6、
./hello.sh
7、
cd /home/testuser
ln -s /tmp/myshare/hello.sh link & cp -p /tmp/myshare/hello.sh ./hello.sh.bak
./hello.sh.bak
8、
su root
find / -name “*.conf” > output.txt
9、
find / -name “*.conf” -ls | tr -s ’ ’ ’ ’ |cut -d’ ’ -f7 | sort -n|head -1 >>output.txt
find / -name “*.conf” -ls | tr -s ’ ’ ’ ’ |cut -d’ ’ -f7 | sort -n|tail -1 >>output.txt
10、
cat /etc/passwd | wc -l >>output.txt
11、
unix2dos output.txt
12、
tar -zcvf pack.gz testuser/
13、
fdisk -l
mkdir /mnt/usb
mount /dev/sdb1 /mnt/usb
cd /mnt/usb
cp /home/pack.gz ./pack.gz
umount /dev/sdb1
umount /mnt/usb
fuser -m -k /mnt/usb #解除占用
14、
userdel -r testuser
rm -fr myshare
ps. 最后发现只能上传zip 手动改后缀名pack.gz.zip