Linux Tips

Shell Tips

  1. End a text program that is hanging (i.e. in an infinite loop)
    Press ctrl-c (with the correct terminal in the foreground). This can often, but not always be used to escape from interactive programs as well.
  2. End a misbehaving graphical program
    Use ps to find its process id (also printed in terminal when programs started), then kill [
    PROCESS ID]. Despite the name, this asks the program nicely to end. If it doesn't work, try kill -9 [PROCESS ID] which forces it to end.
  3. Run a graphical programs from the command line
    Add an ampersand (&) at the end of the command to fork the process (run the program in a new process).
    I you do this, you can press enter to get a prompt and continue using the terminal. If you don't, the prompt won't return until you close the program or enter ctrl-c, and closing the terminal also kills the graphical program.
  4. Take advantage of the command history
    Press the up key to recover the most recent command. Use up and down to scroll through the entire history.
  5. Take advantage of auto-completion
    When entering a command name or filepath, type just the first few characters and press tab to have the shell attempt to complete it. If there are multiple possibilities, the shell will display them. Type a few more characters and press tab again, repeating as necessary. Once you get the hang of it, this makes dealing with long path names much easier.

Useful Text Programs

  1. mail -- send text via email
  2. mutt -- send attachments via email

Shell Configuration

  1. Create aliases for common commands.
    Edit the ".aliases" file in your home directory. Follow the format used for the existing aliases.
  2. Enable file/folder coloring with "ls"
    Edit the ".aliases" file and add the following entry to the top (before any commands that use "ls"):
    $ alias ls 'ls --color=auto'
    This makes navigation somewhat easier.

See Also

Last updated 12/22/12