Many Linux users use the ‘find’ utility when searching for files using the command line on their system. They’ll do a simple:
find / -name ‘pattern’
Really though, the power of find isn’t just in finding names of files but rather specific details about those files. For example, if you wanted to find files which are writable by both their owner and their group:
find / -perm -444 -perm /222 ! -perm /111
or perhaps find any file that’s been altered in your Download directory in the past 24 hours:
find /home/user/Downloads/ -mtime 0
As you can see, the find command is very versatile and can be used to find an array of different attributes of files. There are times though where I’m just looking for something and I don’t want to have to wait for the command to scan the entire directory tree in order to track it down. That’s where locate comes in with quick and simple results.
Using the locate command can only be accomplished if you install the mlocate package. Most major distributions have this available. If not, head over to the mlocate homepage and install manually. Once that is accomplished, you’ll need to manually run a command to index your filesystem with it…otherwise, you’ll have to wait for the command to run automatically as it registers with cron to do so on a system level. Open a terminal and change to your root user, then execute the following:
updatedb &
This updates the mlocate database that indexes your files and forks it to the background (the ‘&’ forks it to the background). You can now logout of the terminal as root and the process will quietly work in the background.
After the command completes, using mlocate is as easy as using the locate command:
locate firefox | less
The command above will look for all files with Firefox in the name and pipe the command through less so you can use the space bar or enter key to scroll the file buffer. Of course, the reason we pipe it through less is because any file that resides in the ‘firefox’ directory will be reported in the output. While this tool isn’t as granular as the find command, it is a quick way to track down paths, directories, and files you know should exist. Since the data is indexed using the updatedb command (by cron) the results are very quick and the command does not have to scan through the filesystem to return the results.
There are plenty more advanced options via flags (such as following symbolic links, making search term case-sensitive, and even using regexp). See the man page for details on how each of these options work. Play around with locate and see what you can do! It’s a powerful and quick search command!
Tag Archives: unix
Some Linux security tips for Rootkit Hunter
If you run Rootkit Hunter and you haven’t modified your stock Red Hat configuration of the SSH service (sshd), chances are it will find that you allow root logins. Rootkit Hunter considers these as possible security risks. However, to fix this, you can simply login as root, fire up a text editor, and edit the file
/etc/ssh/sshd_config
Make the following changes:
You’ll find a commented line like this:
#Protocol 2,1
Uncomment it and change it to:
Protocol 2
This will disallow logins using the older versions of the protocol
Look for the commented line
#PermitRootLogin yes
Uncomment the line and change it so it reads:
PermitRootLogin no
This will configure sshd NOT to allow root logins.
After this, be sure to restart sshd (assuming you run the service in the first place so:
Service sshd restart
By the way Rootkit scanner is scanning tool to ensure you for about 99.9% you’re clean of nasty tools. This tool scans for rootkits, backdoors and local exploits.
Stay safe! Install Rootkit Hunter on Linux and FreeBSD
Rootkit Hunter is a Unix-primarily based scanning tool that scans for rootkits, backdoors and possible local exploits. It does this by comparing SHA-1 hashes of vital files with known good ones in online database, looking for default directories (of rootkits), improper permissions, hidden records data, suspicious strings in kernel modules and particular tests for Linux or FreeBSD. Most instances rootkits are self-hiding toolkits utilized by blackhats, crackers and script kiddies, to keep away from the attention of the system admin. If you’re unsure as to whether your system is compromised, you will get a second opinion from sources such as Linux-oriented forum. If your system is contaminated with a rootkit, cleaning it up will not be an option. Restoring can be not an option unless you might be expert, and have autonomous and an impartial means of verifying that the backup is clear, and does not include misconfigured or stale software. Never trust a potentially compromised machine! Basically a clean install of the OS is always advisable after backing up the system.
WinFF: the best mkv to avi converter for Ubuntu
This week, in our Linux Page (in Spanish) we posted an essential manual about the best software to convert a video file from mkv to a more common (and readable) avi format. First of all we tried with a well known line program: ffmpeg but we had different problems and we did not succeed. For this reason we tried to install the specific libavcodec-unstripped-51 package but we were not able to convert our file. For our second test we installed avidemux but also in this case the mkv file resisted. Then we read in a post that VLC contains a powerful converter and we used it to transform the mkv file to avi. Unfortunately we succed only for the audio part of our file but we were not able to obtain a complete video file. Only during our last test we transform the mkv video to avi using WinFF. This program, based on ffmpeg, has a very clear graphical interface and it is very intuitive to use. After ten minutes of trials we were able to correct our settings and to start the file conversion. In the WinFF menu you can easily choose between many different video and audio formats (in our test we chose AVI) with a Device Preset setted to XviD in AVI (16:9) and decide the output folder you prefer. WinFF -does not work- if you do not insert the mandatory data in the below part of the menu. In our test we setted:
Video Settings
Video Bitrate = empty (null = we did not write anything)
Frame rate = 25
Video Size = 592 x 320
Aspect Ratio = 16:9
Audio Settings
Audio Bitrate = 118
Sample Rate = 48000
Audio Channels = 2
Additional Command Line Parameters (advanced)
null = we did not write anything
We recommend WinFF to all that people who are not very clever with line command programs and need to easily transform video files to a different formats!
Linux on Laptops!
This week, in our Linux Page (in Spanish) we added a brief post about www.linux-on-laptops.com: a very useful website where you can find tons of useful information about the best Linux version for your laptop. Linux-on-laptops is graphically very poor but the information it contains are terrific; in fact you just select your laptop brand and in a new webpage you are able to find all the laptop models related to that specific brand. With a couple of clicks you select your favourite Linux OS and you are redirect to external webpages and blogs where you receive all the necessary information to quick install that specific Linux version on your laptop. In a week time we made many tests and we found all the infos we were looking for. Moreover, linux-on-laptops is really updated with the most recent laptop models and Linux versions. Recommended!