Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have made a big mistake in a wrong command and ended up chmoding 777 all my server.
Result is no service want to start because of writable files.
Is there a way to fix this like a default restore without loosing my database/files?
PS: I m on centos 64 bit
PS2 I can t access ssh on my server but I still have webmin access so I can execute command from it
Reinstalling is probably the only way to be sure... but google shows
google: rpm set file permissions
http://www.cyberciti.biz/tips/reset-rhel-centos-fedora-package-file-permission.html
RPM syntax to fix permission
To set permissions of files in a package, enter:
rpm --setperms {packagename}
Reset the permissions of the all installed RPM packages
and
You need to use combination of rpm and a shell for loop command as follows:
for p in $(rpm -qa); do rpm --setperms $p; done
That should fix a lot. ... but only files from a package. Other data... search for files with mode 777 and figure out what you need. For most maybe chmod o-w FILE would work. It's risky, it doesn't restore the permissions, but only changes them.
find / -perm -777 -exec chmod o-w {} \; # There are faster ways using xargs
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to move/copy a file from the Documents directory into /etc/bind I tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/etc/bind/
I also tried:
sudo mv ~/Documents/Config_Files/db.example.lan /path/to/~//etc/bind/
But also got the error: "No such file or directory"
I am probably being dumb but I double checked spelling capitilisation and everything is correct but still won't come up as a directory.
I can't guide you much but, as you can see we use 'sudo mv' and this means we tell root to move it and you type '~' which means home directory...
So if you type:
sudo mv ~/Documents
this means
sudo mv /root/Documents
instead of
sudo mv /home/<xyz>/Documents
Try to give proper path and let me know if it works.!
example:
sudo mv /home/<username>/Documents/Config_Files/db.example.lan /etc/bind/
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 7 years ago.
Improve this question
I just gotten a Raspberry Pi for Christmas and I wanted to delete some built in programs because I wanted to make a Linux server for home use. So far I had to do this all the time using the terminal because to delete the files, you had to use root.
rm ./files/*
rmdir files
Is there any way I can use rmdir command when there are files in it?
rm -rf files will remove the files directory and all subdirectories and not prompt you with questions about file permissions.
Sure just recursive delete :)
rm -r files
In your terminal, change directories to the one in the hierarchy just above the directory in question. Then:
$mv ./dir_to_del/* .; rmdir ./dir_to_del
This will move all the files out of the directory you want to delete, and then delete the now-empty folder.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Hi i worked on Linux server , and was running this command mv matter/*/* .
but instead i have typed this mv matter /*/* .
because of which some errors starts coming on the screen , and then i was not able to login and when we reboot the server its not coming up.
so can you please tell me what this command has done mv matter /*/* .
You can find out for yourself by inserting an echo at the beginning of the command line:
echo mv matter /*/* .
The expanded command looks like this:
mv matter /bin/ash /bin/bash /bin/echo /bin/false [...] /home/yourname [...] .
All files and directories from the top-level directories (echo /*/) have been moved to this one directory where you executed that command. It's hard to separate them from there, but you can try using a rescue CD:
move all executable files to /bin
make /sbin a symlink to /bin
move all files that look like configuration files to /etc
But since you couldn't find out for yourself what the mv command was doing exactly, you should rather ask someone who knows to fix it for you. It's a lot of work, though.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I'm "hacking" an ARM-base quadcopter running a stripped down Linux as part of a class assignment, and after getting into it using telnet and getting access to the bash terminal, and then messing around the file system I wanted to see what commands were available and how I could mess with it. I ran "chmod 400 chmod" and now I can't change it back, as when I run "chmod 777 chmod" I get "Permission Denied". Is there a command line fix for this? Or do I need some kind of factory reset to get chmod back? And yes I realized how stupid I am for having done this. Thanks!
If you have perl, you can do:
perl -e 'chmod(0755, "chmod")'
As suggested here: https://unix.stackexchange.com/questions/77852/how-to-recover-from-a-chmod-r-000-bin you could try using sudo perl -e 'chmod 0755, "/bin/chmod"' to fix the permissions on the file.
I tried this myself just now by copying /bin/chmod to ~/chmod, running ~/chmod 400 ~/chmod then attempting to use ~/chmod again. I received a permission denied error as expected. I then used the perl trick such that perl -e 'chmod 0755, "~/chmod"' and was able to once again use ~/chmod.
I hope this helps.
Maybe it's possible to copy another chmod binary (with executable rights) to the messed Linux and with that chmod the messed up chmod binary. eg
/path/to/the/copied/chmod 777 /path/to/the/old/chmod.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I have a user account on a cluster( a server), and can only install program like python on the home folder. In case I might accidentally delete the bin, lib, share,include folders coming with the installation of python on the home folder. I change the permissions of the above folder like this
chmod -w folder
but I am worried when the program need to write/delete some files of the folders, it might not function because the removal of write permission. Am I right? or I the run, including write files in the folder, of a program have permissions different than the permission of user.
BTW, is there a way to hide the folders without changing the names?
Wouldn't this stop python from running all together? For example:
$ cd ~
$ mkdir -p python/bin/
$ echo "echo 'hi'" > python/bin/python
$ python/bin/python
hi
$ chmod -x python
$ python/bin/python
bash: python/bin/python: Permission denied
As for your second question, no, there is no other way to selectively hide one folder without changing the name.
Edit: re-reading, I may have mis read what you were saying about the folders. You could always apply a "chmod -r folder" and nothing inside will be visable. This is not hiding it, just turning off permissions to view it.