How can I give highest and lowest permission to all sub folders and files including in a folder?
I used "chmod +x" for a certain file but I don't know how to do this for all folders and files which are in the folder.
The lock means that you don't have write access to the files in question. My guess is that you pulled your images off a cd or something, and that their ownerships/permissions are jumbled up. You may want to straighten things up. In a terminal:
$ cd /path/to/files/
$ su -c 'chown *.jpg'
$ "root's password"
$ chmod 644 *.jpg
I hope you'll enjoy Debian!
Related
Say that I have the folder /dir. Is there a command in bash that I can use so that after performing it, no one could create new files in /dir?
Edit: important to mention that after performing the command, there will be same permissions to the directory files as they were before. For example, if I have folder /dir with file a.txt in it - so after I use my desired command I cant create new files, but I can modify/delete a.txt if I want.
you could change the permission with chmod to only let people read the folders content.
chmod a-w /dir
Will remove all write permissions of all (ugo), but keep x (execute) and r (read) permissions intact.
Yes, it's pretty simple. Just chmod to read only. Here is a sample
chmod -R 0444 /path/to/your/dir/
Where the last 3 4's mean User-readonly, Group-readonly and others-readonly respectively.
I'm new to shell programming and I'm trying to create a simple script that gives me some infos on the status of the machine (i.e date, time, users logged in etc) on Scientific Linux 6 (I know it's old, but the department of my university runs on it so there's no escaping)
Basically I've created my script "sysinfo.sh"
#!/bin/sh
....
exit 0
as root user I want to move it so that I can be able to execute it anywhere and I thought the right way to do it was
sudo mv sysinfo.sh usr/local/bin
but I get the error message
mv: cannot move `sysinfo.sh' to `usr/local/bin': No such file or directory
then I looked for the PATH and it gives me
$ echo $PATH
/u/geo2/sw//System/tools/bin:/usr/bin:/bin
What is the right place to move my script?
Best practice for these kind of manipulation or learning is to have scripts in your $HOME/bin directory.
mkdir $HOME/bin
export PATH=$PATH:$HOME/bin
mv sysinfo.sh $HOME/bin
chmod +x $HOME/bin/sysinfo.sh
If you anyway want to move it to /usr/local/bin, why not do that with:
sudo mv sysinfo.sh /usr/local/bin
chmod +x /usr/local/bin/sysinfo.sh
chmod command will make the script executable.
from chmod man:
x -- The execute/search bits.
The command that you posted indicates that you were trying to use the absolute path for copying, but you missed a leading slash --
the directory should be /usr instead of usr.
Try
sudo mv sysinfo.sh /usr/local/bin
Note that unless an absolute path is specified, the shell looks for the path relative to the current working directory.
In this case, the shell was looking for the subdirectory usr under the current directory which was not found;
hence the error message.
Thank you very much!
In the end, I didn't realize that the directory /usr/local/bin wasn't in the PATH
So i just needed to
export PATH=$PATH:/usr/local/bin
sudo mv sysinfo.sh /usr/local/bin
:D
Thanks to a rashly typed mv command and my inexperience in installing LaTeX packages, I managed to move my user folder--let's call it /home/bob for the purposed of not revealing my name--somewhere else. I started a recovery terminal and found bob buried down in usr/share/texlive/texmf-dist/tex/latex.
I tried moving the folder back (going to usr/share/texlive/texmf-dist/tex/latex and running mv bob /home/, but I got the message
mv: cannot move 'bob' to '/home/bob': Read-only file system
I don't really know what else to do to fix this... Do I just use chmod and change the permissions or do I have to remount something? Since these are all my files, I'd rather ask and be sure than play around more and just make things worse.
EDIT: I tried chmod 777 bob but got the message
chmod: changing permissions of 'bob': Read-only file system
Also, mkdir /home/bob gave me a similar error (Read-only file system)
Use chmod
chmod 777 bob
mv bob/ /home
or You can create a folder with similar name
mkdir /home/bob
To delete a file in Linux,
What minimal permissions do we need to set on it?
What minimal permissions do we need to set on its parent directory?
You need to have x-permissions and w-permissions on the directory (and of course x-permissions on all parents), that is all.
mkdir foo
touch foo/bar
chmod 300 foo
chmod 000 foo/bar
rm -f foo/bar
But when testing you might stumble into thinking that you need more (e. g. r-permissions for the directory or whatever). This will be only due to false testing ;-)
I am trying to copy a filesystem for a device I am programming for. After so much time trying to figure out why the filesystem I was installing wasn't working I found out that cp didn't get the job done. I used du -s to check the size of the original filesystem and the one that I copied with cp -r, as it turns out they differ by about 150 bytes.
Something is telling me that symbolic links or some sort of kernel objects aren't being copied correctly.
Is it possible to copy a folder/file system exactly? If so how would I go about it?
Try doing this the straightforward way :
cp -a src target
from man cp
-a, --archive
same as -dR --preserve=all
It preserve rights, symlinks...
Here I tried all the code in my Linux. Seems Rsync proposed by #seanmcl as the right one while others failed to keep owners and/or some special files or a denied result. The exact code is:
$ sudo rsync -aczvAXHS --progress /var/www/html /var/www/backup
Just remember to use just the directory name and not put a slash (/) or a wildcard (/*) at the end of source and target name otherwise the hidden files right below the source are not copied.
Another popular option is to use tar c source | (cd target && tar x ). See this linuxdevcenter.com article.
The most accurate way I know of copying files is with cpio:
cd /path/to/source
find . -xdev -print0 | cpio -oa0V | (cd /path/to/target && cpio -imV)
Not really easy to use, but this is very precise, preserving timestamps, owners, permissions, special files.
Rsync is the best way to copy a file system. They are myriad arguments that let you control exactly what is copied.
This is what I do, for example to duplicate directory A -> B:
$ mkdir B
$ cd A
$ cp -a ./ ../B