How can i fix/restore linux permissions without reinstalling / deleting my files? - linux

I was trying to change permissons of a folder, and i typed in:
sudo chmod -R 777 /.
I believe it changed my whole system's permissons.
I can no longer connect using ssh/stfp to it.
How can i restore my system permissions without reinstalling / deleting any of my files?
I am using Ubuntu Server
The computer is 64 bit
The files / servers are working fine (HTTP, Games, ETC)

As per this link https://askubuntu.com/questions/508359/restore-default-system-file-folder-permessions you can restore the default system file/folder permissions in linux
and check with the Ubuntu version too.

Related

Linux - Permissions to Create Directory / Delete Directory and Files / Change Permission for an entire Drive

I need your help, in order to allow me, to create directories, delete files, save files in directories. Right now, I'm unable to do anything in this Drive "Ubuntu-Dados".
I've already tried a bunch varieties of commands, from this site, and including running Nautilus, "sudo chmod -R -v 777 *", and nothing is working. Below is the result of my attempt to this issue. I need access to do anything in this Drive. - I'm using Ubuntu 20.04

Can I delete the Matlab installation file in root user home directory

I just found Matlab (2016a) put a 2.5 Gb installation files that it fetched during the installation in the root home directory (Linux mint 18), under /root/Downloads/MathWorks. I guess it is probably because I use sudo for installation.
My question is:
Is it normal that program store information when user executes it with sudo?
Can I delete the file under /root/Downloads? (My limited Linux knowledge told me do not touch anything in the /root folder)
When you execute anything with su...do, you basically execute it 'as' root.
Mathworks uses the Download-Folder (which is in your case /root/Downloads - since you have executed the installer as root) for temporary data (According to https://de.mathworks.com/matlabcentral/answers/229835-is-the-mathworks-folder-necessary-to-run-properly?requestedDomain=www.mathworks.com).
So, yes. It seems like you can delete the folder.
Or just move it to MathWorks.bak and check if Mathworks still works properly. In case everything is working fine, you can delete MathWorks.bak.
A program can do anything when run as sudo and depends only on what the program is designed to do. sudo simply elevates the permissions when running a given command.
I would have thought that the installer would have downloaded everything to /tmp instead of /root/Downloads, but as long as you didn't select /root/Downloads as your installation directory for MATLAB and this is only the temporary download location you can certainly remove it after successfully installing MATLAB to a "typical" location such as /usr/local/MATLAB/R2016a.

Linux Mint: Bitnami Xampp access issue

I have installed Bitnami Xampp on linux mint, it is installed inside /opt/
The application is unable to access(Write/Read) files and hence not able to work on it.
Any Solution Please........
Thank You
It is simple access issue. So I need to give read write access to folder and file using chmod command:-
--$ sudo chmod -R 777 opt
I have to admit that I am don't really know Xampp but with the command you mentioned above you changed the the access rights for the top level directory /opt and thru using 777 you gave basically all rights to everbody using your system. If Xampp now tries to write something, it of course can because you gave it the rights (like to anyone else).
The -R option you used in the chmod-command above means, that you have changed the access rights for all subdirectories of /opt also (recursively).
I would recommend that you change this back to the original access rights for /opt and, if you need, just change the access rights for the directory where Xampp is placed. Then Xampp should also work because it can read an write in it's own subdirectory and there won't be any harm for or from other applications from /opt because they can't access /opt/Xampp and Xampp can't access their directories.
After the previous setting
--$ sudo chmod -R 777 opt Xampp is not working with following error
PhpMyAdmin “Wrong permissions on configuration file, should not be world writable!”
Then I followed PhpMyAdmin "Wrong permissions on configuration file, should not be world writable!" and now working fine...
Thank god it saved me from switching back to Windows. That I hate.....

File permission issues when developing with Windows / hosting with Unix

I am developing a website on my windows laptop, and I use Git for the version control.
When I add my files to Git, they are added under the mode 644. The problem is, on my Linux server, I need the files to be 775. So what I do is, every time I deploy, I have to run chmod 775 -R . on my linux server and then commit the mode changes.
This is really anoying, time consuming, and result in lot of stranges commits.
My question is, how can I make my IDE (PHPStorm) create the files direcly with mode 775? I know Windows does not use the same file permission system as UNIX, but there must be a way to set the files permissions on windows that translates to 775 in Linux?
I tried to use "chmod" command on windows using Cygwin or similar tools, with no luck, Git always saves the files as 644 when I commit on windows.
See: Updating file permissions only in git
In summary, git update-index --chmod should do what you need.

XAMPP or any other service tool in /opt? Security

I am developing with Xampp for Linux and Tomcat (similar to Xampp on Windows). Many programs like /IDEA, Tomcat and Xampp are recommended to be installed under /opt Now I have heard that it is not recommended to run services as root, but on Ubuntu (I am using this) unpacking any directory to /opt implies that it belongs to root owner and root group. This may be specific to Xampp as per the instructions on their Linux page:
Step 2: Installation After downloading simply type in the following commands:
Go to a Linux shell and login as the system administrator root:
su
Extract the downloaded archive file to /opt:
tar xvfz xampp-linux-1.8.1.tar.gz -C /opt
Warning: Please use only this command to install XAMPP. DON'T use any Microsoft Windows tools to extract the archive, it won't work.
Warning 2: already installed XAMPP versions get overwritten by this command.
That's all. XAMPP is now installed below the /opt/lampp directory.
* Step 3: Start To start XAMPP simply call this command:
/opt/lampp/lampp start
Placing it here implies that Apache must be run as root as one is only able to run it with sudo on Ubuntu.
This may be an issue specific to Ubuntu. Is it? Because Xampp is a development tool I posted this here as I am more likely to find an appropriate answer here from developers who use it on Ubuntu (and other Linux systems). I would appreciate any information on if the same problem occurs on other systems, I notice my production environment has Tomcat installed in /opt too, but belongs to tomcat: tomcat
The question here is how to get around this for all tools under /opt, because even though Xampp may not be the tool for my needs, I still want to place Tomcat under /opt to replicate my production environment and the same thing will surely happen unless this is just a Ubuntu issue?
Ubuntu and some other distributions differ to the general Linux principle where the account that you create upon install of the OS is added to specific groups that can be viewed with the following command:
groups username
You will notice that root is not amongst these. It is also not possible to log in or su to the root account. sudo is most likey a command that has been granted permission to be used from other accounts so I imagine the 'sudo' command has a file permission of 775 for user: root:root
Thus launching services from /opt' does not run them asroot`

Resources