The programs ld.so and ld-linux.so* is Linux dynamic linker/loader.
It can find and load the shared libraries needed by a program, prepare the program to run, and then run it
Let us use the loader for loading a program which does not have executable permission
Default permission of chmod command provided below
Assume a scenario where chmod command lost its executable permission, like the below
It can find and load the shared libraries needed by a program, prepare the program to run, and then run it
Let us use the loader for loading a program which does not have executable permission
Default permission of chmod command provided below
[root@localhost ~]# ls -l /bin/chmodchmod has executable permission by default, hence chmod can be executed to change permission of other files in Linux system
-rwxr-xr-x 1 root root 58656 /bin/chmod
Assume a scenario where chmod command lost its executable permission, like the below
[root@localhost ~]# chmod -x /bin/chmod
[root@localhost ~]# ls -l /bin/chmod
-rw-r--r-- 1 root root 58656 Oct 30 2018 /bin/chmod
[root@localhost ~]#
The command available for changing file permission in linux system is chmod, now it has lost its executable permission
Since chmod command become non executable, then think about the way to provide or restore executable permission for chmod command.
Since chmod command become non executable, then think about the way to provide or restore executable permission for chmod command.
[root@localhost ~]# chmod +x /bin/chmod
-bash: /usr/bin/chmod: Permission denied
[root@localhost ~]# touch /tmp/testfile
[root@localhost ~]# chmod +x /tmp/testfile
-bash: /usr/bin/chmod: Permission denied
Solution:
Let us use Linux loader for loading and executing chmod command
[root@localhost ~]# /lib64/ld-linux-x86-64.so.2 /bin/chmod 755 /bin/chmod
[root@localhost ~]# ls -l /bin/chmod-rwxr-xr-x 1 root root 58656 /bin/chmod
Now the chmod command has got executable permission with the help linux loader for execution.
As chmod command became executable, now it can be used for changing file permissions
[root@localhost ~]# chmod +x /tmp/testfile[root@localhost ~]# ls -l /tmp/testfile-rwxr-xr-x 1 root root 0 Jun 3 10:32 /tmp/testfile
Linux loader dynamically finds and loads shared libraries needed by a program and runs the program even when the program do not have executable permission
2 Comments
Very interesting and it caught my attention.Bookmarking your article which will probably be my guide. Thank you very much.
ReplyDeleteby cloudi5
Web Design Company in Coimbatore
You've written a very useful article. This article provided me with some useful knowledge. Thank you for providing this information. Keep up the good work. Dynamic Packaging System Software
ReplyDelete