Want Color in Your Text Editor?


If you're new here, you may want to subscribe to my RSS feed.

If you are a programmer or a web designer, and want to have color designation to your coding without having to buy Dreamweaver or any other pricey HTML editors, I would recommend downloading Vim. Vim is a vi-based clone that allows you to view your code, HTML, CSS, etc. in a color-coded style.

This app can be downloaded by doing: sudo apt-get install vim

VIM can also be an alternative to using vi, which only displays code in monochrome. Here is a comparison of between the physical appearances of vi and vim:

Read the rest of this entry »


Play Tetris in Emacs


If you’re ever using Emacs (Extensible Macro System) as an editor and feeling bored, you can always play Tetris in it. Playing Tetris in Emacs only works in the GNU environment which Mac OS X also runs under. The steps for running Tetris in Emacs have been provided below:

  1. In Terminal, type emacs at the comment. Emacs will then appear for you.
  2. In the Emacs window, press <ESC>. This will bring you to the note buffer section (shown below).

Read the rest of this entry »

Make the most of the Mac OS X’s command line


If you’re like most Mac users, the UNIX command line is the red-headed stepchild of the operating system. It’s always there, but you’re not going to acknowledge its existence — that is, until you need to run an SQL query, make an rsync backup, or generally muck about in the system internals.

Thankfully, TheAppleBlog’s Andrew Bednarz has assembled a compendium of Mac OS X terminal tips, tweaks, and tricks. He shows how to use Visor, a cool program that provides an always-accessible pulldown terminal prompt just like the console in the video game Quake. He also shares some insider UNIX knowledge on tweaking Terminal.app to display color-coded directory listings and more informative command prompts.

Go check out his list of tips. Your command line will thank you.

Having trouble finding text with grep? Try grepping with color


Having trouble finding a needle in a haystack? You can always use grep --color to find what you are looking for. This method is best used for finding a specific piece of text in a document that is all on one line, or a unique string of text within a repetitious document. I have provided the syntax for this grep option below:

grep --color "text" filename

Example:

LSPCI and LSUSB


The commands listed in this post are more for Linux than Unix. To find out information about the hardware of your computer, you can run an lspci command. Lspci will output the specifications of your hardware in a list style arrangement as shown below:

If you want to get more specific in your lspci output (e.g. wanting just to display a certain brand), you can always do lspci | grep -i "Productname" which will only return results that includes the string from your grep command. For example, if I wanted to find all of the hardware made by Broadcom, I would do lspci | grep -i "broadcom" and the results would return only hardware that mentions Broadcom.

Read the rest of this entry »

Need to find a SMALL amount of text in a BIG directory? No problem!


Have you ever tried to grep in a directory that has a vast amount of files and you received an error like this? (below)

If so, there is a simple way around this. Just use this: find . | xargs grep "yahoo" * | more. I will break down these processes for you:

  • find . - Find is a command that outputs the location of a file. In this case by specifying a ., the search will only be done in the present directory.
  • xargs - This allows a command to be executed from standard input. This also helps force the grep command (coming next) to return output, even when the directory is too large.
  • grep - The way we will be using this command is to search through a file for a specific string. If you are looking for straight text, it is best to use quotes (e.g. “text”) to help the command line decipher exactly what you are looking for. More info on grep can be found on this earlier post.
  • more - This command is optional for this process. More would be best used if you were expecting a full page of output returned from your search, and want to be prompted for the next page. This option would be very beneficial if the string you are searching for would be common in your results.

Apropos


Ever wanted to use a command to do something, but couldn’t quite figure out the actual command to accomplish what you need done? Try using apropos! Apropos is a way to browse through the help area of the Unix/Linux operating system for a command that will help achieve your goal. For example, if I wanted to find commands that relate to “secure”, I would enter apropos secure at the command line, and the kernel would return the results listed below along with any services that involve ’secure’:

As always, if you wanted to get a more elaborate description on a command or service, you can always use man (shortened for: manual). This will display a full description, and various options of a command which you have found using apropos.

Alias


The alias command is very useful. It is kind of a shortcut in some ways. I get tired of tying ls -la so I can see all the info for my files so what i do is type alias ls 'ls -la'. What this command does is that it sets up an alias so that every time I type ls the computer treats is as though I typed ls -la. There are many other things you can do also. Say you have a long command you run a lot. You can alias it to something like mc.

Ex: alias mc 'locate log_error | grep -R 192.168.1.1 *'

Your command can be as long or as short that you want to alias. I also use it to setup ssh connections.

Ex: alias con1 'ssh usrname@192.168.1.1'

Now any time I type con1 it will try to make an ssh connection to that ip address.

The diff command


The diff command is a very useful command to see the differences between two files. An example of this command would be

diff file1.txt file2.txt

It takes file2.txt and compares it to file1.txt and displays the differences that are in file2.txt. You may also want to use the -b options in the command because that will allow it to ignore differences in white space. This command is very useful in programming when you have a backup version of a script that you just modified. If the script no longer works it can help you track down bugs, by looking at backup version of the script that does work.

The kill command


Today we are going to look at a command that you don’t use very much in a Unix environment. The kill command. It is used when an application is stuck or not responding. The basic form of the command is kill [option]… PID. The PID is the process ID, you can get it by using the top command that I talked about previously. The most common option for the kill command is the -9 option. It will kill the process immediately.

Example

kill -9 2342

If you type top again you should see that the process that was associated with that PID is no longer running.