Archive for the 'Mac' Category

Want An OS X Dock On Your Linux Box?

If you are an Linux user and want your desktop looking more like Apple OS X, this post is for you. One of the cool things that Apple’s OS X operating system includes is the dock down at the bottom of the main desktop window. This makes your commonly-used programs easy to get to without having to go through a process of searching for them.

With this in mind, there is an application that you can install on your Linux box that acts a dock for you. This application is called KDocker.

(more…)

How To Change Login Screen Background Via Terminal

Sick and tired of the same old bluish background of the Mac OS X login screen? I have now found out a way to change it out. Simply modify/replace the following files:

/System/Library/CoreServices/DefaultDesktop
.jpg
(Leopard users)

/Library/Preferences/com.apple.loginwindow (Tiger users: modify this file)

Once this has been done, open a Terminal window and execute this line at the command prompt:

sudo defaults write
/Library/Preferences/com.apple.loginwindow
DesktopPicture '/Path/To/Picture.jpg'
(all on one line)

Once this has been done, log out of your account. When you log out, you should instantly see the changes that you have made.

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).
  3. (more…)

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.

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.

Top

Top is a great command when you are trying to see all of your running processes. It also gives a great deal of other information. It is broken down into four categories – tasks, cpu, mem, and swap. Tasks tells you about the processes that are running. Cpu tells you your processor load. Mem tells you about the total memory you have, how much is being used, and how much is free. Swap Is just like mem except it deals with your swap partition.

Below, you will see all the processes that are running on your computer. It gives most of the info about the processes that you will ever need to know. The main columns I focus on are PID, USER, %CPU, and %MEM. They are to me the most useful. PID is the process ID which is very useful when a program freezes. USER is who is running the program. %CPU is the amount of processing power the program is using. %MEM IS the amount of memory the program is taking up.

Top by itself only gives you information on what is running, but when you combine it with other commands, it makes it very powerful. We will get into that next time.

Searching for a File with a Specific String in the File.

To accomplish this I am going to show you a new command and then use | and grep with it. The command is locate. Your computer has a database that has the path names and files that are publicly accessible on your computer. Locate searches that database for all the pathnames and finds the one you are looking for. It is probably the easiest command to remember and use. You just type locate then what you are looking for.

Example:

locate report

You can also search for all files with a certain extension.

Example:

locate '*.jpg'

You may be saying why would I want to do such a specific search? Well lets say you are a web designer that need to modify a template file for all your websites that contain a certain function. Say the function was called capcha and all your template files end in .tpl. You would use you the | command to combine the two function together to accomplish this.

Example:

locate '*.tpl' | grep -R 'capcha' *

This works by running the locate command and then using grep on just the file names that locate returns. Yes you could just type grep -R 'capcha' *, but you would have to be in the root directory of your hard drive and the grep command would search every file on our computer. That would take a long time to complete, and if you are running the search on a web server you could bring it to its knees.

Grep

Grep is a very powerful command in the Unix world. It allows you to search for words in documents. This is very useful if you are trying to find bugs in code or just tracking down certain files.

The basic structure of a grep statement is below.

grep -R "string you are looking for" *

The -R in the statement means you want to search recursively. Make sure you put the “” around your string or you will get an error when you try to execute the command. The * means that the preceding item will be matched zero or more times.

Their are many more options that can be added into the grep function to make it even more useful. To find them type the following into the command line.

man grep