# It is often useful to pipe the results of a # MySql query. The below will execute # an SQL select statement and pipe result to a textfile mysql database_name -e "sql statement" > sql.txt # startx with an error log startx 2>&1 | tee startx.log # to check the settings being used for your Xserver # (like xinerama), use "whereis" to locate the startx script: whereis startx # then edit that shell script to add server arguments, like: startx -- +xinerama # to add Xinerama support, although this can be in the # config file found in /etc/X11/XF86Config-4. # to find out what package something belongs to: rpm -qf /path/to/mysterious_file # To modify font sizes, so that 12 points looks like # you expect, you can specify the dpi for the Xserver: startx -- -dpi 100 # to find what the Xserver currently thinks your dpi is: xdpyinfo | grep resolution # to list all fonts: xlsfonts # to fax under linux, assuming you have all the # standard packages for this installed, and have # printed your document to a postscript file: fax send -v 123-4567 file.ps # to make a pdf file from an HTML page, first view the HTML # in a good browser and print to file(.ps). Then use: ps2pdf file.ps file.pdf # directory usage, list the size of directories du -ch # amount of swap space used free # convert a man page to a textfile man command | col -b > command.txt # change the prompt to the current directory and current time: PS1="[\W \@]" # tell me the date and time date # tell met the date as YYYY-MM-DD date +%Y-%m-%d # If I can't remember a command, you can search # for all commands related to a term apropos term # when copying directories, hidden files are skipped. # They can be copied by stipulating "cp .*", but then # hidden directories aren't copied recursively. This is an # issue when I backup my email folders (Kmail), because # hidden files and directories are used. But there is a # command to copy directories recursively, including # hidden files and directories: rcp -r original new # Perl can be used to perform a regular expression substitution # on a series of text files, making backups, using a single command: perl -pi.bak -e 's/foo/bar/' filelist # Note: use with caution. Test your regular expression before applying it # to a large group of files. In the example above, the backup files will # have the extension ".bak". # Make a man page from a perldoc: pod2man Photos.pm > /usr/share/man/man3/Photos.3pm # after that, "man Photos" will display the Photos module documentation # in manpage format. # make an Xauthority file for user Chris mkxauth -u Chris -c # find files larger than 1 Megabyte modified less than 250 minutes ago find / -size +1000k -mmin -250 # to convert a postscript file (.ps) to .jpg, thumbnail size, with ghostscript: gs -sDEVICE=jpeg -sOutputFile=file.jpg -r20 file.ps # if booting from a boot disk, and it's necessary for some reason # to boot into a shell with only the "/" partition mounted (e.g. other # partitions have errors), enter the below at the "boot>" prompt: linux init=/bin/sh # RedHat installations use "cups" for printing # instead of lpd. The below command will print # multiple copies of "class3.ps" collated (in this case, 14 copies) lpr.cups -#14 -o Collate=True class3.ps # to do a screen capture of a single window, saved as "file.jpg": import file.jpg # to make a tar file of all html files in /www tar -czf pt.tar.gz /www* # to list files in a gzipped tar archive: tar -ztf pt.tar.gz # to see the cookie for a website (not limited to Linux), # type the below in a web browser's address window and hit enter javascript:alert(document.cookie)