For those who are just starting to learn emacs, the key command sequence to save a file is:
Ctrl x s
That means hold down the Control key, tap the x key once, and the s key once, let go of Control key. If you're used to using "Cntl+s" in a graphical progam to save file, this key binding might seem a little awkward at first but you'll get used to it quickly.
You can also choose whether or not to save by simply exiting emacs and telling it "y" for "yes" or "n" for "no" when it asks you if you want to save your changes (also known as "Exit saving changes") by typing the "quit" key command sequence:
Ctrl x c
Emacs will then prompt you "Save file /path/to/filename? (y, n, !, ., q, C-r or C-h)" which means you must answer with one of the options listed inthe parenthesis. To save just tap the "y" key and you're done.
If you decide you don't want to save your changes, tap "n" for "no". Emacs will then double-check your decision by asking you:
Modified buffers exist; exit anyway? (yes or no)
Type "yes", which in this context means "yes I really do want to exit and discard my changes"
If you type "no" emacs will send you back to editing mode with Emacs still open and your unsaved changes still visible and accessable in the window.
Sunday, March 8, 2009
Tuesday, March 3, 2009
Installing Mac OS X software updates from the commandline
I don't know why I didn't know this existed earlier - it's the most helpful computer administration command I've found in a year.
Apple's Software updates can be downloaded and installed on Mac OS X with the command "softwareupdate". This makes Updating your OS X remotely via ssh a snap compared to using ARD or VNC.
The command:
softwareupdate -l
will scan the apple update site for pending updates, and display them complete with a commandline-friendly label (name).
You can then install the updates you want with
softwareupdate -i [update_label]
For example:
$ softwareupdate -l
Software Update Tool
Copyright 2002-2005 Apple
Software Update found the following new or updated software:
* JavaForMacOSX104Release7-1.0
Java for Mac OS X 10.4, Release 7 (1.0), 82580 [recommended]
$ softwareupdate -i JavaForMacOSX104Release7-1.0
The command output shows which upates are recommended and which will requite a system restart.
The install command prints out a handy character based progress meter while it's downloading and installing:
Downloading Java for Mac OS X 10.4, Release 7
Downloading Java for Mac OS X 10.4, Release 7
0..20..40..60..80..100
Expanding Java for Mac OS X 10.4, Release 7
Installing Java for Mac OS X 10.4, Release 7
0..20..40..60..80..100
Done.
This is one terrific feature!
Apple's Software updates can be downloaded and installed on Mac OS X with the command "softwareupdate". This makes Updating your OS X remotely via ssh a snap compared to using ARD or VNC.
The command:
softwareupdate -l
will scan the apple update site for pending updates, and display them complete with a commandline-friendly label (name).
You can then install the updates you want with
softwareupdate -i [update_label]
For example:
$ softwareupdate -l
Software Update Tool
Copyright 2002-2005 Apple
Software Update found the following new or updated software:
* JavaForMacOSX104Release7-1.0
Java for Mac OS X 10.4, Release 7 (1.0), 82580 [recommended]
$ softwareupdate -i JavaForMacOSX104Release7-1.0
The command output shows which upates are recommended and which will requite a system restart.
The install command prints out a handy character based progress meter while it's downloading and installing:
Downloading Java for Mac OS X 10.4, Release 7
Downloading Java for Mac OS X 10.4, Release 7
0..20..40..60..80..100
Expanding Java for Mac OS X 10.4, Release 7
Installing Java for Mac OS X 10.4, Release 7
0..20..40..60..80..100
Done.
This is one terrific feature!
Wednesday, October 15, 2008
Emacs Example Tutorial: insert a block of text
As I explained in my previous Emacs tutorial on killing a block of text, it is sometimes hard to find easy to understand documentation on how to use emacs.
One of the first things I wanted to learn how to do in Emacs was block editing. By "block editing" I mean select a vertical area of text (one or more columns across multiple rows making a square or rectangle - you might call it zero or more since you don't actually have to select any characters, only the spaces between them) and do things to it - you might call it column editing or column mode or "Block Mode Editing" like in Kate, or UltraEdit.
Inserting a column of characters in emacs (without using a mouse) is really easy: you start by highlighting or selecting an area - when you do this you are said to "mark" the region.
You mark a region by positioning your cursor in one corner of the area you want to mark and hitting Control-Spacebar. You will see Emacs respond with the message "Mark set". Then navigate your cursor (I always use the arrow keys, but there is probably other ways to do it) to the opposite corner of the region you want to mark. The "region" is now marked as a rectangle between wherever you started (when you hit Ctrl-Space) and wherever your cursor is now sitting. Note that you don't do anything special to mark the end of the region -- the end is where ever your cursor is positioned.
Emacs calls the space you've now selected the "region-rectangle". Once it's highlighted, you can insert characters into the region by typing:
C-x r t
(That means press x while holding down the control key, release both keys, press and release the r key, press and release the t key). Emacs will respond with the message "String rectangle": it is asking you what text you wish to insert. Type what ever characters (letters) you want to "paste" into the region, and hit enter. It will automatically fill in that same text on every line that you've selected in your region.
I find this to be a great way to comment out areas of code with # characters. Emacs also has a "comment region" command which sometimes works, but occasionally emacs is too smart for it's own good and doesn't know what comment character to use (in which case it will usually ask you which to use with the question "No comment syntax is defined. Use:"), or worse it will use the wrong one.
You can use the comment region function by selecting a region in the same manner descried above, then type:
M-x comment-region
(That means press x while holing down the ALT key, release both keys, type "comment-region" - without the quotes of course - and hit enter).
I find C-x r t easier and faster to use than "M-x comment-region" in most cases anyway. It's fewer letters to type, even when you consider tab completion.
One of the first things I wanted to learn how to do in Emacs was block editing. By "block editing" I mean select a vertical area of text (one or more columns across multiple rows making a square or rectangle - you might call it zero or more since you don't actually have to select any characters, only the spaces between them) and do things to it - you might call it column editing or column mode or "Block Mode Editing" like in Kate, or UltraEdit.
Inserting a column of characters in emacs (without using a mouse) is really easy: you start by highlighting or selecting an area - when you do this you are said to "mark" the region.
You mark a region by positioning your cursor in one corner of the area you want to mark and hitting Control-Spacebar. You will see Emacs respond with the message "Mark set". Then navigate your cursor (I always use the arrow keys, but there is probably other ways to do it) to the opposite corner of the region you want to mark. The "region" is now marked as a rectangle between wherever you started (when you hit Ctrl-Space) and wherever your cursor is now sitting. Note that you don't do anything special to mark the end of the region -- the end is where ever your cursor is positioned.
Emacs calls the space you've now selected the "region-rectangle". Once it's highlighted, you can insert characters into the region by typing:
C-x r t
(That means press x while holding down the control key, release both keys, press and release the r key, press and release the t key). Emacs will respond with the message "String rectangle": it is asking you what text you wish to insert. Type what ever characters (letters) you want to "paste" into the region, and hit enter. It will automatically fill in that same text on every line that you've selected in your region.
I find this to be a great way to comment out areas of code with # characters. Emacs also has a "comment region" command which sometimes works, but occasionally emacs is too smart for it's own good and doesn't know what comment character to use (in which case it will usually ask you which to use with the question "No comment syntax is defined. Use:"), or worse it will use the wrong one.
You can use the comment region function by selecting a region in the same manner descried above, then type:
M-x comment-region
(That means press x while holing down the ALT key, release both keys, type "comment-region" - without the quotes of course - and hit enter).
I find C-x r t easier and faster to use than "M-x comment-region" in most cases anyway. It's fewer letters to type, even when you consider tab completion.
Labels:
administration,
computer,
linux,
Mac OS X,
system administration
Tuesday, October 7, 2008
Linux on a Dell Vostro 1710 laptop - don't try it [yet]
Recently my company needed a new laptop for one of our employees. After my great success with installing SuSE Linux on a Dell Vostro 1700 laptop, we decided to buy a Dell Vostro 1710, hoping that it would have better, newer hardware and still work with SuSE.
Wrong.
For this first time in my entire 11+ years of using Linux, the installer could not use the trackpad or even the keyboard. Yes, you read that right. I was able to complete the install with an external USB mouse and keyboard, but after the install finished and I rebooted the system without the peripherals (hoping that it was only the installer having trouble), the laptop's built-in keyboard and mouse still wouldn't work. I can't image what Dell has done to prevent detection/use of a simple keyboard.
I never bothered to try the other hardware (camera, etc) - we sent the 1710 back and bought a refurbished 1700.
I strongly suggest nobody buy a 1710 until at least another round of distros has been released this coming winter or spring. It was openSuSE 11.0 that I tried on the 1710 - perhaps 11.1 will work with the 1710, but I'm sure I won't be ordering another one to try it on.
Wrong.
For this first time in my entire 11+ years of using Linux, the installer could not use the trackpad or even the keyboard. Yes, you read that right. I was able to complete the install with an external USB mouse and keyboard, but after the install finished and I rebooted the system without the peripherals (hoping that it was only the installer having trouble), the laptop's built-in keyboard and mouse still wouldn't work. I can't image what Dell has done to prevent detection/use of a simple keyboard.
I never bothered to try the other hardware (camera, etc) - we sent the 1710 back and bought a refurbished 1700.
I strongly suggest nobody buy a 1710 until at least another round of distros has been released this coming winter or spring. It was openSuSE 11.0 that I tried on the 1710 - perhaps 11.1 will work with the 1710, but I'm sure I won't be ordering another one to try it on.
Monday, March 24, 2008
Setting the computer hardware clock (BIOS or CMOS) from inside a running Linux system
Normally after setting the date and time in Linux (for example using the NTP service or ntpdate, you can set the hardware clock to match with the following command:
hwclock --systohc
That way when you reboot, your clock will still be correct (or close to it).
I've discovered that this method does not work on the newer Dells, such as our 1U PowerEdge 1850s. Supposedly this has something to do with the kernel RTC module, and hardware changes. However, the following command appears to set the clock just fine on the problematic Dell servers:
hwclock --systohc --directisa
hwclock --systohc
That way when you reboot, your clock will still be correct (or close to it).
I've discovered that this method does not work on the newer Dells, such as our 1U PowerEdge 1850s. Supposedly this has something to do with the kernel RTC module, and hardware changes. However, the following command appears to set the clock just fine on the problematic Dell servers:
hwclock --systohc --directisa
Friday, December 21, 2007
Wednesday, November 28, 2007
How to enable the root user in Mac OS X using NetInfo, or change root's password:
- Open the NetInfo Manager utility (located under /Applications/Utilites/).
- Click the lock (padlock icon) in the NetInfo Manager window.
- Enter an administrator account name and password, then click OK (this isn't Administrator as in root, it's Administrator as in a user account with administrative privileges, typically the first account created during the initial install or setup).
- For Mac OS X 10.2 and later, choose Enable Root User from the Security menu.
- If you have not previously set a root password, an alert box may appear that says "NetInfo Error," indicating that the password is blank. Click OK.
- Enter the root password you wish to use and click Set.
- Enter the password again for verification and click Verify.
- The root user is now enabled.
- Click the lock again to prevent changes.
Subscribe to:
Posts (Atom)