How to avoid bunch of "[oh-my-zsh]" messages showing whenever I open iterm terminal? - zsh

Whenever I start my iterm terminal. I always get this message followed by prompt on my terminal.
Last login: Fri May 1 21:33:59 on ttys001
[oh-my-zsh] plugin 'zsh-syntax-highlighting' not found
[oh-my-zsh] plugin 'zsh-autosuggestions' not found
[oh-my-zsh] Insecure completion-dependent directories detected:
drwxrwxr-x 7 david admin 224 Apr 30 22:22 /usr/local/share/zsh
drwxrwxr-x 6 david admin 192 Apr 30 23:30 /usr/local/share/zsh/site-functions
[oh-my-zsh] For safety, we will not load completions from these directories until
[oh-my-zsh] you fix their permissions and ownership and restart zsh.
[oh-my-zsh] See the above list for directories with group or other writability.
[oh-my-zsh] To fix your permissions you can do so by disabling
[oh-my-zsh] the write permission of "group" and "others" and making sure that the
[oh-my-zsh] owner of these directories is either root or your current user.
[oh-my-zsh] The following command may help:
[oh-my-zsh] compaudit | xargs chmod g-w,o-w
[oh-my-zsh] If the above didn't help or you want to skip the verification of
[oh-my-zsh] insecure directories you can set the variable ZSH_DISABLE_COMPFIX to
[oh-my-zsh] "true" before oh-my-zsh is sourced in your zshrc file.
~
➜
What can I do so that it doesn't show all these above [oh-my-zsh] messages and I can go to direct prompt? Is there anything wrong I did while setting up [oh-my-zsh]?

It looks like you're trying to use plugins that are not installed. See the following documentation on how to install them:
zsh-syntax-highlighting
zsh-autosuggestions
(basically you want to clone the repos into $ZSH_CUSTOM/plugins and source them in your .zshrc, but see the documentation of each for actual commands to use. NOTE: zsh-syntax-highlighting must be the last plugin sourced.)
The other part of your question is answered in your terminal output:
To fix your permissions you can do so by disabling the write permission of "group" and "others" and making sure that the owner of these directories is either root or your current user.
It looks like the owner is already your current user, however your permissions are rwxrwxr-x, which are read, write, execute for users and group, and read, execute for others. From the warning message you should remove the write permission from group:
sudo chmod 755 zsh
now when you ls -l you should see rwxr-xr-x for that directory.
Do the same for the /usr/local/share/zsh/site-functions directory.
The warning message even gives you an alternative, suggesting you place the following in your ~/.zshrc file and restart zsh:
ZSH_DISABLE_COMPFIX="true"

Suggesting you place the following in your ~/.zshrc file and restart zsh:
ZSH_DISABLE_COMPFIX="true"

Put this on the top .zshrc file. It works for me.
ZSH_DISABLE_COMPFIX="true"

Related

Inaccessible folder when using Google Drive via terminal

I access my Google Drive via the terminal using gdfuse. There is a directory that exists, but I can't seem to access via the terminal:
I have a directory called 'papers'. Within that I want to access 'instructions'. When I do ls -ltr I see:
?????????? ? ? ? ? ? instructions
drwxrwxr-x 2 user user 4096 Jun 12 2017 my_docs
-rw-rw-r-- 1 user user 3923 Jul 25 2017 bs237-procedure.txt
with the word instructions appearing in red. And if I try to cd instructions I am told bash: cd: instructions: No such file or directory.
However if I use a browser to go into my Google Drive, I can access the directory 'instructions' and the files within it no problem.
I was searching and I reached this answer, hope it works for you!
To read a file, its read permission needs to be set. However, to read a directory and the listing of its files, both the read and the execute permissions need to be set. If they aren't, you get weird errors like the ones you're experiencing.
To set the read permission on files and the read and execute permissions on directories recursively, use this command:
chmod -R a+rX directoryname
and link to that page: https://askubuntu.com/questions/243999/why-do-question-mark-characters-appear-when-changing-the-permissions-of-director
edit : you can change the folder name, again I saw this on the internet and it seems to work!

Symbolic link is getting the permission error

I'm trying to get the symbolic link from other user.
My file is located in /home/serviceA/logs/a.txt And I want to create a symbolic link to /home/centos/logs/a.txt.
Here is my command I ran as root user:
ln -s /home/serviceA/logs/a.txt /home/centos/logs/a.txt
I see the red color of filename. And I still get the permission denied error
The error is lrwxrwxrwx 1 root root 47 Feb 12 01:49 /home/centos/logs/a.txt -> /home/serviceA/logs/a.txt
Eventually, I want to forward the /home/centos/logs/a.txt log file to the Splunk.
Why am I getting the permission error after creating the symbolic link? And how do I fix it? (chmod 777 didn't help)
Unfortunately, that isn't how symlinks work on Linux systems. You can't create a symlink to a file, then change the permissions on the symlink and have it change the permissions of the actual file. Think of the security issues with this approach!
If you want Splunk to be able to monitor /home/serviceA/logs/a.txt, you will need to either:
change the file to be world readable (chmod a+r /home/serviceA/logs/a.txt), OR
add splunk (assuming Splunk is running as user splunk) to the group that owns the file, and make the file group readable (chmod g+r /home/serviceA/logs/a.txt), OR
run Splunk as root, BUT THIS IS VERY BAD, DO NOT DO THIS IN PRODUCTION, ONLY DO THIS FOR TESTING, AND EVEN THEN, ITS VERY BAD

Setting permissions to WordPress to install plugins is preventing access through SSH

I have read several ways to solve the problem of permissions in WordPress to install themes and plugins from the WordPress administration.
As I understand the problem is that the owner of the folder where WordPress is installed must be the user who manages the web server (read postdata). In my case with Apache and AWS, www-data.
However, by changing the owner to www-data (even just changing the group to this user), I lose SSH access to the server. In this case I had to ask the administrator of the entire server to access from its user and restore the owner and permissions of the folder.
I am using Amazon Web Services with Ubuntu 16.0.4 LTS where I have access to a main user and the installation of WordPress is located at the root of the user, i.e. /home/myuser/
I am accessing via SSH with a .pem key and with myuser#publicdns
What can I do?
Thank you so much.
PD: WordPress in this guide says that the owner always has to be the ftp web server owner (i.e. myuser) and never the webserver, I agree.
I hate having to answer my own question but maybe I can help others solve problems easily and fast. This is what worked for me:
BEFORE DOING ALL OF THIS YOU SHOULD TAKE NOTE OF ALL PERMISSIONS, OWNERS AND GROUPS OF ALL THE FOLDERS & FILES WE ARE CHANGING HERE BECAUSE YOUR WEBSITE MAY FAIL AFTER CHANGING THESE SETTINGS. ALL HOSTS HAVE DIFFERENT CONFIGURATIONS.
As long as you don't exit the session, you may be able to return all the changes you have made with sudo privileges.
If your WordPress installation is in the root folder of the user, eg: /home/myuser/
Take note of permissions, owners and groups:
With ls command and the -a -l flags you can see all files using long listing format. Do this being in /home and /home/youruser/ paths.
cd /home
ls -al
cd /home/youruser
ls -al
Copy the output and save it in some text file.
Prevent losing SSH access:
The owner of the folder must be the user you are accessing with.
sudo chown youruser /home/youruser/
I also have set the group of the folder myuser.
sudo chgrp youruser /home/youruser/
Set the permissions of this folder with 751 (I think the important thing here is that the owner has full access)
sudo chmod 751 /home/youruser/
The permissions for the hidden folder .ssh must be 700 for top folder, 600 for files inside the folder and the owner & group must be youruser
sudo chmod 700 ~/.ssh/
sudo chmod 600 ~/.ssh/*
sudo chown -R youruser ~/.ssh/
sudo chgrp -R youruser ~/.ssh/
Solve Plugins & Theme installation problems:
I'm still unsure if this solution is right for site security. However, I think you can apply this fix and then return the changes. The website should run smoothly in both cases.
I have changed permissions for folders and files via sftp in Nautilus. If you are using .pem key remember to add the key using ssh-add path/to/your/key.pem
then connect to the server sftp://youruser#yourpublicdns
Make multiple click in folders wp-content, wp-admin, wp-includes and do Right click -> Properties (or Ctrl + I), change to permission tab and click in the "Apply permissions to Enclosed files" button on the bottom of the window, set:
Files
Owner: Read and Write
Group: Read only
Others: Read only
Folders
Owner: Create and delete files.
Access to files.
Access to files.
This will apply the changes to files and folders inside these three folders selected. Depending on the speed of your internet and how much files do you have, this may take some minutes to finish.
Make multiple click in remaining files and do Right click -> Properties (or Ctrl + I), change to permission tab and set
Owner: Read and Write
Group: Read and Write
Others: Only Read
AND LAST
Change the owner and the group of all the WordPress installation files, i.e. all the files inside /home/youruser
sudo chown -R www-data wp*
sudo chgrp -R www-data wp*
This make changes for all the files that start with the "wp" word recursively. To remaining files, I have made the changes manually. There are better ways like find command but that changed hidden folders too so I decided to do manually.
Apply the corresponding changes to files to the .htaccess as well.
NOTE: Test your website. Access to it, access to your WordPress admin, try installing plugins and themes, open another terminal (DON'T CLOSE the one you were writing the commands) and try to SSH into your webserver. If you have problems use the backup and revert the process.
Hope this helps.

WordPress file permissions on CentOS7 requiring sudo

I'm running WordPress on my VPS with CentOS 7 LAMP stack.I've followed this guide to set permissions, i.e. I've run
sudo chown apache:apache -R *
to ensure that my wordpress directory is owned by apache:apache.
I've also set WordPress directory and file permissions with these commands:
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
(I had to prefix the above commands with sudo)
Normally I manage the server by logging in through SSH using myuser, where myuser belongs to the apache group and the wheel group.
I have 3 problems:
Any file CRUD command in the WordPress directory still requires me to prefix the command with sudo, or else I get a permission error. Since myuser belongs to apache and apache owns the directory, I'm confused as to why I still need to prefix the commands with sudo.
Similar to problem 1, any git command such as a git pull requires me to prefix the command with sudo or else I get a permission error.
When I try to automatically update theme files from my WordPress dashboard web interface, I get permission errors. Interestingly, I'm able to install/update plugins via the WordPress dashboard without any permissions errors.
Any ideas on what I'm missing?
Look at:What does mode_t 0644 mean?
644 means:
* (owning) User: read & write
* Group: read
* Other: read
CRUD is a write command, so you're not allowed to do that. Either you change to 664 or keep using sudo. Basically any writing procedure on the file system would not be allowed without sudo since your user is not the owner (event though he is in the group).
#fortuneRice, CentOS7 features selinux enabled by default, which is often the cause of many hard-to-understand file permission errors.
I would suggest the following:
Edit /etc/sysconfig/selinux
Change SELINUX=permissive (or whatever SELINUX is currently set to in the file) to SELINUX=disabled
Reboot your server (not just the apache web server, but the whole machine)
Disabling SELINUX completely is not a good idea, therefore if this procedure works, you should re-enable SELINUX and fix its configuration.
Configuring SELINUX can be a difficult task, so I suggest you read up on google how to do that :)
chown -R -f user:apache /path of the directory
I also faced that issue and solved this problem by changing the PHP handler.
it is important to use PHP Handler that will run as the file owner.
After I installed HTTP2 and another few features on the way, I changed the PHP handler.
I am running WHM/CPanel on my VPS, and I fixed my issue following these steps:
Under WHM > Software > EasyApache 4 > Customize
Look for the: mod_suphp under the Apache Modules tab and make sure it is enabled, and if you just turned it on to install, follow step two.
Go to the Review tab and click the Provision button to save.
Under Whm > Software > MultiPHP Manager look for PHP Handlers tab.
Choose suphp as the handler for the current PHP version.
That's it. It was the PHP handler.
Edit: I notice that suphp had a conflict with one of my user uploads directories that I am adding dynamically to images a watermark. It seems the suphp handler had permission to upload but doesn't show the pictures.
I also tried the lsapi for the PHP Handler, and it seems to work correctly with the file's permissions and attaching via the .htaccess file watermarks for images.

Fatal error: cannot mkdir R_TempDir

When attempting to run R, I get this error:
Fatal error: cannot mkdir R_TempDir
I found two possible fixes for this problem by googling around. The first was to ensure my tmp directory didn't contain a load of subdirectories - it doesn't and it's virtually empty. The second fix was to ensure that TMP, TMPDIR, and R_USER in my environment weren't set to non-existent paths - I didn't even have these set. Therefore, I created a tmp directory in my home directory and added it's path to TMP in my environment. I was able to run R once and then I got the fatal error again. Nothing was in the TMP directory that I set in my environment. Does anyone know what else I can try? Thanks.
Dirk is right, but misses a point: If /tmp is full, you can't create subdirectories there. Try
df /tmp
I just hit this on a shared server, where /tmp is mounted on it's own partition, and is shared by many users. In this particular case, you can't really see who's fault it is, because permissions restrict you seeing who is filling up the tmp partition. Basically have to ask the sys admins to figure it out.
Your default temporary directory appears to have the wrong permissions. Here I have
$ ls -ld /tmp
drwxrwxrwt 22 root root 4096 2011-06-10 09:17 /tmp
The key part is 'everybody' can read or write. You need that too. It certainly can contain subdirectories.
Are you running something like AppArmor or SE Linux?
Edit 2011-07-21: As someone just deemed it necessary to downvote this answer -- help(tempfile) is very clear on what values tmpdir (the default directory for temporary files or directories) tries:
By default, 'tmpdir' will be the directory given by 'tempdir()'. This
will be a subdirectory of the temporary directory found by the
following rule. The environment variables 'TMPDIR', 'TMP' and 'TEMP'
are checked in turn and the first found which points to a writable
directory is used: if none succeeds '/tmp' is used.
So my money is on checking those three environment variables. But AppArmor and SELinux have shown to be an issue too on some distributions.
Go to your user directory and create a file called .Renviron and add the following line, save it and reopen RStudio or Rgui or Rterm
TMP = '<path to folder where Everyone has full control>'
This worked with me on Windows 7
If you are running one of the rocker docker images (e.g., rocker/verse), you need to map a local directory to the /tmp directory in the container. For example,
docker run --rm -v ${PWD}/tmp:/tmp -p 8787:8787 -e PASSWORD=password rocker/verse:4.0.4
where ${PWD} for me is ~/devProjs/r, and I created a /tmp directory inside it, so that the container's /tmp is mapped to my ~/devProjs/r/tmp directory.
Just had this issue and finally solved it. Simply a windows permission issue. Go to environment variables and find the location of the temp folders. Then right click on the folder > properties > security > advanced > change everyone to full control > tick "replace all child object permission entries with inheritable permission entries from this object" > Ok > ok.
This will also happen when your computer is completely, utterly out of space. Currently, my Mac has 0 kb free and it's causing this error. Freeing up some space solved the problem.
Check for the user account with which you are launching the RStudio with. Now u check the TMP(System Environment variable) for its location. If the user who is launching RStudio has Write access for those directories you will not face this issue. Being said that you are facing this issue, all you have to do is to change the permissions for that user to have write access on those directories.
Running R on CentOS system and had the same issue. I had to remove all R folders from the tmp directory. Usually all R folders will be in the form of /tmp/Rtmp*****
so i tried to delete the folders from /tmp by running the below.
CD into /tmp directory and run rm -rf Rtmp*
R shell Worked for me afterwards
I had this issue, solution was slightly different. I run R on a linux server - it turned out for me R had made a whole load of tempdirs when running jobs with cron that had hung and not been cleaned up, clogging up the root /tmp directory with ~300 RtmpXXXXXX folders.
Using terminal access, I navigated to the /tmp folder did a recursive find/rm - deleting all of them using this command:
find . -type d -name 'Rtmp*' -exec rm -r -v {} \;
After this, Rstudio took a while to load up, but was once again happy and my scripts began to run again.
You will need the appropriate admin rights for this solution. And always be careful when running rm -r, especially with a find command, as it's easy to remove things unexpectedly.
When it comes to deleting tmp files, make sure that the tmp files are in the server or in local.
If its in the remote, 1st check for the df /tmp in the server or in the remote to see who uses more storage.
Then use rm(file_name)` to remove the files which cause the blocking.
If its in the remote, then use rm /tmp/(file_name)..
MOreover, you can also refer to https://support.rstudio.com/hc/en-us/articles/218730228-Resetting-a-user-s-state-on-RStudio-Server

Resources