Posts Tagged “cli”

If you are a Terminal lover you might try mounting .dmg files from commandline.

Basicly thats pretty easy, so just continue reading

Read the rest of this entry »

Tags: , , , , , , , , ,

Comments No Comments »

Mac OS X comes with an update service called Software Update.

Basicly its a nice feature which keep tracks on all Updates released by Apple Inc. for its software. This means it will cover the Operating System itself and the software shipped or offered by Apple.

Unfortunaly there is no real paket management like linux users love to have, but thats another story and this should not end in a rant

In some cases you want to ignore a specific update or an application from being updated so lets take a look how we can handle that with Mac OS X.

How to define an update to be ignored using Software Update:

You have to start Software Update and if the result list shows up, select the item you want to ignore. Navigate to Update in your menubar and select Ignore Update.

Well this is pretty easy, but maybe you selected the wrong update or just want to reset your ignore list whyever. It’s possible but not really good implemented from feature aspect … why ? Because you can only reset all Ignored Updates, not a specific one. Again a whyever….

How to reset Ignored Updates:

Start Software Update, navigate to Software Update in your menubar and select Reset Ignored Updates.

I would like to have a real paket management but that’s far away from reality, so we have to live with SoftwareUpdate how it is right now.

Personaly i would not work with ignoring updates in general as i prefer keeping my applications and operating system in touch with latest releases (which takes long enough with Mac OS X), but well if you need it ….do it =)

A final note for the command line lovers: Software Update is available as cli command too. You should start with a quick:

man softwareupdate

in Terminal.app, which will output something like that (10.5.4 here)

NAME
softwareupdate — system software update tool

SYNOPSIS
softwareupdate command [args ...]

DESCRIPTION
Software Update checks for new and updated versions of your software based on information about your
computer and current software.

Invoke softwareupdate by specifying a command followed by zero or more args.

The following modes are available:

-l | –list
List all available updates.

-d | –download

-i | –install
Each update specified by args is downloaded and unarchived, and also installed.  The
install flag requires root.  args can be one of the following:

item …    One or more update names.

-a | –all  All appropriate updates.

-r | –req  All required updates.

–ignore …
Manages the per-user list of ignored updates.

–reset-ignored
Clears the list of all ignored updates.

–schedule  Manages the per-user scheduler preferences.  args should be one of the following words:

on | off    Enable or disable automatic checking.

-h | –help
Print command usage.

I hope this short article helped.

Links:

Tags: , , , , , , , ,

Comments No Comments »

If you do use Terminal.app more then once a week it makes sense to customize your Terminal to your needs.

Personaly i prefer bash so the next steps are focused on the bash shell.

1. Creating a .bashrc:

  • Open Terminal.app
  • Open Terminal Preference Dialog
  • Navigate to the Startup section
  • Make sure you seleted “command (complete path)” under “Shell open with” section. The Full path should be “/bin/bash” in our example
  • Close the Preference dialog
  • Navigate to your users home folder if you arent there already.
  • Enter: “touch .bashrc” to create a new empoty file called .bashrc

Now we have done the first steps. We are sure we do use bash and we have an empty .bashrc ….so no function till now

2. Creating a .bash_profile:

Now we have to create a .bash_profile in our Users home directory too.

  • Open Terminal.app (be sure that you are in your users home directory)
  • Enter the following to create a bash profile: touch .bashprofile
  • Open the new bash profile. Enter: vi .bash_profile
  • Fill the new bash profile with the following:

if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi

3. Forcing Terminal.app to load our bashrc at start:

Now we have to make sure Terminal.app uses our new .bashrc while starting.

  • Open Terminal.app
  • Open Terminal Preference Dialog
  • Navigate to the Startup section
  • Change “/bin/bash” to “/bin/bash –rcfile /Users/yourusername/.bashrc

On the next start of Terminal.app it should use our empoty .bashrc file. So now lets fill it a bit

4. Define  an example alias:

  • Open Terminal.app
  • Open your .bashrc with a texteditor (ie: vi .bashrc)
  • Insert the following example alias to check if our .bashrc works: alias  ls=”ls -la”
  • Save and close the file
  • Restart Terminal.app

After relauching Terminal.app the “ls” command should output the same in terminal then “ls -la” does

5. Tweak the history of your shell:

I love my bash history, but why not tweaking its default behaviour ?

  • Open Terminal.app
  • Open your .bashrc with a texteditor (ie: vi .bashrc)
  • Enter the following lines to your .bashrc:

# history handling
#
# Erase duplicates
export HISTCONTROL=erasedups
# resize history size
export HISTSIZE=5000
# append to bash_history if Terminal.app quits
shopt -s histappend

After restarting your Terminal your history should we teaked as follows.

  • The first command deletes duplicate-commands out of your .bash_history file which contains your bash history.
  • The second command defined the size of your history
  • The third line appends the history to your .bash_history to make sure you have all sessions saved.

Well that was the basic first step. You could now continue adding colors to your .bashrc, configuring how the prompt will look like and many other nice things.

Here my final example .bashrc

# Define how Bash prompt looks like:
#
# User @ Host - working dir
#export PS1=”\u@\h\w$ ”
export PS1=”\u@\h\w: ”

# Cli Colors
export CLICOLOR=1
# use yellow for dir’s
export LSCOLORS=dxfxcxdxbxegedabagacad

# Alias
#
#
alias ls=’ls -la’

# history handling
#
# Erase duplicates
export HISTCONTROL=erasedups
# resize history size
export HISTSIZE=10000
# append to bash_history if Terminal.app quits
shopt -s histappend

Tags: , , , , , , , , , ,

Comments 3 Comments »

I have to cleanup my mails so here the link to the Apple Command-line backup documentation

Quote:

Backing up your hard drive is like going to the dentist: important, but unpleasant enough that it is easy to put off or forget. Because of that, the best way to keep your data safe is to schedule regular backups. While there are numerous commercial applications that address this need (including Apple’s .mac Backup), they tend to either require the user to be logged in, or be connected to an enterprise data center.

The traditional UNIX alternative is to run a command-line backup tool as part of a ‘cron’ script, but many system administrators are unaware of the variety of options available for unattended backups under Mac OS X.

This article discusses some of the issues faced in making backups, the special considerations of Mac OS X systems, a number of options which allow the creation of viable backups, and a few potential pitfalls of developing a backup system. This article does not cover BSD flags, or systems prior to Mac OS v10.4 Tiger. And for simplicity, this article assumes that you have not turned on ACLs (using Mac OS X Server or fsaclctl) on the filesystem you are wanting to back up. There are some subtleties in how these tools interact with ACLs that are beyond the scope of this article. Please consult the latest documentation for each tool for more details.

Links:

Tags: , , , , ,

Comments No Comments »

I really like the say command on my Mac’s. Great fun letting another mac in your building say something while someone else is using it.

I stumbled upon some nice tricks regarding the say command.

Examples:

ie you could play a simple melody like that:

say -v Good oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo oooooooooooooooooooooooooooooooooooooooooooooooo

Where “-v Good” defines the voice. You could use “-v Bad” too, or any other system voice. if you dont define a voice yourself, say will use the default voice defined in System Preferences

Check the apple link at the end of this post for more details on the say command.

You could  try something more creative like that:

osascript -e ’say “Dum dum dee dum dum dum dum dee Dum dum dee dum dum dum dum dee dum dee dum dum dum de dum dum dum dee dum dee dum dum dee dummmmmmmmmmmmmmmmm” using “Pipe Organ”‘

Best snippet i found so far:

osascript -e ’say “oh This is a silly song silly song silly song this is the silliest song ive ever ever heard So why keep you listening listening listening while you are supposed to work to work to work to work its because i hate my job hate my job hate my job its because i hate my job more than anything else No its because youve no life youve no life youve no life and you better go get one after forwarding this crap” using “cellos”‘

Great =)

Links:

Tags: , , , , , , , ,

Comments 1 Comment »

I stumbled upon SystemStarter while searching a way how to restart a service in Mac OS X.

Quote from the man page:

The SystemStarter utility may be used to start, stop, and restart the system services which are described in the /Library/StartupItems/ and /System/Library/StartupItems/ paths

Example:

  1. Restart NetInfo: sudo SystemStarter restart NetInfo
  2. Restart Printing / CUPS: sudo SystemStarter restart PrintingServices

I guess the missing part now is a full listing of the Services…lets see if i can find the time to collect them later.

Links:

Tags: , , , , , , , ,

Comments No Comments »

Description:

iSSH is a front-end application to the command line application “ssh”. It provides a quick and easy way to start an SSH connection to a remote computer. You may be asking, “What’s the point of running SSH without an interactive command prompt (Terminal)?” Well, running SSH in the background will not supply a prompt, but, it will forward ports. This is the main purpose of iSSH. You can set two options with iSSH; which ports to forward to the remote computer, or, to start an SSH SOCKS proxy. The first could be used to forward a VNC connection over SSH and the latter could be used to bypass your work’s website filters! Either way, it provides a simple way to start an SSH connection for those who are afraid of the Terminal or just don’t need it.
Links:
Tags: , , , , ,

Comments No Comments »

for sure its quite easy to get the Mac OS X Version string using the “About this Mac”-dialog. but what if you need to get the same result from command-line ?

Lets take a quick look:

  • Open terminal.app ( in /Applications/Utilities )
  • Enter: /usr/bin/sw_vers

This should end up in a similar output to my one:

MacPro:~ fidel$ /usr/bin/sw_vers
ProductName:    Mac OS X
ProductVersion:    10.5.2
BuildVersion:    9C7010
MacPro:~ fidel$

Tags: , , , , ,

Comments No Comments »

Just in case you have deleted a pre-installed Apple application here some ideas how to get them back.

Idea 1:

  • Insert your Mac OS Install CD
  • Open Terminal.app and goto /Volumes/yourMacCD
  • Navigate to the /Applications folder of the CD and copy the file somewhere to your Desktop or similar

Idea 2 - for packages:

  • You can use Pacifist to extract a package from the Mac OS X install CD/DVD

Just keep in mind that if you get an Application from your Install-Cd it might be outdated. But well better then nothing.

Tags: , ,

Comments No Comments »

Raw copy/quote from macosxhints.com:

If you don’t want to manage server lists for tab completion with ssh, put the following line in your .bash_profile file in your home directory:

complete -W “$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ‘ ‘ | sed -e s/,.*//g | uniq | grep -v “\["`;)" ssh

This will allow you to tab complete any hostname you've previously ssh'd to.

[robg adds: This worked as described for me. The complete command is a built-in bash function that lets you specify lists of options to be used with tab completion on a given command. The version above parses your known_hosts to create the list of options. You can read more about the complete built-in function in the bash man pages -- man bash, then search for the section titled Programmable Completion.]

Tags: , , , ,

Comments No Comments »

1234»