Difference between using "chmod a+x" and "chmod 755" [closed] - linux

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
This may sound silly, but I have a file/ script that need to run and in order to do it I must change it to become executable. I would want to use either chmod a+x or chmod 755. But is there a difference between using chmod a+x and chmod 755?

chmod a+x modifies the argument's mode while chmod 755 sets it. Try both variants on something that has full or no permissions and you will notice the difference.

Yes - different
chmod a+x will add the exec bits to the file but will not touch other bits. For example file might be still unreadable to others and group.
chmod 755 will always make the file with perms 755 no matter what initial permissions were.
This may or may not matter for your script.

Indeed there is.
chmod a+x is relative to the current state and just sets the x flag. So a 640 file becomes 751 (or 750?), a 644 file becomes 755.
chmod 755, however, sets the mask as written: rwxr-xr-x, no matter how it was before. It is equivalent to chmod u=rwx,go=rx.

Related

Run applications with bash from Linux Mint [closed]

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 4 years ago.
Improve this question
I started learning Bash on Mint Linux. The thing is I want to know how to open and execute programs. I have a test.sh in my junk directory so that I can mess around but when ever I type in gnome-open test.sh it just opens the file and not actually run it. In the test.sh file I have echo hi in there so that I can see that it worked and I gave the file the permissions for it to be an executable file so it should execute.
You need to do two things:
Give the file execution permission (+x)
Execute the file
First you give the file permission no 755:
chmod 755 test.sh
Then you start it:
./test.sh
The dotslash means "current directory", it's like saying c:\file.bat if \ is the current directory. You need that because the current dir (called PWD) is not in your PATH variable which means that you either need to specify the complete path, eg. /users/user/file.sh or using the dot which is a shortcut for the current directory.
The file permission number 755 means:
owner: 7 (read, write, exec)
group: 5 (read, exec)
other: 5 (read, exec)
If you want to be the only one to be able to even open the file you may specify 700 instead. There are plenty of combinations, but 755 is most commonly used for scripts.
edit:
I forgot to mention that you need the dotslash everytime you run the script, but you only need to issue the chmod command once for every file.

Changed /usr file permissions to 0744 with sudo chmod command [closed]

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 6 years ago.
Improve this question
I had a brilliant idea to change my /usr file permissions to 0744 using 'sudo chmod 0744 /usr' while I was trying to install a program. So now I can't access any of my files, my home directory 'home/username' doesn't exist apparently (which isn't true), and all commands that are located in the /usr/bin folder are 'do not exist', which also isn't true.
I think the reason for the commands not existing is because I don't have write/execute permissions on the /usr/bin folder (owned by root), but I don't know why my home folder 'does not exist'.
My question is what exactly have I done, and how do I fix it, if possible?
As a side note, the computer is now having a problem when I try to turn it on. It immediately goes to a blinking cursor (top left) and black screen, but I can ssh into the machine. Finally, I don't have access to the root user or a root shell on this machine.
Solved:
So what happens when you run a command like sudo chmod 744 /usr is that all users on the network get locked out of the home folders as well as making it impossible for the computer to boot (hence the black screen with a blinking cursor). Also, more technically, your root file system (/dev/sda1 for me) becomes read-only.
Since you can't boot the computer, you need to go into single user mode from the grub menu. Next, run the command mount -o remount, rw /dev/(your root file system, possibly sda1). This will remount your root file system as read only. Then, run the command chmod 755 /usr. This will of course change the file permissions to read,write, and execute for the owner of the files and read/execute for group and world users.
You need to login as root, or boot the computer into single-user mode, and then execute:
chmod 755 /usr
You won't be able to do this with sudo because that command is in /usr, and without execute permission you can't access anything in it.

Linux - I ve chmoded all my server [closed]

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

I stupidly ran "chmod 400 chmod" and now it appears forever broken [closed]

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.

Will the program installed in a folder function properly if I remove the write permission in linux? [closed]

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.

Resources