mkdir -p ~ /.ssh returning Permission Denied - putty

This is the very first time for me to start deploying website using Linode. So now I am following a tutorial and after creating a user in server I am trying to create a folder using mkdir -p ~ /.ssh but I keep receiving mkdir: cannot create directory ‘/.ssh’: Permission denied
I am using Linode Ubintu and using Putty. So my question is why am I receiving this error and how do I fix it?

You have an extra space in your command:
mkdir -p ~ /.ssh
^ here
That space splits the path you wanted (~/.ssh) to the new 2 paths: ~ and /.ssh. Note that the second one is in the root (/) directory, which requires additional access rights to write in. But you most probably wanted to create .ssh in your home directory (to which the ~ leads), so proper command would be:
mkdir -p ~/.ssh

Related

Azure Bash - Permission denied when running . <(sudo wget -q -O - https://aka.ms/microservices-data-aspnet-core-setup)

I'm trying to setup my environment to learn azure from the Microsoft learning page https://learn.microsoft.com/en-us/learn/modules/microservices-data-aspnet-core/environment-setup
but when i run . <(sudo wget -q -O - https://aka.ms/microservices-data-aspnet-core-setup) to pull the repo and run the services, i get the error below
~/clouddrive/aspnet-learn/modules/microservices-data-aspnet-core/setup ~/clouddrive/aspnet-learn
~/clouddrive/aspnet-learn
bash: /home/username/clouddrive/aspnet-learn/src/deploy/k8s/quickstart.sh: Permission denied
bash: /home/username/clouddrive/aspnet-learn/src/deploy/k8s/create-acr.sh: Permission denied
cat: /home/username/clouddrive/aspnet-learn/deployment-urls.txt: No such file or directory
this used to work until it stopped working and I'm not sure what caused it to break or how to fix it.
I've tried deleting the 'Storage account' and the resources, but doesn't seem to work. also, when i delete the storage account and create a new one then try again, it seems to have the old data stored and i need to run a remove, so somehow this data isnt really being deleted when i delete the 'Storage account'
Before running this script, please remove or rename the existing /home/username/clouddrive/aspnet-learn/ directory as follows:
Remove: rm -r /home/username/clouddrive/aspnet-learn/
any idea what is wrong here, or how i can actually reset this to work like a new storage?
Note: I saw some solutions which say to start with sudo, for elevated permission, but didnt manage to get this to work
I have done the repro by following the given document
Able to deploy a modified version of the eShopOnContainers reference app
Again I executed the same command ,
. <(wget -q -O - https://aka.ms/microservices-data-aspnet-core-setup)
got the same error which you have got
If we try to run the deploy script without cleaning the already created resource/app,will get the above error.
If you want to re-run the setup script, run the below command first to clean the resource
cd ~ && \
rm -rf ~/clouddrive/aspnet-learn && \
az group delete --name eshop-learn-rg --yes
OR
Remove: rm -r /home/username/clouddrive/aspnet-learn/
Rename: mv /home/username/clouddrive/aspnet-learn/ ~/clouddrive/new-name-here/
The above command removes or renames the existing /home/username/clouddrive/aspnet-learn/ directory
Now you can run the script again

GCP SDK changing cloud directories from local terminal

I'm trying to follow this tutorial. It seems that if I open a "cloud shell" in the browser, I can execute commands such as cd <cloud path> without any issues. However, when I try to do so from my laptop terminal I run into issues:
(base) user ~ % gsutil ls
gs://my_project/
(base) user ~ % cd gs://my_project/
cd: no such file or directory: gs://my_project/
(base) user ~ % gsutil cd gs://my_project/
CommandException: Invalid command "cd".
(base) user ~ % gcloud cd gs://my_project/
ERROR: (gcloud) Invalid choice: 'cd'.
How should one change cloud directories from a local terminal, using gcloud SDK?
The program gsutil does not support the concept of a current working directory. Objects are specified using the full path <protocol><bucket><object-name>.
If you install the package gcsfuse, you can mount a Google Cloud Storage bucket as a directory. Then you can use the Linux shell command cd to move around the bucket as a file system.
Cloud Storage FUSE
This article shows how to set up gcsfuse on Cloud Shell:
Unlimited persistent disk in google cloud shell

Read-only file system when attempting mkdir /root/.local/share on Mac with Putty

I am trying to start Bitnami AWS with Putty in mac, but when i start Auth in SSH with both Catalina and Big Sur i get this error:
(putty: 3637): Gtk-WARNING **: Attempting to set the permissions of `/Users/daniele/.local/share/recently-used.xbel ', but failed: No such file or directory
I tried to install the folder:
sudo mkdir -p /root/.local/share
I get this error:
mkdir: /root/.local/share: Read-only file system
As per the error message, we should create the folder at the following path:
/Users/daniele/.local/share/
And not:
/root/.local/share
Therefore, the correct command is:
mkdir -p /Users/Daniele/.local/share
Require the result in command: csrutil status
If result is enabled, you need to restart machine and press command + R, open the terminal in the recovery, so input csrutil diabled.
Restart, and check the status: csrutil status.
Here are two methods:
you are root.
sudo mount -uw /
so, you could mkdir or touch new file.
If you still can't read or write any, you maybe try this:
cd ~ # cd home directory
sudo vim /etc/synthetic.conf # create new file if this doesn't exist
In the conf files, add new line
data /User/xx/data # Notice: the space between this two strings is tab
Restart, and you will find a link named /data in the root.

FIle could not be opened in append mode: failed to open stream: Permission denied laradock

I'm setting up laradock (Setup for Multiple Projects) following the official documentation from the Laradock in my local machine.
After installation I installed the laravel through workspace container bash. I did configured the config file for the app in nginx/sites/ directory and in /etc/hosts file.
While visiting the development url I'm getting the following error message:
The stream or file "/var/www/laravel-api/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
This worked for me:
chown -R www-data:www-data "project foldername"
If you are still facing the issue even after changing the permission and owner of file, just check for the OS of you Linux server.
Login to your server
$ ssh user#server-ip
check your OS running on linux server
$ cat /etc/os-release
//output
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
If it is CentOS, you need to disable Security-Enhanced Linux (SELinux) if enabled.
Check for SELinux status
$ sestatus
If it is enabled, then
$ setenforce Permissive
Or
$ sudo setenforce 0
Have a good day!
you have to enter the workspace first by typing "docker-compose exec workspace bash"(without quotes)
To give a write permission to a single file,
chmod -R 777 /var/www/laravel-api/storage/logs/laravel.log
or
chmod -R 777 /var/www/laravel-api/storage/logs
or
sudo chmod -R 777 /var/www/laravel-api/storage/logs/laravel.log
when the same error appears but different folders or files, do the same thing only change the folder name
example :
chmod -R 777 /var/www/laravel-api/storage/logs
chmod -R 777 /var/www/laravel-api/storage/framework/views
chmod -R 777 /var/www/laravel-api/storage/framework/sessions
If you aren't running your application as root on your web server, then it wont have write access based on the permissions you've provided.
Checked from workspace container bash. storage/logs/ directory has drwxr-xr-x 2 root root 4096 Aug 1 07:37 logs
The error is complaining about permission denial for opening in append mode - it doesn't have permission to write to the file, only root does.
What you need to do is make your web server group the owner of the storage directory:
chown -R www-data:www-data /var/www/laravel-api/storage/
The www-data can be switched out for whatever group your web server is associated with.
To avoid completely repeating an amazing and complete answer, I recommend you give this answer a read:
How to set up file permissions for Laravel?
Give group write access to /storage/logs/
sudo chmod g+w storage/logs
You need to run the following command. It works for me:
step 1:
sudo chmod -R +rwX .
step 2:
sudo chown -R $(whoami) .

command mkdir -p returns: "mkdir: can't create directory '/drives/f/': Permission denied" when use full path on mobaxterm on Windows

Command:
mkdir -p /drives/f/_/cache
returns:
mkdir: can't create directory '/drives/f/': Permission denied
in MobaXterm on Windows.
mkdir -p cache
in /drives/f/_/ works fine.
Any workaround on this assuming I can't go with relative path here? I can't change permissions for /drives so I think there is the main problem. Maybe there is a solution in MobaXterm allowing to use full path without /drives at the beginning?
I used workaround changing:
/drives/f/_/cache
to:
f:/_/cache
by using command:
BASE_DIR=$(pwd | cut -f 3 -d '/'):/$(pwd | cut -f 4- -d '/')
and it works flawless in MobaXterm.

Resources