Is #chmod o-w /usr safe?

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
Wiz Kid

Is #chmod o-w /usr safe?

Post by Wiz Kid »

I was trying to set up a VM in virtualbox and a forum said to run this command

Code: Select all

#chmod o-w /usr
But is it safe or should I undo it, because in the end it was not what solved the problem. I don't want to run an insecure box. All I know is that I gave write permissions to that folder, but I don't know if that is very unsafe to do?

And can someone please post the undo command as well, Thanks.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
bkidwell

Re: Is #chmod o-w /usr safe?

Post by bkidwell »

So my /usr folder is owned by root:root with 755 permissions you likely have the same with that command. If you drop to / and run

Code: Select all

ls -l
look for /usr and it should say something like
drwxr-xr-x 11 root root 4096 Sep 26 09:38 usr
If not you can set it to that with this.

Code: Select all

sudo chmod 755 /usr
The "o" symobilizes the last three letters of the 10, meaning other people besides the OWNER,(in this case root) and GROUP (also root).
The "-w" means remove write privilages, but as far as I can tell, that is the default anyway. So it's likely that command did not change any thing.
However if it was a "+w" then it made the folder open to be added too and deleted from by any user.
Wiz Kid

Re: Is #chmod o-w /usr safe?

Post by Wiz Kid »

I found i used "-w" after I looked at the log so everything seems to check out. Here's the result. Thanks for your time, much appreciated.

Code: Select all

abc@pc ~ $ cd /
abc@pc / $ ls -l
total 104
drwxr-xr-x   2 root root 12288 Oct 20 19:49 bin
drwxr-xr-x   3 root root  4096 Oct 20 19:59 boot
drwxr-xr-x  15 root root  4280 Oct 22 23:53 dev
drwxr-xr-x 138 root root 12288 Oct 23 01:23 etc
drwxr-xr-x   3 root root  4096 Sep 12 21:22 home
lrwxrwxrwx   1 root root    32 Sep 12 21:24 initrd.img -> boot/initrd.img-3.2.0-23-generic
lrwxrwxrwx   1 root root    33 Sep 12 21:14 initrd.img.old -> /boot/initrd.img-3.2.0-23-generic
drwxr-xr-x  24 root root  4096 Oct 20 19:49 lib
drwxr-xr-x   2 root root  4096 Oct 20 19:49 lib64
drwx------   2 root root 16384 Sep 12 21:13 lost+found
drwxr-xr-x   3 root root  4096 Oct 23 01:23 media
drwxr-xr-x   2 root root  4096 Apr 19  2012 mnt
drwxr-xr-x   7 root root  4096 Sep 13 02:06 opt
dr-xr-xr-x 158 root root     0 Oct 22 23:52 proc
drwx------  13 root root  4096 Sep 13 02:01 root
drwxr-xr-x  24 root root   820 Oct 22 23:54 run
drwxr-xr-x   2 root root  4096 Oct 20 19:56 sbin
drwxr-xr-x   2 root root  4096 Mar  5  2012 selinux
drwxr-xr-x   2 root root  4096 Apr 23  2012 srv
drwxr-xr-x  13 root root     0 Oct 22 23:52 sys
drwxrwxrwt  15 root root 12288 Oct 23 01:17 tmp
drwxr-xr-x  10 root root  4096 Apr 23  2012 usr
drwxr-xr-x  12 root root  4096 Oct 22 23:49 var
lrwxrwxrwx   1 root root    29 Sep 12 21:24 vmlinuz -> boot/vmlinuz-3.2.0-23-generic
Locked

Return to “Scripts & Bash”