Recursively set permissions on directories

The following command will execute a command on a directory and all its sub-directories:

$ find plugins -type d -exec chmod g+w {} \;

In this case, we’re changing the group permissions on the plugins directory and all sub-directories.

 

Update your SELinux policy

If you’ve recently installed an application or applied some patches that begin to generate a lot of SELinux audit entries, you can update your local policy to accommodate your recent changes. Please note that this isn’t a substitute for ensuring your files have the appropriate selinux roles and types.

# grep avc /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
 

I recently came across a command that allows me to search and replace a string of text in all files within a directory structure. This is very useful for updating static information in HTML files and the like.

find ./ -iname \*.htm\* -exec sed -i 's/www\.example\.com/www2\.example\.com/g' {} \;

Note that you must denote special characters with the backslash character (e.g., the dots in www.example.com).

 

Find world writable directories

I recently found myself needing to locate all world writable files in a directory tree and came across the following useful command:

find /var/ -type d -perm -o+w -exec ls -ld {} \;

The syntax may vary depending on the flavour of Unix/Linux you’re using, but this worked on Ubuntu for me.

 

1. Insert CD/DVD

2. Open a terminal window and use the following command to determine your DVD device:

$ drutil status
Vendor Product Rev
HL-DT-ST DVDRW GSA-S10N AP09


Type: DVD-ROM Name: /dev/disk1

3. Umount the disk with the following command:

$ diskutil unmountDisk /dev/disk1
Disk /dev/disk1 unmounted

4. Use the dd command to create the ISO file:

$ dd if=/dev/disk1 of=file.iso bs=2048

5. Mount the ISO file to verify that it is readable:

$ hdid file.iso

If you’re looking for a utility to allow you to read ISO files on the Windows platform, try Virtual Clone drive from SlySoft.