Text

chmod +X

For those that already know well how to change permissions, this memo won’t be usefull.
Maybe, it can be usefull to some others.

umask is generally fixed to 022.
This mask will be applied every times you create files and directories.

For directories, umask will be combinated with max permissions 0777 :
0777 - 022 = 755 (rwxr-xr-x)
For files, umask will be combinated with 0666 :
0666 - 022 = 644 (rw-r—r—)

You can change umask() value for 1 user or the whole system.

But, sometimes, you don’t want to do that and need to set permissions for only 1 directory.

example :
Suppose you (leader of a project) have 1 directory with normal 755.
Now, you want to share it with your team, you want to put it in some share.
On the share, now you want 750 for directories and 640 for files.

So you start with something like this :
drwxr-xr-x leader team  15 oct.  2009 /some/common/directory

You want : group (team) to be able to read files and directories above /some/common/directory

By doing : chmod -R g+r /some/common/directory
All files will be readable by group (team).
But the bad is that directories need ‘x’ bit to be accessed.
If you do : chmod -R g+x /some/common/directory
You’ll set ‘x’ for files and directories.

Before starting to write a script based on `find -type d`, have a look at `chmod +X` (X in capital) will ask chmod to set ‘x’ only where needed.
It will set ‘x’ only for directories.
So, for our case, something like this :
chmod -R go-rx /some/common/directory
chmod -R g+rX /some/common/directory

Text

multi-volumes archive under GNU/Linux

I have an external multimedia hard drive from MemUp which is not a great product.
The sad thing is that the included media-player feature (when connected to the TV) requires FAT32 partition.
This filesystem format from old Microsoft OS doesn’t allow to store files bigger than 4 GB.
Since I also use this drive to store backup likes CD/DVD images, I need to split these files.

The following two methods allow to split archives :

  • split command will cut your file,
    # -d switch generates numeric suffixes instead of alphabetic (.aa, .ab…)
    # -b switch is used to specifiy each volume size
    # optionnally, last parameter can be the prefix you want,
    so, do something like this :
    split -d -b699M “/path to /the /file /you /wanna split /like /PJ_Harvey-Please_Leave_Quietly.iso” pjharvey-plq.
    this will produces files like :
    pjharvey-plq.00
    pjharvey-plq.01
  • if you would like to archive a directory and its contents (sub directories and files), you may pack it into a tar archive before sending it to split :
    tar -c “/path to /my heavy loaded /directory /to backup/” | split -d -b1G - MyDigitalLife.

  • Maybe, one day, you will need to restore :
    cat pjharvey-plq.* > pjharvey-plq.iso
  • if your lame friend (girlfriend, mother, grand’ma or boss) is a Windows user and WinRAR adept, try something like this (see rar manpage for more options) :
    # a
    will tell rar to add files (create mode)
    # -m
    sets the compression level (0..5) : store (no compress) = 0
    # -v
    specify multi-volumes sizes
    rar a -m0 -v699m pjharvey-plq.rar “/path to /the /file /you /wanna split /like /PJ_Harvey-Please_Leave_Quietly.iso”
    this will produce files like :
    pjharvey-plq.part01.rar
    pjharvey-plq.part02.rar