How to undo "sudo chmod 777 /workspace" ubuntu - node.js

I have deployed node.js on aws server using putty. While giving permission to a file which I dont know how to give i used "sudo chmod 777 workspace/". and when i ran my file "index.js" it gives me encrypted data . then I used "sudo chmod 775 workspace/". After a little search i used "sudo chmod -777 workspace/" and then "sudo chmod -775 workspace/" After this when i tried to enter to enter in '/workspace' it gives error 'Permssion denied' so i used "sudo chmod 777 workspace/" again and it gave me access to '/workspace' But again when i ran my file it is encrypted. So now please tell me how to undo these two commands and give permission to file index.js. Please do not remove this question and help me find a solution.

try sudo chmod -R 777 ./workspace

Related

How to change directory permissions like made with 'sudo mkdir' in linux

I created the directory with "mkdir" command, after that I need to change permissions as if I made it with "sudo mkdir".
I've searched for the chmod command, but it doesn't seem to be what I'm looking for.
Is it possible to do this with a single command in terminal?
you can use the chown command to change the owner and group of the directory, and the chmod command to set the permissions.
sudo chown root:root /path/to/directory && sudo chmod 755 /path/to/directory

How to give permissions for specific commands in linux

I am new to linux. I have a build.sh file which consists of a lot of mkdir commands and some rm commands. But as I have installed this new in my VB, each time I run the .sh file, it says "Permission Denied for creating directory" and fails.
So is there any way that I grant directory privileges to all users.
Can anyone help me with this
Add "sudo" in the beginning of the directory creation command i.e
sudo mkdir dir_name
The issue might be with the directory in which the mkdir command is being run.
Use the command ll or ls -l to check the directory permissions.
If your directory doesn't have write privilege for the current user, you can run
chmod -R u+w /path/to/directory
This might require you to use sudo if permission is denied.
If you want to enable it for all users, run
chmod -R ugo+w /path/to/directory
Alternatively, a quick fix would be to run the build.sh file as root
sudo /path/to/build.sh
However, this approach is not advised unless you always run it as root

Tomcat not starting in linux ---permission denied to run startup.sh

I pasted tomcat folder in Linux machine. User is root . When I go to bin folder and execute ./startup.sh I'm getting an error:permission denied. [This is what I got]
How to rectify this issue.
give:
chmod -R 777 startup.sh
Then error will come as:Cannot find ./catalina.sh
then give:
chmod -R 777 catalina.sh
Tomcat will start.
the problem was because there was no permission for executing. u can see if permission is there or not by giving:
ls -l
As color of file name is white, I suppose file is not executable; try the following command
ls -l
It gives you file list with its permission. Try using command
chmod a+x startup.sh
If still permission denied. Try
sudo chmod a+x startup.sh
Then try using
./startup.sh
If still permission denied. Then try
sudo ./startup.sh
Hope it will be helpful.
Verify, that your filesystem with the new tomcat folder isn't mounted with "noexec". Please run a "ls -l", "file start.sh" and a "head start.sh" .
Tom
It is also worthwhile to check which bash you are using with
which bash
This is because you might see the error
Cannot find ./catalina.sh
when your bash is /usr/bin/bash but is working perfectly fine when bash is /usr/bash

Enable write permission for directory in Linux

I keep trying to move files from a directory on Linux- but I keep getting permission errors.
Initially I was told
sudo chmod -R r+w /directory/*
But this only applies it to the directory folder (and not the files inside)
Trick is- you need to "select all" to apply the file permissions to:
sudo chmod -R a+rwx,go-w /directory/
And that's it
Or you could do sudo chmod 777 /dir/
and that's just a simple way to do the answer stated above.

LINUX Permission issues

Can anyone help me in fixing the permission issues in Linux.
I am new to Linux and i am trying to run a script called buildAll.sh
by moving to that specific directory and i typed ./buildAll.sh the response i got was
./buildAll.sh: 16: ./buildAll.sh: ./buildJS.sh: Permission denied
i tried to run using sudo ./buildAll.sh , but that didn't work.
Then i tried with chmod -r 777 buildAll.sh and again i tried to run that script but no change.
I have a folder called build which has some dependency can be seen a folder with locked picture.
Can anyone help me to run the script without having the permission issues please
in line 16 your script seems to call buildJS.sh and the permissions OF THAT seem to be incorrect
You obviously have a pervasive permissions problem. Why don't you just start again, unpack the files into a new directory without using sudo or su, and then use chmod +x on the files that need to be executable?
sudo chmod +x buildAll.sh
Should do the trick
It seems by the error message the issue is with buildJS.sh. If buildJS.sh is not in your current directory (it might not be as buildAll.sh might be changing directories), find buildJS.sh and then:
chmod +x ${directory_where_found}/buildJS.sh
Since .sh files should have executable permissions by default you can do this:
cd $YOUR_DIRECTORY
find . -name '*.sh' -exec chmod +x {} \;
I tried with sudo chmod +x buildAll.sh
rm: cannot remove ‘build’: Permission denied
cp: cannot stat ‘./build/.svn’: Permission denied
cp: cannot stat ‘./build/compiler.jar’: Permission denied
cp: cannot stat ‘./build/buildJS.sh’: Permission denied
touch: setting times of ‘build’: Permission denied
./buildAll.sh: line 14: cd: build: Permission denied
./buildAll.sh: line 16: ./buildJS.sh: No such file or directory
You have given permission only to run your script. However, this doesn't mean that you have permission for all of instructions launched by the script. The error message is there to prove it ;) .

Resources