Is there a cheatsheet for linux commands to save your system?

I've recently lost my window options, had to somehow manipulate my way to Xchat and ask some people how do I get it back (it was metacity --replace, and after I decided to stop the command and run it in background the X was completely useless so I had to do killall -u user). And that was after the internet connection stopped working for some reason (might've been the ISP).

The thing is, after using linux a long time, I still get the feeling that on dire situations, I don't know the good tricks (stuff like metacity --replace). I feel like a really need like a "rescue" cheatsheet for things like:

  • how to save the X no matter what without pressing reset
  • how to reset the system to "normal state"
  • how to connect to the internet through the command line
  • how to monitor what the X is doing (using ubuntu linux 10.04 btw)

X

If it's working: Ctrl-Alt-Backspace.

Ctrl-Alt-F[1-6] go to terminal.

Ctrl-Alt-F7 - go to X

Restart XDM in most distros:

/etc/init.d/xdm restart

Or find X processes PIDs

ps aux|grep "[Xx]"

and kill them. Then start new X

startx

X logs: /var/log/Xorg.0.log

Internet

Using dhcp:

dhclient interface 

Interface could be eth0. Without

ifconfig ...

or

ip

(see man for more)

Not sure how Ubuntu works, but i think you can restart your network connecting using some kind of /etc/init.d script. Check server guide. Not sure, but I think that works for desktop edition too.

Other stuff

Useful terminal programs:

  • lynx,links - internet browsers
  • irssi - IRC client
  • mc - file manager
  • mcedit - simplest file editor ever
  • GNU and system utils - basic like: cat, tail, head, cp, rm, mv - must know!
  • top, ps - display Linux tasks
  • free - memory usage (but remember to look at buffors table, not mem)
  • man :)

Magic Resq Key

Wikibooks Freezes


I'm a programmer, so I use git daily.

I have found git very useful for monitoring changes (and eventually restoring in emergency cases) changes in config files.

Edit:

On my Ubuntu 10.04 LTS I do:

sudo /etc/init.d/network-manager restart

or

sudo service network-manager restart