Unix commands
Changing the owner of specific files only (chown --from)
If you want to delete a user and chown all files that belong to this user, you can use this command:
sudo chown -R --from=username newowner /
Recursive grep
grep (case-insensitive, recursive) grep doesn't offer any possibility to recursively descent down the directory tree. The following command searches e.g. just thru all the files in the current directory:
grep bacteria *
To make the search case-insensitive, one can use the i flag:
grep -i bacteria *
But if you want to do a recursive search you have to use a quite complicated construction of UNIX commands to achieve this goal:
find ~/Mail -type f -exec grep 'bacteria' {} \; -print
scp (secure copy)
In order to copy the file index.html from the local machine to vesuri.helsinki.fi the following command is needed:
scp -p /Volumes/Documents/michael/Sites/index.html mjeltsch@vesuri.helsinki.fi:./public_html/index.html
The full path of the original file (/Volumes/Documents/michael/Sites/index.html) is of course not needed if the file is in the current directory.
Finding files that have been modified during the last specified period of time (find -cmin)
To find files in the current directory and its subdirectories that have been modified (= created or updated) 2 minutes ago
find . -cmin 2 To find files in the current directory and its subdirectories that have been modified (= created or updated) within the last 2 minutes find . -cmin -2
What nfs and smb shares are available on a server (showmount, smbclient)?
The command to figure out what shares are available e.g. on the computer 192.168.0.2 type:
/usr/sbin/showmount -e 192.168.0.2
smbclient -L 192.168.0.2