Searching For and Inside Files (find, grep)

The command find is used to find files with various attributes. It has many options. This makes it somewhat awkward for just searching for a file by name. For example, the command

finds all the files in the current directory and any directories below that have a name which ends in .tex and then prints the result of the search at the terminal.

The program grep looks inside files for specified text. For example,

will search the file paper.tex for any occurrences of the text Diophantine” and then then print those lines at the terminal. If you are searching in more than one file as in grep Diophantine *.tex it will print the name of the file in which the line was found.

 

How To Search Inside Files Via The Terminal in Linux

find ./ -name “*.ext” -print | xargs grep “keyword”

In the command given above, you have to change “.ext” with the file extension you are going to search inside, then replace “keyword” with text you want to search.

Here is an example:

find ./ -name “*.php” -print | xargs grep “

–> This command will search inside the current folder all PHP files for this code: “”.

Here is another example:

find ./ -name “*.txt” -print | xargs grep “How to unlock”

–> This command will search all text files under the current folder for this keyword: “How to unlock“.

great programs for terminal linux

cmus
cmus is a music player that I admire the most when it comes to command-line because it’s really powerful and has a lot of nice features. It is built with ncurses and therefore providing a text-user interface. cmus is indeed feature-rich, with several view modes and Last.fm song submission support via scripts. It supports Vi-like commands and auto-completion with Tab too. Recently I wrote a full guide on how to use cmus, you can read it here.
Homepage


finch
Finch comes bundled with Pidgin, the popular IM client. Finch offers the same functionality that Pidgin offers, only that it does it in a terminal by using the ncurses library. It supports IM protocols like Yahoo, Google Talk, XMPP (Facebook), WLM (Windows Live Messenger) and more. A while ago I put up a detailed guide to Finch, which you can read here.
Homepage

htop
htop is an interactive process viewer tool using ncurses which has the great benefit that it allows to scroll up and down the list of processes, and it also uses graphs and colors. I think all these make htop a real gem for the Linux user.
Homepage

irssi
Very powerful IRC (Internet Relay Chat) client with an ncurses-based interface, implements multi-server support, can be expanded with Perl scripts, supports themes, DCC chat and every other possible feature IRC servers allow.
Homepage

mc
Midnight Commander is the famous twin-panel file manager for the Linux terminal, also based on ncurses and with lots of features.
Homepage

lynx
lynx is a popular web browser for the terminal. It supports protocols like HTTP, FTP or Gopher.
Homepage

gzip
gzip is a command-line tool for compressing and uncompressing files. All the files that end in a .tar.gz extension are archived with tar and compressed with gzip.
Homepage

bzip2
Same as gzip, bzip2 is a data compressor which takes a longer time to compress and uncompress files, but it also provides a more efficient compression algorithm which results in smaller files.
Homepage

tar
This tool is used to create archived files, and will also work in conjunction with gzip or bzip2. The command to compress a file or folder to gzip is (what follows after # is a comment):

The c argument means compress, the z specifies the type of file to create (gzip file in this case), and f specifies the output file name. The command to uncompress a .tar.gz file:

This will extract the contents of input_file.tar.gz to the current working directory. Here are the commands for bzip2:

Homepage

aaxine
aaxine is a video player for console based on xine-lib multimedia player, using ASCII characters for video output. In Ubuntu it is provided by the xine-console package.
Homepage


…it’s Big Buck Bunny by the way

aview
This tool allows to view images as ASCII art. It only supports the following formats, which are either in binary form or ASCII plain text: PNM, PGM, PBM, PPM. It also supports FLI and FLC video formats.
Homepage

mencoder
mencoder is a powerful video encoder and decoder included in MPlayer and can convert between various video files.
Homepage

ffmpeg
Using libavcodec, ffmpeg is yet another powerful tool to encode/decode, record and stream video files.
Homepage

convert
Included in ImageMagick, convert is a tool that can convert between image formats, and also apply various effects to images or edit certain aspects, including resizing, cropping, blur or dither effects. convert is also used on web servers for image processing.
Homepage

moc
moc (music on console) is yet another ncurses-based music player for the terminal which plays formats like Ogg Vorbis, FLAC, MP3, WAV or WMA. It also supports themes and searching for files.
Homepage

best pdf reader for ubuntu

Evince is the default PDF viewer in most GNOME-based Linux distributions, so if you don’t want to install all those KDE dependencies, Evince is probably your next choice. It’s lightweight, simple, and easy to use, though it doesn’t have too many advanced features. You can rotate PDFs, add bookmarks, and change the sidebar’s view mode, but other than that, you don’t have much. If all you’re doing is reading the occasional PDF, it’s great, but you won’t find any annotation features here.

Adobe Reader has a Linux version available, and as always, we don’t recommend it as your go-to reader. That said, it’s still the standard, which means if you ever have compatibility issues in something like Okular or Evince, Adobe Reader will probably handle it just fine. You don’t need to install it now, just know that if you ever have problems, it’s worth keeping in mind.

Lastly, it’s worth noting that lots of Windows PDF apps work great under WINE, including PDF X-ChangeFoxit, and Sumatra. So, while they won’t look fantastic under Linux, they’re great if you need some more advanced reading and editing tools, since most Linux apps are a bit lacking.

These aren’t the only PDF viewers for Linux, but they are, in our opinion, the best. If you’ve got a favorite we didn’t mention, let us know about it in the comments.

Ubuntu Performance Tuning

The overall performance of Ubuntu Linux is fine but to further tune the following can be done :

1. If you are not using IPv6 it can be disabled as follows:

In /etc/modprobe.d/aliases change the line alias net-pf-10 ipv6 into alias net-pf-10 off #ipv6.

2. Start daemon/processes in parallel

Change /etc/init.d/rc from CONCURRENCY=none in CONCURRENCY=shell

3. Add your hostname in the host file (default on hardy & intrepid). If you add your host name to the /etc/hosts file some apps will start quicker. e.g. 127.0.1.1 myhostname

4. Install preload. Startup times on apps. can be further improved by installing preload (apt-get install preload)

5. Decrease Swappiness setting

If you got plenty of ram (>1GB) you can decrease the use of the swap file by changing the vm.swappiness sysctl entry from 60 to 10. If you like to further reduce swapfile usage you can set this value to 0* which will not disable swapfile usage but will reduce it to the absolute minimum. To change the sysctl entry *sysctl vm.swappiness=10 can be used, to let this setting survive a reboot vm.swapiness=10 can be added to the /etc/sysctl.conf file.

I’ve found that the value of 5 works very good for my use and I have 2 GB of memory.

6. Use the profile option of grub to reduce startup time.

Hit the escape button when booting to get to the grub menu, select the default kernel and select edit, add the profile option to the end of the kernel line and boot your system.

8. Disable unused services.

9. Use the noatime mount option to disable updating the access time on files.

If you have additional tips I’m more then willing to test/add them to this list.