Change owner for directory recursively: sudo chown -R user:group /path/to/directory Chown is a short for “change owner”, -R – means “recursively”, owner and group definition are separated by “:”. Also we need high privileges to run chown command – so we use “sudo”. Change permissions only for directories recursively: find /path/to/directory -type d -exec chmod 755 {}Continue Reading
Tag: Unix
How to run a program as daemon without any output
Each program has a set of file descriptors. It’s like an open stream from / to file. On start program has 3 descriptors: standard input (stdin), standard output (stdout) and standard error (stderr). They has numbers: from 0 to 2. Standard input is used for reading input data from the user (from the terminal). StandardContinue Reading
How to get top 10 commands
It’s more like a joke / just for jun task. But it also perfectly shows one of the Unix principle: Make each program do one thing well. To do a new job, build afresh rather than complicate old programs by adding new “features”. Actually even two principles; Write programs to handle text streams, because thatContinue Reading
How to move files only if destination does not exist
Unix is simple and straight. It’s not ask you when you tell it to do something. For example, if you ask to move a file to the directory with same-named file… Unix will replace it without any words. But we can ask Unix do it more “carefully”. Merge one folder to another, but don’t overrideContinue Reading
How to get status codes from commands in pipe
A pipe is a form of redirection io-streams. It helps transfer standard output to some other destination. That is used in Linux and other Unix-like operating systems to send the output of one to another. One by one Unix programs can modify output. But what if one of them fails? The members of the $PIPESTATUS array holdContinue Reading
File and directory permissions in Linux / FreeBSD / MasOS
According to the Unix philosophy “Everything is a file”. And it is. But sometimes it’s difficult to understand all the rules to provide this statement. Let’s start from the most common problems that developers have when working with Unix-like file systems! Basic commands for setting file permissions To recursively change directories’ owner and group, useContinue Reading