files
Using Find To Help Manage Files On Linux
We found a system administration problem on a server today that was being caused by incorrect directory permissions. Any email that passes through the server-wide spam filter was not going through because of permissions on the /home/<domaindir-here>/etc directory. That directory needs to be owned by mail. Here is a quick way to update those directories: [root@host:home]# cd /home The find command only lists directories (much, much faster if you know you only need a certain file type like ‘d’), up to 2 levels deep (. = current directory = level 1), and matching the name etc… [root@host:home]# chgrp mail `find /home -maxdepth 2 -type d -name etc` Now we pass find as a variable list to the ls command to see what we touched. The ‘d’ on ls also restricts it to directory level output only, so we don’t descend into those ...
Finding Which Linux Packages Provide Which Files
There have been multiple situations where I find out that I need a particular file to continue with something I am doing. Most of the time this happens when I am compiling a program. I will be missing a library, or header file, or something. So I end up on search engines looking for whatever package I need to ‘apt-get install’. Well it turns out there is a command line tool that will tell you this information, on systems use Apt, that is. Enter ‘apt-file’. I use Ubuntu, and it doesn’t come with that platform by default. Or at least not on 10.04 then I’m using. But you should know how to get it. A simple ‘apt-get install apt-file’. Once you have it installed, you will have to update the cache it uses for searching. I was prompted to do this automatically, but if you ...
Linux File Management
Note About Security: Best practices dictate that the security of your directories and files should be set to least privileges granted to get the job done. That means don't open up the security of a directory or a file just to make it work. Know what you need to accomplish your goal and don't open security beyond that. Listing Files By Date "list long time reverse" = show detailed listing, by date, in reverse ls -ltr * By Size "list long by size reverse human" = show detailed listing by size, reverse order, human readable (kb,Mb instead of blocks) ls -lSrh Finding Files "find all files, starting at the root directory whose size is more than 4096k" find / -size +4096k Script to find big files This script will locate all files in the specified directory that are more than 4M (4096k). The backward single tick around the find command is used to gather the results of the ...

