From 4e6e06483e93fe996650956e4b9b815b342790fa Mon Sep 17 00:00:00 2001 From: Ravi Date: Tue, 14 Feb 2023 12:56:54 +0530 Subject: [PATCH] setcap: add page (#9850) * setcap: add page * Update pages/linux/setcap.md Co-authored-by: K.B.Dharun Krishna --- pages/linux/setcap.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pages/linux/setcap.md diff --git a/pages/linux/setcap.md b/pages/linux/setcap.md new file mode 100644 index 000000000..962d12142 --- /dev/null +++ b/pages/linux/setcap.md @@ -0,0 +1,25 @@ +# setcap + +> Set capabilities of specified file. +> See also: `tldr getcap`. +> More information: . + +- Set capability `cap_net_raw` (to use RAW and PACKET sockets) for a given file: + +`setcap '{{cap_net_raw}}' {{path/to/file}}` + +- Set multiple capabilities on a file (ep behind the capability means "effective permitted"): + +`setcap '{{cap_dac_read_search,cap_sys_tty_config+ep}}' {{path/to/file}}` + +- Remove all capabilities from a file: + +`setcap -r {{path/to/file}}` + +- Verify that the specified capabilities are currently associated with the specified file: + +`setcap -v '{{cap_net_raw}}' {{path/to/file}}` + +- The optional `-n {{rootuid}}` argument can be used to set the file capability for use only in a user namespace with this root user ID owner: + +`setcap -n {{rootuid}} '{{cap_net_admin}}' {{path/to/file}}`