Kroko Just another WordPress weblog

November 6, 2015

How to remove executable bit recursively from files (not directories)

Filed under: Linux — admin @ 11:09 am

When I plug-in an USB stick (FAT) into my Centos Linux machine, all files have the executable bits set. After having copied the directory structure to my hard disk I remove the executable bits recursively just from the files and keep those on the directories with following command:

chmod -R -x+X *

Explanation:

  • -R – operate recursively
  • -x – remove executable flags for all users
  • +X – set executable flags for all users if it is a directory

November 10, 2014

Find files modified in the last week.

Filed under: Linux — admin @ 4:13 pm

Change ./ to the root directory you wish to search in. Change -7 to +7 for files changed more than a week ago.

  1. find ./ -mtime -7 -print

-mtime n[smhdw]

             If no units are specified, this primary evaluates to true if the difference between the file last modification time and the time find was started, rounded up to the next full 24-hour period, is n 24-hour periods.

             If units are specified, this primary evaluates to true if the difference between the file last modification time and the time find was started is exactly n units.

             Please refer to the -atime primary description for information on supported time units.

   -atime n[smhdw]

             If no units are specified, this primary evaluates to true if the difference between the file last access time and the time find was started, rounded up to the nextfull 24-hour period, is n 24-hour periods.

             If units are specified, this primary evaluates to true if the difference between the file last access time and the time find was started is exactly n units.  Possible time units are as follows:

             s       second

             m       minute (60 seconds)

             h       hour (60 minutes)

             d       day (24 hours)

             w       week (7 days)

             Any number of units may be combined in one -atime argument, for example, “-atime -1h30m”.  Units are probably only useful when used in conjunction with the + or   modifier.

June 19, 2014

VMWare vSphere ESXi v5.5 Datastore problems

Filed under: Linux — admin @ 2:41 pm

I found an error with vmware esxi. Message from windows client is: Call “HostStorageSystem.ComputeDiskPartitionInfo” for object “storageSystem” on ESXi “x.x.x.x” failed.

I have the issue because the disk that I was using had existing partitions (a Linux swap partition and a Linux MD5 RAID partition).  I had to manually delete the partitions logged in as root to my ESXi box, even though ESXi said it would do that for me.

Useful commands:

# esxcfg-scsidevs -l

this lists the disk devices, the device file will be /dev/disks/<NAME>

output looks like:

t10.ATA_____ST3320620AS_________________________________________6QF1PZXB
   Device Type: Direct-Access
   Size: 305245 MB
   Display Name: Local ATA Disk (t10.ATA_ST3320620AS_6QF1PZXB)
   Multipath Plugin: NMP
   Console Device: /vmfs/devices/disks/t10.ATA_____ST3320620AS_________________________________________6QF1PZXB
   Devfs Path: /vmfs/devices/disks/t10.ATA_____ST3320620AS_________________________________________6QF1PZXB
   Vendor: ATA       Model: ST3320620AS       Revis: 3.AA
   SCSI Level: 5  Is Pseudo: false Status: on
   Is RDM Capable: false Is Removable: false
   Is Local: true  Is SSD: false
   Other Names:
      vml.010000000020202020202020202020202036514631505a5842535433333230
   VAAI Status: unknown

 

Easy solution:

Now can recreate partition table for that disk with a blank one:

for MSDOS run:

 ~ # partedUtil setptbl /dev/disks/naa.600508b1001c95a3d3a1f9455babd2d0 msdos

msdos

0 0 0 0

for HDD larger than 2TB use GPT:

~ # partedUtil setptbl /dev/disks/naa.600508b1001cfb4c4b4ed4e1eee52e25 gpt

gpt

0 0 0 0

Now you have a fresh drive. Try to add again in datastore.

 

Alternative solution:

# partedUtil get /dev/disks/t10.ATA_...

this shows the partitions on the device

output looks like:

38913 255 63 625142448

1 63 514079 130 128

2 514080 625137344 253 0

this disk has 2 partitions, numbers 1 and 2

# partedUtil delete /dev/disks/t10.ATA_... 2

deletes partition 2

# partedUtil delete /dev/disks/t10.ATA_... 1

deletes partition 1

« Newer PostsOlder Posts »

Powered by WordPress