There is also no Internet/Phone connection, hence you can't contact anyone for help either. The interviewer says "There are no interpreters on your machine.". You may reply again, "I'll set the execute bit from perl.". So you can't copy the chmod binary from other systems. "I will copy the chmod binary from other systems?", you might reply. So, how do you restore executable permission to chmod command in Linux? You are sitting in an interview panel and the interviewer just asked this question. So if the executable permission of chmod is removed, you can't assign the permissions to any programs, including the chmod command itself. The question is - What do you do if the executable permission of Chmod command is removed accidentally? As you may know, the chmod (stands for Change mode) command is used to set or change the access permissions of a file or directory in Unix-like systems. When you run this oneliner you might see a lot of “No such file or directory” errors, ignore it.I came across an interesting discussion thread on Twitter. Let’s see a practical example – Here is how to reset file ~]# for package in $(rpm -qa) do rpm -setperms $package doneĬhmod: cannot access `/etc/modprobe.d/nf': No such file or directoryĬhmod: cannot access `/etc/dev.d': No such file or directoryĬhmod: cannot access `/etc/scsi_id.config': No such file or directoryĬhmod: cannot access `/etc/udev/devices': No such file or directoryĬhmod: cannot access `/etc/udev/scripts': No such file or ~]#.Since we need to reset file permissions on the whole /var directory, we will run the following commands on all of the installed RPM packages: for package in $(rpm -qa) do rpm -setperms $package doneįor package in $(rpm -qa) do rpm -setugids $package done Starting sshd: /var/empty/sshd must be owned by root and not group or world-writable.Ĭommands to reset file permissions to it’s default state. 2 root root 4096 ~]# service sshd restart 2 root root 4096 Nov 8 10:02 tmpĭrwxrwxrwx. 1 root root 10 mail -> spool/mailĭrwxrwxrwx. 17 root root 4096 ~]# ll /var/ĭrwxrwxrwx. 3 root root 4096 Nov 29 11:07 tmpĭrwxrwxrwx. ![]() 2 root root 12288 Nov 8 10:00 sbinĭrwxr-xr-x 13 root root 0 Nov 29 11:07 sysĭrwxrwxrwt. This can cause quite some problems to linux services as we can see below: ~]# ll /ĭr-xr-xr-x. Let’s say, we made a mistake and chmod 777 whole /var directory. Reset File Permissions Let’s Reset File Permissions to default! By default, we mean the permissions set, when RPM package was installed – set the default RPM installation permissions of files and folders. Wondering how you could reset file permissions? Have you ever made a mistake and changed user and group ownership/permissions of the folder and all it’s subfolders? Well … it happens! □ Read this post and learn how to reset file permissions to default.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |