Archive

Posts Tagged ‘bash’

Shell Shortcuts

January 21st, 2008 Christer Edwards 9 comments

I was tearing away this morning configuring something in the shell. My wife peaks over my shoulder and says “How do you do that?!” I have a nice laugh and there was born an idea for my next post. This post outlines
some basic shell shortcuts. note: these use the default shell bindings, based on emacs.

Shell Shortcuts

First lets start with some simple stuff.

Clearing the screen. I still see a lot of people using the old ‘clear’ command to do that. A shorter method is:

ctrl-l

Exiting the shell or logging out. I’m sure the most common way to exit your terminal session is using the ‘exit’ command. This can also be done with:

ctrl-d

Searching the history. I’m guessing you’re familiar with using the up/down arrow keys for finding previous run commands. Did you know you can search through your history too, helping avoid hitting up a hundred times.

ctrl-r + command

The above will find the most recent match. If you’d like to go further back hit the key sequense again and it’ll toggle through matches of ‘command’ deeper into your history.

Using the previous argument. This is one of my favorites, and really can save some typing and monotony. You can drop in previously used arguments to your current commands with:

esc-. or alt-.

These are all that came to me off the top of my head. What other shortcuts do you use for the default shell? I’ll have a future post about set -o vi, so if you’ve got tips for that hold them for now.

You also might be interested in an earlier post on using copy and paste within the terminal.

If this article has been helpful, please consider linking to it.

Categories: Linux Tags:

How to Enable or Disable Login Messages

December 9th, 2007 Christer Edwards 9 comments

Suppressing Login Messages

I do a lot of remote remote maintenance via ssh on my machines and one thing that I’ve long wondered about is the message outputted when you login.  You know, the system information output plus the notice concerning the warranty, etc.  Here is the output I’m referring to when connecting to my Sun Sparc Ultra 10 server via ssh:

Linux sparc 2.6.15-51-sparc64 #1 Tue Oct 23 21:46:00 UTC 2007 sparc64 GNU/Linux

The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
Last login: Sun Dec  9 12:50:43 2007 from 192.168.0.6

Now, that information is not ultra annoying by any means, but sometimes after repeated connections I just really don’t want to see it.  So, I finally found way that the information above can be suppressed.  All you need to do is create an empty file in your home folder and those login messages will be suppressed.

touch .hushlogin

Run that command, which just “touches” a file into creation with no contents.  If the login system finds that file it’ll suppress the login message above.  Note: if you want login messages suppressed on remote machines you need to create this file on the remote end.

Enabling Login Messages

The login message above actually comes from a file on the machine at /etc/motd.  If you’d like to change the message on your machine you can simply edit that file.

sudo vim /etc/motd

If you’d like to enable a different login message, which can often be used to pass messages to anyone logging into the system, this might be a good place to do it.

Categories: Linux Tags: ,