From bfddd5311d7d5f580e51bd9e7978085d45478caf Mon Sep 17 00:00:00 2001 From: RealStickman Date: Sun, 24 Apr 2022 14:56:10 +0200 Subject: [PATCH] (Grav GitSync) Automatic Commit from RealStickman --- .../02.linux/02.file-operations/default.en.md | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 pages/02.linux/02.file-operations/default.en.md diff --git a/pages/02.linux/02.file-operations/default.en.md b/pages/02.linux/02.file-operations/default.en.md new file mode 100644 index 0000000..c5ac52a --- /dev/null +++ b/pages/02.linux/02.file-operations/default.en.md @@ -0,0 +1,40 @@ +--- +title: 'File Operations' +--- + +## Workings of file permissions + +### Change permissions +To change file permissions use `chmod (-R) XXX (path)` + +XXX signify the permissions for the file's owner/group/others respectively + +Each X goes from 0 to 7. +What each number means can be easily calculated by looking at what the individual bit values mean. +``` +0 -> No Permission +4 -> Read Permission +2 -> Write Permission +1 -> Execute Permission +``` + +A value of 5 therefor gives the permissions "Read" and "Execute". + +*To enter a folder, you need the read as well as the execute permission!* + +### Change user and group +Use `chown` to change the owner and group of a file or directory. + +Example: +`chown (-R) (owner):(group) (path)` + +### Change group +Use `chgrp` to change the group of a file or directory. + +Example: +`chgrp (-R) (group) (path)` + +## Find biggest files +`find . -type f -print0 | xargs -0 du -s | sort -n | tail -(amount) | cut -f2 | xargs -I{} du -sh {}` + +`find . -type f -printf "%s %p\n" | sort -nr | head -5` \ No newline at end of file