How to log all file that has been move,chmod,chown?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to log all file that has been move,chmod,chown?
# 1  
Old 11-25-2013
How to log all file that has been move,chmod,chown?

Hi All,

Seeking for your assistance on how to log that has been chmod,mv,chown,chgrp and how to prevent script running while chmod,mv,chown,chgrp are still running?

Ex: a/b/c-folder
Code:
file1.txt
file2.txt
file3.txt

Code:
chmod 777 *
chown owner
owner group
mv

what i did was(please see below). but it's not working. i ended up 0 bytes the .log
Code:
chmod 777 * > test.log
chown owner > test.log
mv * > test.log

Expected output:
put all that commands that i used in the log file. and prevent the script from running again while the commands that i used are still running.

Code:
Move command expected output sample
a/ - folder
file1.txt is transferred to a/ folder
file2.txt is transferred to a/ folder

Please advise,

Thanks,

---------- Post updated at 07:10 PM ---------- Previous update was at 06:05 PM ----------

may i gently followed up on this please. i don't know how to start T_T

Please advise,

Thanks,
-nik

Last edited by nikki1200; 11-25-2013 at 07:25 AM.. Reason: Use code tags, please...
# 2  
Old 11-25-2013
Quote:
As per my understanding ,since these commands wont give any output, you are getting a zero byte file.

I believe you are looking for some kind of tracking to know what has happened with the files -- audit any changes made on the file.

I am not sure if there is any command that let us do this audit trail, but on googling i found the below link, may be you can take a look to get some idea,

http://www.cyberciti.biz/tips/linux-...to-a-file.html
# 3  
Old 11-25-2013
Thanks Sir. i think there is a solution on my issue but i don't know how to start. T_T
# 4  
Old 11-25-2013
This is confusing. Let's say you want to block access to /path/to/files, then find all the chmod (or created) and modified changes for the last 24 hours.

Code:
#Run as root to block other  and group access:
chmod 700 /path/to/files   # sets  read + execute off  [you are root (or owner)] 
# now find regular files that have either been "chmoded" 
echo 'start chmod, created list' 
find /path/to/files -type f -atime -1 -exec ls -l {} \;
echo 'end chmod, created list'
# now find files that have been modified in the last day
echo 'start recently modified list' 
find /path/to/files -type f -mtime -1 -exec ls -l {} \;
echo 'end recently modified list'
chmod 755 /path/to/files

NOTE: blocking access to some directories, like I showed, is not needed and is dangerous and can actually hang the whole system or cause other important processes to fail. Therefore it is really a bad idea. Be very careful. I personally would not do that.
This User Gave Thanks to jim mcnamara For This Post:
# 5  
Old 11-25-2013
Thanks Sir jim mcnamara.
# 6  
Old 11-25-2013
Not sure the OP wants to block anything. I guess he/she wants to log actions performed. To do so, redirect stderr and not stdout, and append to the log file instead of overwriting. And, you may want to use the -v (verbose) options to the commands, if that exists. Like:
Code:
mv -v file?.txt /path/to/destination 2>>log.file

This User Gave Thanks to RudiC For This Post:
# 7  
Old 11-25-2013
Thanks Sir RudiC
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Chmod working in sudo run script but chown isn't

My git user has permission in sudoers to run a wrapper script to move files into my webroot. Everything is working fine except for the chown line. After the script has run, the files ar still root:root instead of apache:apache. Scratching my head...:confused: #!/bin/sh echo echo "****... (4 Replies)
Discussion started by: dheian
4 Replies

2. UNIX for Dummies Questions & Answers

chown: Read-only file system

Hi, I am logged in as super use and want to set owner of a root folder to a specific user. #chown -R user1:group1 /u01 This gives the message: chown: /u01: Read-only file system chown: lost+found: Read-only file system #ls -l drwxr-xr-x 3 root system 256 Mar 21 16:42... (2 Replies)
Discussion started by: shoefiend
2 Replies

3. Shell Programming and Scripting

excluding a directory with chown, chmod

does anyone know how to exclude a directory with chown or chmod? im trying to do something like this chown $username:$username $directory/* chown $username:$username $directory/.* chown $username:$username $directory and find $directory/* -type f -exec... (1 Reply)
Discussion started by: vanessafan99
1 Replies

4. UNIX for Dummies Questions & Answers

chown: <file>: Not owner on Solaris 9

Hi, on a Solaris 5.9 machine no user except for root is able to use chown. for exmaple: > touch iamgal > ls -la iamgal -rw-r--r-- 1 galtest1 other 0 Dec 19 08:40 iamgal > chown galu iamgal chown: iamgal: Not owner I have checked about /etc/system and rstchown - it is... (5 Replies)
Discussion started by: galuzan
5 Replies

5. UNIX and Linux Applications

What is the difference between chmod in solaris and chmod in Linux?

i think it is the same in both... Iam i right? (1 Reply)
Discussion started by: sumaiya
1 Replies

6. Shell Programming and Scripting

File permission by chmod

Hi, I have a typical problem. Consider the scenario: Folder1 ------> Folder2 ------> File1 ------> Folder3 Above is my folder structure, currently the user group "other" has no permissions. I wish to give "read" permission for "others" to File1 using a single command. chmod -R... (5 Replies)
Discussion started by: animesh303
5 Replies

7. UNIX for Dummies Questions & Answers

chmod of remote file

I would like to chmod the file which I am pulling from remote server onto my server. I am using the following script: sftp <server detail> get abc xyz chmod 666 xyz bye Though I could fetch the file successfully but I am not able to change the permission of xyz file on my server. umask... (1 Reply)
Discussion started by: kdtrica
1 Replies

8. Shell Programming and Scripting

use a file to chmod

Hi! I need help becouse I've server to backup and I've a lot of files with 700 permission and I need to change the mode to 755 before copy So the point is. With find . -perm 700 -exec echo {} > textfile.txt \; I got a text file with 3156 line which one... (3 Replies)
Discussion started by: ruben.rodrigues
3 Replies

9. Shell Programming and Scripting

Trying to untar then chown, and chmod

I'm changing (trying to anyway) a script that will need to unrar a file, this file will create a directory with files in it. Then I need to change the owner ship and permission on that directory. Finally, I will rsync the directory to another machine. This is what I have so far. #!/bin/bash ... (1 Reply)
Discussion started by: walkerl
1 Replies
Login or Register to Ask a Question