Unix

From Dave's wiki
Jump to navigation Jump to search

https://www.chiark.greenend.org.uk/~sgtatham/agedu/

Tips

Find all top level directories

# -path pattern - File name matches shell pattern pattern.
# -prune True; if the file is a directory, do not descend into it.
find . -type d -path "*/*" -prune

View older "last" logs

last -2000 -f /var/log/wtmp.1 | less

Default group for newly created files requires the setgid bit on the directory.

# https://serverfault.com/questions/96338/specify-default-group-and-permissions-for-new-files-in-a-certain-directory
mkdir blah
chown dtang.ngs blah
ls -lhd blah
drwxrwxr-x 2 dtang ngs 10 Mar 18 14:59 blah

# set the setgid bit
chmod g+s blah
ls -lhd blah
drwxrwsr-x 2 dtang ngs 10 Mar 18 14:59 blah

touch blah/foo
ls -lh blah
total 0
-rw-rw-r-- 1 dtang ngs 0 Mar 18 15:01 foo