Chmod Command

Hello everyone!

Can anyone help me in how to work the chmod command?
Suppose that you have a directory of udir12, a subdirectory udir121 (under udir12) and a file called file131 under directory udir121.

How do you change permission for the directory udir12 and all subdirectory and files to 770?

Can anyone help me out please!!!

Thanks
Carlos


Similar Content



Soft Link

Hello everyone!
I wonder if you can help me with the following:
If you have the following directory and subdirectories,
UDIR1 ---MAIN DIRECTORY
under UDIR1 there is two subdirectories: UDIR11 AND UDIR12
under UDIR11 there is a subdirectory: UDIR111
under UDIR12 there are two subdirectories: UDIR121 and UDIR122
Given the above scenario:
1- How to create a soft link of the directory UDIR111 under the directory UDIR12, and then how do you name the soft link UDIR111-sl

Thanks so muchhhhhhhhhh to anyone who can help!!

Regards,
Carlos

Script To Recursively Enter Subdirectories And Rename Files Sequentially From Scratch

I am new to Bash scripting.

I have a main directory called Photos which has many subdirectories like People, Places and Things. Each of these subdirectories is populated by other subdirectories and lots of JPG photo images.

The digital cameras name the files in a way that is difficult to manage with web hosting.

I would like to go to each directory and subdirectory and rename the photos 1.jpg, 2.jpg, 3.jpg, etc. so that I can use a simple XML template to access them by specifying only a hosting directory.

I tried to use the following script:

#! /bin/bash

cd /home/paul/test

find . -name "*.jpg" -print0 | rename -v 's/.+/our $i; sprintf("%d.jpg", 1+$i++)/e' * -vn

exit 0

It successfully renames all of the files in all of the directories, but it does not restart the numbering for each new subdirectory. So first it goes through Photos and renames the three JPG files there 1.jpg, 2.jpg and 3. jpg, and then it opens the first subdirectory People and names the three JPG files there 4.jpg, 5.jpg and 6.jpg. Next it moves to the next subdirectory and continues sequential renaming until it is done.

I want it to restart sequential renaming with each new subdirectory, so that after renaming the three JPG files in Photos to 1.jpg, 2.jpg and 3.jpg, it moves to the first subdirectory and renames the JPG files there starting with 1.jpg again.

That way I use the links 1.jpg, 2.jpg, 3.jpg, etc in the XML template and just change the directory name to download the photos from the web.

Thanks for any help you can give me.

Setuid, Setgid, Sticky Bit

There's something really weird happening with permissions on a directory in linux. I have the directory /dir

Code:
ls -ld /dir
drwxrwxrwx. 2 root root 4096 Jan  8 00:06 dir
chmod 2777 /dir [this sets the setgid bit on]
ls -ld /dir
drwxrwsrwx. 2 root root 4096 Jan  8 00:06 /dir

And this is what I expect it to do.
However, when I change it to setid (WITHOUT setgid), it simply doesn't work. Instead of overwriting, it cumulates:
Code:
chmod 4777 /dir [for setting setuid bit on]
drwsrwsrwx. 2 root root 4096 Jan  8 00:06 /dir

As you can see, the setgid bit is still on together with the setuid! However, if I run:
Code:
chmod -s /dir

then the file has a 0777 permission.

And then again, if I change its permission to 4777 (so setuid):
Code:
chmod 4777 /dir
drwsrwxrwx. 2 root root 4096 Jan  8 00:06 /dir

it acts normally. So the same chmod 4777 acts differently in two different contexts.

I really can't understand it. Basically, I cannot get rid of the setuid/setgid through binary permissions. The sticky bit works fine. Changing from 1777 to 0777 adds and removes "t" respectively. What am I to make of all this? This behaviour makes no sense to make especially given that we can change the permissions to 6777 (setuid + setgid).

Can Someone Please Help Me Build A Script?

I'm in the need of building a script to clean up my media library. I've been PVR'ing for years now and it's time to clean things up. For example, my TV Shows are saved as such:

/media/storage/Show Name/Season 1/Show Name - S01E01 - Episode Name.mp4

Over the years I've created a bunch of subdirectories further than that and I want to go through and clean those out. For example, the following directory might exist:

/media/storage/Show Name/Season 1/subtitles

If I use the find command, with -type d and -maxdepth 4, I have discovered that the subdirectory I want to delete is in the 4th level. There should be nothing valid in the 4th level and okay to delete.

I don't really know where to start. I tried using the find command with -mindepth 4 but that doesn't seem to work as I would expect. Basically, I want to scan through the library, then I want to test to make sure that the directory isn't "Season XX" and if it is a subdirectory within Season X then I would like to delete that subdirectory.

Any ideas how I can accomplish this?

FYI: I'm using Korrora 21 with BASH.

Gzip -r -c Directory > Archive.gz

SUSE 11. I have issued the command "gzip -r -c directory > archive.gz" over a complete directory tree. I've got no errors or warnings. I can decompress the gz file also without errors, but what I get is a single file which is the concat of all of the original files, including binaries, without posibility of splitting them into the original ones.

I suppose I've lost my files, no?.

Secondary question: why does gzip let me issue that destructive command?

File Permissions Between Users

Hello Everyone! I'm somewhat new to linux, and getting my feet wet by building my first linux server.

So what i have is an application that moves/sorts files. Another program that catalogs them.

The problem is that each app uses it's own user. So my question is if there is any way that files owned by prog1user can be read by prog2user?

I have tried doing a chmod -R 755 Directory and that has allowed the second program to see the files, but I'm guessing this has certain security risks (although I'm not so worried about the files in this directory).

Anyways I was wondering if there was a proper way to do this? OS is debian wheezy.

Cheers!

Using The Teminal Command Line In Ubuntu 12.04 Lts

Stupid question i know. I am trying to install some brother printer drivers and following the instructions it states that i must change to the directory where the file is stored by using the following command line "cd /home/(loginname)/downloads"

this comes back with unkown directory. When i use DIR the directory is there but it will not allow me to access it?

This has worked before. I have been using linux now for a few years and never had this problem before. It must be something stupid that I am doing.

Ssh Public Key Fingerprint

First time post so I hope it's not too long winded!

I've just installed Centos v7.1 and created an additional user.

First putty session I logged in with root and got the public fingerprint message and clicked Yes to accept.

However I noted when I logged in with the user other I did not get the prompt and my home directory didn't have a .ssh directory.

OK, so I created a .ssh (chmod 700) directory within /etc/skel and created a new user. Logged in with that account and still no prompt, although I do now have a .ssh directory generated.

I've tried deleting the known_hosts files in the root's .ssh directory and restarting the sshd daemon but it's not working.

How do I get it to prompt with original public key again?

Thanks for reading.

Why Should I Always Use Chmod When Not As A Root User

System Info:

I have normal user in CentOS 7 whose name is "mostafa" (the name of the account).

I naturally have another user called root with all privileges. User "mostafa" is put into sudoers file, too.

The OS is installed in VmWare, so the system is all mine.

Problem:

Now I create a file with touch file.sh and put a command in it, but when I want to run it with Code:
sudo ./file.sh

, an error is shown that the command Code:
./file.sh

does not exist. But if I Code:
 sudo chmod 777 ./file.sh

then it gets run. My question is that, why should I use Code:
chmod 777

when I myself have created the file, and I am in sudoers.

Can anyone explain me why shuold I still use Code:
sudo chmod 777

when the creator of the file is me.

Permission Denied When Trying To Execute An Application On A SD Card

Hi,
I made some little applications with qt creator and i wanted to run them on an embedded linux board (linux 2.6.24). To transfer the files i use a SD card. If i move the applications to "/bin" after having mounted the SD card and then "chmod a+x" them then i have no problem running them.
But if i mount the SD card and try to run the applications directly in the folder where i mount it i have an error : "Permission denied". Also when using the command "ls" i notice that if i keep the files in the mounting folder and try to "chmod a+x" them, the modification don't happen. They stay "greyed" and don't go "green". (I don't know if this color code is a standart for linux terminal but maybe this could help you understand the problem).
When mounting the SD card i use the command :
Code:
mount -t vfat /dev/mmcblk0p1 /mnt/SD

So the files are located in /mnt/SD.

Am i missing something or is it not possible to run something like that ?

EDIT :
I tried "mount -t vfat -o umask=0000 /dev/mmcblk0p1 /mnt/SD" to chnage how i am mounting the SD card.

Still "Permission Denied".

With "ls -l" i can see that the permissions are staying :
-rw-rw-rw-

Even if i try something like "chmod 777".

It seems to be a problem related to the fact that the sd card is formated as fat32 but it must stay like that.