chmod cannot access to 'uploads/' :file or folder doesn't exist - linux

i did this
sudo chmod -R 775 uploads/
and got this
chmod cannot access to 'uploads/' :file or folder doesn't exist

Your command is syntactically correct. The reason why it is reporting file or folder doesn't exist will be that the file or folder doesn't exist.
As you are using a relative path, you may wish to ensure that the current directory when you type the command is the parent directory of where you expect the uploads directory to reside. Note in particular that sudo will run the chmod command from the existing current directory (for example, it would not change to the home directory of the root user merely because it is running the command as root).
If you wish to check whether uploads is a valid path relative to the current directory, then use the ls command (without command-line arguments) to list the contents of the current directory, and see whether uploads (case-sensitive) is mentioned in the output.

Related

How to recursively change permissions with backup file comparing permissions

So in my work i did a mistake and it change all the file permissions (file owner and group) recursively inside a folder. I have the backup of that folder. I'm working inside a nsf server and my idea is to copy the permissions of the backup directory to the directory where i did the mistake recursively. All the folders and files have the same name and i want to grab the permissions from each file/directory from the backup and copy the permissions to the original directory, recursively.
chown can be uded to change ownership of a file or firectort
chown -R root:user /dir
changes the file ownership to user
-R perform the command recursively in a directory
same for
chmod -R 600 /dir
then you specify your permission and ownership in your own format

Cannot create directory in tmp(overthewire bandit24)

I'm trying to solve bandit24 on overthe wire on ubuntu virtual machine.
I have already seen the solution.
But i have a problem,when i try to create a directory on tmp as bandit24#bandit i get this message:
Cannot create directory "name_of_directory": file exists.
If I try with find command there is only the "." directory and with ls I get the message:
Cannot open directory '.' : permission denied.
I also have tried with ls -l on tmp and I get the message:
Cannot open directory 'tmp': Permission denied
What else could I do?
What could be the problem?
Try to prepend sudo at your command. Seems you don't have permissions to read the /tmp directory, what is pretty weird.
Example that might works:
To list the /tmp contents:
sudo ls -l /tmp
To create the 'my_new_dir' inside /tmp:
sudo mkdir /tmp/my_new_dir
It means that there is a directory under /tmp/ with the same name that you specified. But since you did not create it (in this case, someone created with a different bandit user), you cannot view it. There is not read permission for bandit24 to access it.
Since /tmp/ is directory accessible for all user accounts, you cannot list the files/directories under it without the root permission. (Which means the root of the bandit machine has configured like that)
What you need to do
Try a random name. Create anything random under /tmp/. It will work.

How to copy files and give them permission of destination directory

I am copying files from source to location. The source is not owned by me and the permission for files at source is ----rwx---. The permission of files coped to destination directory which is owned by me is ----r-x---. The permission of destination directory is drwxrwsrwx. How do I have the files with same permission of destination directory. I tried "cp --no-preserve=all" but it did not work (still the same permission).
Try this:
cp --no-preserve=mode,ownership $backupfile $destination
Let me rephrase that to "How to preserve permissions of destination directory on copy?"
I can't take credit for the answer since I just combined a couple of answers I found on the wild. So here it comes.
Firstly
Permissions are generally not propagated by the directory that files are being copied into, rather new permissions are controlled by the user's umask. However when you copy a file from one location to another it's a bit of a special case where the user's umask is essentially ignored and the existing permissions on the file are preserved.
Which explains why you can't directly propagate the permissions of the src to the dst directory.
However, there is two-step workaround to this.
cp-metadata: Copy the attributes and only the attributes you want to preserve back to the source directory. Here is a quick script that can do this:
#!/bin/bash
# Filename: cp-metadata
myecho=echo
src_path="$1"
dst_path="$2"
find "$src_path" |
while read src_file; do
dst_file="$dst_path${src_file#$src_path}"
$myecho chmod --reference="$src_file" "$dst_file"
$myecho chown --reference="$src_file" "$dst_file"
$myecho touch --reference="$src_file" "$dst_file"
done
You can leave out the touch command if you don't want keep the timestamp.
Replace myecho=echo with myecho= to actually perform the commands.
Mind that this script should be run in sudo mode in order to be able
to run chown and chmod effectively
cp --preserve: After you have successfully run the first command
now it's time to copy the contents along with the attributes to the dst
directory.
--preserve[=ATTR_LIST]
preserve the specified attributes (default: mode,ownership,timestamps), if possible additional attributes: context, links, xattr, all
\cp -rfp $src_dir $dst_dir should do what you want.

How do I fix the uploading error in aptana studios: parent path doesn't exist

I have a quick question. I've been trying to upload my website to blue-host, but every time I try, it says that parent path doesn't exist, is there a way I can change the parent path so the uploads work
Thx,
willmonferno
This is likely due to file permissions, you don't have write access, try updating file owner or file permissions.
I'm guessing you on some type of linux system, so you either need a chown (change owner) shell command or a chmod command (change file permissions) on the parent folder
try:
sudo chmod -R 777 {YOUR_PARENT_FOLDER}
This will recursively change this and all other files and folders below it in the file tree to allow everything. I would change it once you're in a production environment.

Create a user level 777 directory inside root directory /

I need to put the Dropbox folder inside the root path, this way:
cd /Dropbox
I can't create first a normal folder because Dropbox automatically creates a Dropbox folder nested in it...
so it would result in this (like It does now)
cd /folder/Dropbox
What would be the problem if I give a "sudo chmod +w /"?
So I could initialize Dropbox inside the root path?
No problem if other files would be written in the / since there are no important files loaded in there, and anyway users wouldn't be allowed to write in the subfolder like /etc. Is that right?

Resources