Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


Random things I've discovered recently (Don't laugh)

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Author Message
gravies



Joined: 30 Jan 2005
Posts: 6

Posted: Fri Jun 24, 2005 8:39 pm    Post subject: Random things I've discovered recently (Don't laugh)  

I've been using Linux on and off since RedHat 5.0 and along the way I've never really bothered to RTFM that often. This leaves huge gaps in your knowledge but when you find a solution to something it seems like a revelation. Thanks to people on #linode for some of these. Some random finds in no particular order:


Programs

firehol - front end to iptables for those of us who don't know iptables by heart. It uses a simple configuration file to setup servers and clients. There is some debate as to whether you need a firewall on a linode, but the safer bet is to have something. If you aren't an iptables master this might be a good solution. I tired shorewall briefly but ended up liking firehol more.

monit - as the name suggests this monitors various services on your system and can restart, stop, alert and other stuff. I found this very useful on my Linode64 to restart mysql or apache if load average was above a set level.

munin - munin creates graphs of system activity, services, io_status, and much more. It was apt-gettable, simple to setup and quite pretty. It may also be more secure than cacti (recently exploited)

screen - this little beauty is a must for console access. If your connection is broken then you can just detach the screen when you log back in and then attach right where you left off.

irssi - text irc may seem dated to some but using screen and irssi you can remain connected and track back through the history despite moving around irl.

elinks - enhanced links makes lynx look ancient. In an xterm-color it is very impressive and even has CSS support.

logcheck - looks through your logs and emails you anything dodgy. Currently sending me too much info about

Websites

tldp.net - an old one but always useful. They have palmdoc versions of HOWTOs, for when you are really bored, but no man pages for palm as far as I could find.

dnsreport.com - this was invaluable for me to get my bind9 configuration right.

http://workaround.org/articles/ispmail-sarge/ - a good guide to setting up mail on your box

Gotchas

/lib/tls - any weirdness - check for this and move out of the way if you find it.

lock out - lish is invaluable if you get blocked out for any reason. This is all explained in the member section but don't forget about it.

boot failure - if you are in deep trouble and your machine won't boot, install debian on your swap partition, boot from that and fix0r.

slowness - this is often caused by thrashing and lack of tokens. If, like me you didn't read about tokens in the wiki, then do so. Short version is that /proc/io_status shows you how you are doing. If you are low on io_tokens you are in trouble. If you have token_refill of 100 you may be a thrasher and you need to put in a ticket.

ssh-bruteforce - even if you have a firewall kiddiez will try and break in by bruteforce attack on ssh. Use mikegrb's script in these forums to lock them out with iptables. Make sure you edit the whitelist! You'll need ulogd installed for logging.

memory

mysql - this beast is a memory hog. Use caker's my.conf and add skip-innodb too to reduce memory. Don't let mysql log too much, if any, info - this can cause massive I/O and token loss.

apache - change the MaxClients, MaxSpareServers, StartServers to lower values, play around a bit. Remove modules you don't need.

remove everything - check every service you are running and see if you need it (this is obvious but do it anyway)

commands

tac - reverses a file (cat<->tac)
uniq - remove duplicate lines from a file
memstat - show breakdown of virtual memory
lsof - shows all open files
sysvconfig - simple way to control what starts on boot

console

The console is much less of a mystery if you actually read `man bash` again... you probably know a lot but there are many I didn't know some highlights:

Meta-DEL - delete word
Meta-b / f - back / forward word
Ctrl-u - delete to start of line
Ctrl-a - jump to start of line
!!:gs/foo/bar/ - replace foo with bar in previous command
set -o vi - go into vi key binding mode (I love vim but this is scary)
Back to top  
Ciaran



Joined: 13 Feb 2004
Posts: 138
Location: England, UK

Posted: Sun Jun 26, 2005 2:26 pm    Post subject:  

I've been using Linux as my desktop OS for a couple of years now and even I learned something from your post - up to now, I was totally unaware of the existence of tac. You learn something new every day. :D

I also didn't know of the "!:g" notation. Nice.
Back to top  
graham



Joined: 22 Mar 2005
Posts: 38
Location: London, England

Posted: Mon Jun 27, 2005 10:44 am    Post subject: Thanks  

Thanks gravies I found your list very helpful.
Back to top  
sweh



Joined: 13 Apr 2004
Posts: 211

Posted: Tue Jun 28, 2005 11:35 am    Post subject:  

!!:gs/foo/bar/ - replace foo with bar in previous command

That's almost the same as
^foo^bar
(except the "g" means do it globally)

In general, history commands can specify a specific line in your history
eg
!50:s/foo/bar/
would replace "foo" with "bar" in line 50 of your history. Or
!-2:s/foo/bar/
would do it for the previous two lines.

FWIW, that style of history substitution comes from csh
Back to top  
ferfer



Joined: 12 May 2005
Posts: 36

Posted: Thu Jun 30, 2005 4:11 pm    Post subject:  

Another useful command (at least, for me)

tee - let you save in a file what you're watching on console. Very useful to log looooong outputs.

Usage:
Code: command | tee newfile
command | tee -a filetobeappended
Back to top  
razza



Joined: 25 Jan 2005
Posts: 26

Posted: Sun Jul 03, 2005 8:54 pm    Post subject:  

or you can try this for example:
command > /somefile.txt
e.g.

ls -l > /somefile.txt

works nicely for me :)
Back to top  
caker



Joined: 15 Apr 2003
Posts: 2346
Location: Galloway, NJ

Posted: Sun Jul 03, 2005 8:57 pm    Post subject:  

razza wrote: or you can try this for example:
command > /somefile.txt
e.g.

ls -l > /somefile.txt

works nicely for me :)
Right, but you don't see the results as they're going into the file. "tee" does that.

-Chris
Back to top  
 
       Linode.com Forum Forum Index -> Linux Tips, Tricks, Tutorials
Page 1 of 1