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.
Related
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.
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 3 years ago.
Improve this question
I am trying to create a directory in my home directory on Linux using the mkdir command, but am getting a 'permission denied' error. I have recently installed Lubuntu on my laptop, and have the only user profile on the computer.
Here's what happened on my command line:
jdub#Snowball:~$ cd /home
jdub#Snowball:/home$ mkdir bin
mkdir: cannot create directory ‘bin’: Permission denied
jdub#Snowball:/home$
How do I gain access to this folder? I am trying to write a script and following a tutorial here: http://linuxcommand.org/wss0010.php
Thanks for your help!
As #kirbyfan64sos notes in a comment, /home is NOT your home directory (a.k.a. home folder):
The fact that /home is an absolute, literal path that has no user-specific component provides a clue.
While /home happens to be the parent directory of all user-specific home directories on Linux-based systems, you shouldn't even rely on that, given that this differs across platforms: for instance, the equivalent directory on macOS is /Users.
What all Unix platforms DO have in common are the following ways to navigate to / refer to your home directory:
Using cd with NO argument changes to your home dir., i.e., makes your home dir. the working directory.
e.g.: cd # changes to home dir; e.g., '/home/jdoe'
Unquoted ~ by itself / unquoted ~/ at the start of a path string represents your home dir. / a path starting at your home dir.; this is referred to as tilde expansion (see man bash)
e.g.: echo ~ # outputs, e.g., '/home/jdoe'
$HOME - as part of either unquoted or preferably a double-quoted string - refers to your home dir. HOME is a predefined, user-specific environment variable:
e.g.: cd "$HOME/tmp" # changes to your personal folder for temp. files
Thus, to create the desired folder, you could use:
mkdir "$HOME/bin" # same as: mkdir ~/bin
Note that most locations outside your home dir. require superuser (root user) privileges in order to create files or directories - that's why you ran into the Permission denied error.
you can try writing the command using 'sudo':
sudo mkdir DirName
Try running fuser command
[root#guest2 ~]# fuser -mv /home
USER PID ACCESS COMMAND
/home: root 2919 f.... automount
[root#guest2 ~]# kill -9 2919
autofs service is known to cause this issue.
You can use command
#service autofs stop
And try again.
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
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.
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.