- Bash Cookbook
- Ron Brash Ganesh Naik
- 138字
- 2021-07-23 19:17:40
Getting ready
Let's get ready for the exercise by creating a few text files and directories, and adding some content:
$ cd ~/
$ mkdir -p fileops
$ touch fileops/empty.txt
$ echo "abcd1234!!" > fileops/string.txt
$ echo "yieldswordinthestone" > fileops/swordinthestone.txt
$ touch fileops/read.txt fileops/write.txt fileops/exec.txt fileops/all.txt
$ chmod 111 fileops/exec.txt; chmod 222 fileops/write.txt; chmod 444 fileops/read.txt; fileops/all.txt;chmod 777 fileops/all.txt
$ sudo useradd bob
$ echo "s the name" > fileops/bobs.txt
$ sudo chown bob.bob fileops/bobs.txt
This recipe is about performing some simple file tests and to combine some of the other knowledge from earlier recipes on conditional logic, but with a twist—using user input from the CLI and file permissions.
Notice the commands chmod, useradd, and chmod. Chmod is the command you may use to change the permissions of files for execution and more.
推薦閱讀
- DevOps:軟件架構師行動指南
- C語言程序設計實踐教程(第2版)
- Mastering Python Scripting for System Administrators
- Internet of Things with Intel Galileo
- 精通Python自然語言處理
- Mastering Apache Maven 3
- R用戶Python學習指南:數據科學方法
- GameMaker Essentials
- QGIS Python Programming Cookbook(Second Edition)
- Building Serverless Architectures
- 代替VBA!用Python輕松實現Excel編程
- PHP項目開發全程實錄(第4版)
- Android應用程序設計
- 數據結構與算法詳解
- R語言數據分析從入門到實戰