官术网_书友最值得收藏!

How to do it...

Let's begin our activity as follows:

  1. Open a new terminal and start an editor of your choice and create a new script. The following is a code snippet from the script:
#!/bin/bash
FILE_TO_TEST=""

function permissions() {

echo -e "\nWhat are our permissions on this $2?\n"
if [ -r $1 ]; then
echo -e "[R] Read"
fi
if [ -w $1 ]; then
echo -e "[W] Write"
fi
if [ -x $1 ]; then
echo -e "[X] Exec"
fi
}

function file_attributes() {

if [ ! -s $1 ]; then
echo "\"$1\" is empty"
else
FSIZE=$(stat --printf="%s" $1 2> /dev/null)
RES=$?
if [ $RES -eq 1 ]; then
return
else
echo "\"$1\" file size is: ${FSIZE}\""
fi
fi

if [ ! -O $1 ]; then
echo -e "${USER} is not the owner of \"$1\"\n"
fi
if [ ! -G $1 ]; then
echo -e "${USER} is not among the owning group(s) for \"$1\"\n"
fi

permissions $1 "file"

}
  1. Execute the script and try to access the various files, including the directories and files that do not exist. What do you notice?
  2. Remove the folder now with this command:
$ sudo rm -rf fileops
主站蜘蛛池模板: 洛隆县| 囊谦县| 遂溪县| 汾西县| 确山县| 拉孜县| 肃宁县| 平定县| 公安县| 高邮市| 苏尼特右旗| 星座| 仁化县| 锡林浩特市| 临颍县| 财经| 收藏| 平利县| 文成县| 平遥县| 鄂伦春自治旗| 故城县| 通许县| 青州市| 通城县| 揭西县| 资中县| 西华县| 葫芦岛市| 寻甸| 玉门市| 柯坪县| 海盐县| 梁山县| 贵定县| 仁寿县| 柏乡县| 宁海县| 亚东县| 阜宁县| 宝丰县|