What if your Unix/Linux chmod file is canceled with the x attribute?

  

If one day your comd command on a Unix/Linux system is removed by someone for the x attribute (execution attribute), how do you recover it?

The following are some answers:

1) Reinstall. For Debian systems: 1 sudo apt-get install –reinstall coreutils

2) Use language-level chmod. Perl:perl-e ‘chmod 0755, “/bin/chmod”‘Python:python -c “import os;os.chmod(‘/bin/chmod’, 0755)”Node.js:require (“fs”).chmodSync(“/bin/chmod”, 0755); C program: 123456 #include #includevoid main(){chmod(“/bin/chmod”, 0000755);}

3) Use an existing executable file. 1234567 $cat – > chmod.cvoid main(){}^D

$cc chmod.c$cat /bin/chmod > a.out$./a.out 0755 /bin/chmod123 $cp true > new_chmod$cat /bin/chmod > new_chmod$./new_chmod 0755 /bin/chmod

4)Use the GNU tar command 12 $tar –mode 0755 -cf chmod.tar /bin /chmod$tar xvf chmod.tar1 tar –mode 755 -cvf – chmod |  Tar -xvf -

5)Use cpio (files 19 to 24 are file mode – http://4bxf.sl.pt)1234 echo chmod | Cpio -o | Perl -pe ‘s/^(.{21})…/${1}755/’ | Cpio -i -u

6)Use hardcore1 alias chmod=’/lib/ld-2.11.1.so ./chmod’

7)Use Emacs

Ctrl+xb > * scratch*(set-file-modes “/bin/chmod” (string-to-number “0755″ 8)) Ctrl+j

Well, quite powerful, but Why not use the install command? 12 install -m 755 /bin/chmod /tmp/chmodmv /tmp/chmod /bin/chmod

You, how about your method?

Copyright © Windows knowledge All Rights Reserved