chmod interview questions
Top chmod frequently asked interview questions
Suppose I have a directory on Linux with a bunch of files and subdirectories. This is that root directory:
drwxr-xr-x 13 user1 group1 4096 May 7 15:58 apps
Now, I only want to alter the group portion of those permissions. I want to alter it in such a way that it exactly matches the owner portion. The result for that directory would be:
drwxrwxr-x 13 user1 group1 4096 May 7 15:58 apps
But, I want a script or command to do this automatically, not just for that directory but for every subdirectory and file recursively under it. Anyone know how?
Thanks.
Source: (StackOverflow)
On my web server, my file permissions are all over the place and I want to 'reset' everything back to how it originally was. I don't want any users to be able to come in and delete things off my web server! I just want them to be able to look at php pages etc.
What chmod should I use?
Source: (StackOverflow)
I'm working to set up Panda on an Amazon EC2 instance.
I set up my account and tools last night and had no problem using SSH to interact with my own personal instance, but right now I'm not being allowed permission into Panda's EC2 instance.
Getting Started with Panda
I'm getting the following error:
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Permissions 0644 for '~/.ec2/id_rsa-gsg-keypair' are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
I've chmoded my keypair to 600 in order to get into my personal instance last night, and experimented at length setting the permissions to 0 and even generating new key strings, but nothing seems to be working.
Any help at all would be a great help!
Hm, it seems as though unless permissions are set to 777 on the directory, the ec2-run-instances script is unable to find my keyfiles.
I'm new to SSH so I might be overlooking something.
Source: (StackOverflow)
I have a project in which I have to change the mode of files with chmod
to 777 while developing, but which should not change in the main repo.
Git picks up on chmod -R 777 .
and marks all files as changed. Is there a way to make Git ignore mode changes that have been made to files?
Source: (StackOverflow)
Is there a way to set chmod 755
for /opt/lampp/htdocs
and all of its content including subfolders and files? Also, if I create a new folder or file, how can the chmod of that automatically be set to 755?
This works, but only for this folder:
chmod 75 /opt/lampp/htdocs
Source: (StackOverflow)
I've had a look over here but didn't find any details on the best file permissions. I also took a look at some of WordPress's form's questions over here too but anybody that suggests 777 obviously needs a little lesson in security.
In short my question is this. What permissions should I have for the following:
- root folder storing all the WordPress content
- wp-admin
- wp-content
- wp-includes
and then all the files in each of those folders?
Source: (StackOverflow)
why doesn't this work I am trying to change all files to 644 abd all -d to 755:
find . -type f -exec chmod 644 {} ;
i get: find: missing argument to `-exec'
thanks
Source: (StackOverflow)
I have a web directory /www
and a folder in that directory called 'store'
.
Within 'store' are several files and folders. I want to give the folder 'store' and all files and folders within the 'store' folder all permissions.
How do I do this? I am guessing via .htaccess.
Source: (StackOverflow)
I noticed:
chmod -R a+x
adds execute permissions to all files, not just those who are currently executable.
Is there a way to add execute permissions only to those files who already have an execute set for the user permission?
Source: (StackOverflow)
Using chmod
, I do chmod +x *.sh
in the current directory but what if I want to change all files including files within subfolders that has an sh file extension?.
chmod +x -R *
will work but I need something more like chmod +x -R *.sh
Source: (StackOverflow)
I often read articles saying something along the lines of "chmod 777 is bad!"
I was wondering:
How do I become vulnerable when I execute 'chmod 777' on a file?
What is a real world example of this that I can reproduce?
Source: (StackOverflow)
I'm having an issue related to the Android ADB Shell. When I try to execute the command chmod he gives me a "Bad Mode". I don't get it why. I'm sure I'm executing under "su", as represented by the '#'. Anyone have any idea why this is happening, and how to make it work? Thanks in advance.
chmod o+rw /dev/ttyS1
Source: (StackOverflow)
I'm following the recent RailsCast on setting up PostgreSQL, but I'm unable to run the initdb /usr/local/var/postgres
command. Each time I run it, I get this error:
The files belonging to this database system will be owned by user "Construct".
This user must also own the server process.
The database cluster will be initialized with locale en_US.UTF-8.
The default database encoding has accordingly been set to UTF8.
The default text search configuration will be set to "english".
creating directory /usr/local/var/postgres ... initdb: could not create directory "/usr/local/var": Permission denied
Source: (StackOverflow)
I've got the opposite problem from
"How do I make Git ignore file mode (chmod) changes?"
I've got a file that I've changed executable permission on, but there are also
some text changes, and I want to commit the former but not the latter. Is this
possible with git?
(Actually, I've made some text changes I want to commit along with the
executable permission change, and others I don't want to commit)
Update: Unstaging the text changes to the file, and then doing git add -p
again and incorporating some of the text changes managed to get the mode change
into staging. (My git version is 1.5.4.3)
Source: (StackOverflow)
How do I use chmod with Node.js?
There is a method in the package fs
, which should do this, but I don't know what it takes as the second argument.
fs.chmod(path, mode, [callback])
Asynchronous chmod(2). No arguments other than a possible exception are given to the completion callback.
fs.chmodSync(path, mode)
Synchronous chmod(2).
(from the Node.js documentation)
If I do something like
fs.chmodSync('test', 0755);
nothing happens (the file isn't changed to that mode).
fs.chmodSync('test', '+x');
doesn't work either.
I'm working on a Windows machine btw.
Source: (StackOverflow)