________SWAT MAGAZINE ISSUE TWENTY THREE: NOVEMBER 1999_________ / \___________________________________________/ \ / Linux Hints and Tips \ / Bt DeathRow \ ----------------------------------------------------------------------- Here is just a couple of Linux related tricks, commands and general stuff that linux users might find useful: Commands -------- grep ---- grep is the KING of linux commands. Learn to live by it. In its default mode, it excludes everything from its input pipe that doesnt match the search criteria. | grep example: pgpk -l | grep @ will give me a list of email addresses on my PGP5i (www.pgpi.com getitNOW) keyring, along with their public key information. If I wanted to check whether I had a gates@microshaft.com on my keyring, I'd issue a: pgpk -l | grep gates@microshaft.com If nothing was printed, then I dont. If however, I do have his key, then I'll receive a line along the lines of: PUB KEY ID <893498394> gates@microshaft.com I dont have linux up at the moment so this is a guess of the real output, but you get the idea. Grep is particually usefull when I want to view extended info on a directory. If I used #ls -l root I'd get the contents of my root directory (if logged in as root) however, I dont want that, I want to view the file permissions of the directory itself. What do I do? I use grep: #ls -l | grep root bingo, extended information on the root directory. Nice. grep has many other options and usages, just info or man grep for more. One particually useful option is grep -v, which includes everything that doesnt match the search criteria. Ie: Crap! A disaster has occured! While experimenting with perl scripts, I have managed to flood my home directory with 10000 1 kb files starting with 'frog'! (dont ask me what I was doing). However, one file called frog776 I want. How do I delete every frog but frog776? Yup, you guessed it, with grep. I simply issue a: #ls | grep -v frog776 | rm -f viola. I should be left with only 'frog776' in my directory Hopefully you now apprichate the power of grep. An interesting development is the ongoing work at www.packetfactory.net (admined by route of phrack) to develop grep's cousin, ngrep. ngrep is a network version of grep which allows you to filter packets in the same way as you would files with grep, allowing you to ignore those nastily fragmented DOS TCP packets for example, or filter through a sniffer log file looking for interesting packets. Check it out @ www.packetfactory.net [*] whatis and whereis ------------------ whatis whereis These little proggies are well useful for the beginning linux sysadmin swamped over by incidious unpronouncable commands. whatis gives you a one line description of the program you give it, if its in its database. whereis tells you where a command on your path (one that you can execute without being in the present working directory) is. ie: # whatis ls ls [1] - Prints a list of files in the current working directory # whereis ls /bin/ls Even better is the fact that you can issue a whatis *. Ie: # cd /bin # whatis * ls [1] - Prints a list of files in the current working directory rm [1] - Removes a file or directory ... etc Useful for finding a command to do something without having to sift through stacks of man pages. Ok, thats enough commands for now.. if you're still stuck or need more assistance on command for linux, get Linux in a Nutshell by O'Reilley publishing (www.ora.com). It gives you a complete list of the standard commands with verbose descriptions. X Windows & FVWM2 ----------------- X Windows.. aah. The truely configurable GUI for linux. Or it is if you know how to configure it. First let me explain a few things. X Windows runs on a server/client basis. You run the x server specific to your graphics card and you connect to it when you run startx. X windows was designed for network computing, so you can run multiple x clients connecting to the same server. A Window Manager is an application for X windows which controls the size, height, colour, position etc, of the windows that you run. This is the 'configuarable' part of X windows, unless you are into TCL/TK and applications programming. Today I am going to discuss configuaration of a particular window manager called FVWM2 - F? Virtual Windowing Manager 2. No one knows what the F standed for, or stands for, but the acroymn has stuck. OK, enough smalltalk. To install FVWM2, you'll need to remove the existing window manager that came with your distribution. Usually if you select to install X, the distro script will install a window manager for you, with a 'nice' configuration. RH5.2 for example, by default installs a really crap window manager 'manager' called AnotherLevel. Stay clear, remove and install the latest version of FVWM2 is what I always do. Anyway, now I am assuming that you have installed FVWM2 and you have a nice clean install. If you go into /etc/X11/FVWM2 directory, then you should see the worldwide configuartion file for FVWM2, called 'system.fvwm2rc', Any changes you make to this file will effect all users on the system. If you delete this file, fvwm2 will panic, and wont let you run anything until you a) reinstall fvwm2 or b) rebuild system.fvwm2rc from scratch. Neither are particually pleasent things to do, so leave the file alone. To configure fvwm2, you'll need to copy the system file to your home directory to .fvwm2rc or .fvwm2rc95 depending on your version. I havent got time to explain the config file in its entirity - there are web sites devoted to that, all I will do in this limited space is to show you a few neat tricks you can use to set up your fonts. First, find this section in your config file: # # Fonts - one for window titles, another for icons, and another for the menus # WindowFont -bitstream-charter-bold-r-normal--16-80-0-0-*-0-iso8859-1 IconFont fixed #MenuFont -adobe-helvetica-medium-r-*-*-*-120-*-*-*-*-*-* These fonts are standard X fonts. You need to find a program call xfontsel. On my box its in the /usr/X11R6/bin/ directory, but it will vary. Once found, run it under X and it will present you with a number of drop down combo boxes with a lot of options. Tweak these combo boxes and the displayed text will change shape, width, height, boldness etc. Once you are satisfied with your selection, select copy font, and copy it into your .fvwm2rc file, which should be ideally loaded in an editor on an xterm. Reboot fvwm2 and viola, your fonts will have changed. Keep fidling until you are satisfied. You can download other fonts from various websites if you want to customise your fonts even more. This is just a taster of what you can do with fvwm2. The fvwm2rc file is well documented and, as long as you dont touch system.fvwm2rc, messing around with it will not hurt your system. So, go ahead, play around and see what you can do with your x windows. Quickly before I move off the subject of fvwm2 - setting a backdrop. You can do this by running display on startup. There is a function that runs programs on startup, find that function in your rc file, add an entry saying: display -size 1280x1024 -window root The size is variable to the picture obviously, play around with it. Linux Resources --------------- There are a number of good linux resources on the 'net, as you'd expect, Linux being one of the most popular network operaing systems around. Here are just a list of a few I've found while browsing: www.zillennium.com - Linux distribution site, 2 pounds per CD. www.polo.demon.co.uk - Cheapbytes, another UK based cheap Linux distributer. www.linux-HOWTO.com www.linuxlinks.com http://linuxpower.org www.linuxstart.com - Good site for newbies. www.users.dircon.co.uk/~trix/Raven/ - Cool guide to building your very own linux box from scratch. www.magma.ca/~bklimas/ - Linux Newbie System Administrators Guide.. coolio www.cygnus.com - Free GCC win32 IDE howto.linuxberg.com/LinuxGuide/index.html - Good newbie guide. www.x.org - The main X www.x11.org - Windows Sites www.rahul.net/kenton/xsites.framed.html - Lee's X Links - 700 X links related to programming X mostly, but still worth a look. http://fvwm.math.uh.edu/ - The FVWM Home Page. Also, a new magazine has just come out from Future Publishing (PC Format/FHM people) on Linux.. its called Linux Answers or something. Anyway, after having looked through the first edition I would highly reccomend it for anyone considering venturing into Linux or any Linux newbie. End --- I hope you have found this article informative. Ultimatly the best way to learn more about Linux is to play around and read man pages and online tutorials. If you need any more help with Linux, email me and I'll see what I can do. [Deathrow] [t1nk@bigfoot.com] ["No one expects the spanish inquisition!"]