LINUX实验课练习(每一题相对应的解释和分析,红色字为重点)
1、root帐号登录,查看/tmp目录,如果/tmp目录下没有子目录myshare,则建立该目录。
cd /tmp
mkdir myshare
2、创建帐号testuser。
useradd testuser(最好用passwd设置个密码什么的)
3、把myshare目录及其目录下的所有文件和子目录的拥有者该为testuser,工作组改为users。
chown -R testuser:users myshare
4、切换至testuser帐号。进入/tmp/myshare目录,采用vim编辑器编写以上程序,程序名称为hello.sh:
#!/bin/bash
echo "app start"
echo -e
func (){
echo "hello world!"
}
func
echo -e
echo "app end"
su - testuser
cd /tmp/myshare
vi hello.sh(按i/o/a/R进入Insert模式)
输入完代码后 按ESC回到命令模式 然后输入:wq保存并退出
可利用cat hello.sh查看是否输入正确
5、保存hello.sh后,给予hello.sh拥有者可读、可写和可执行的权限,同组可读可执行,其他人可执行权限。
r、w、x分别为4、2、1 还有ugo的知识 不懂的要自己搞懂 下面751分别对应ugo
chmod 751 hello.sh