link to cgstock.com homepage
home site info image licensing newest video prints

Other sections:

Useful Linux Commands

I keep a textfile in my home directory that lists useful linux shell commands, including the exact arguements required. This has been a valuable memory aid. I've copied some of this file below (lines that begin with the pound character (#) are comments). Note: I have a short video of some commands in action here: Linux CLI tutorial 1

disclaimer: these commands were discovered through research and trial & error. Although they worked for me on my installation (RedHat Linux 8 and 9, and later Fedora and Gentoo), I can't vouch for them. Use your own discretion and read the man pages.

#convert a postscript file to another format
convert file.ps file.jpg
#which can be viewed width "display" (requires ImageMagick)
display file.jpg

#I've found it very 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 

#to find the location of a command's executable,
#use "whereis", such as to locate the startx script:
whereis startx

#to look for a file not in your path, such as your
#X configuration file, use "locate":
locate xorg.conf

#to list all fonts installed on your syste:
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
#file in a browser and "print to file"(.ps format). Then use:
ps2pdf file.ps file.pdf

#directory usage, list the size of directories
du -ch

#amount of swap space used
free

#change the prompt to show 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 with "apropos"
apropos term

#Perl can be used to perform a regular expression substitution
#on a series of text files, making backups, using a single command.
#Test your regular expression before applying it to a large group
#of files. In the example below, the backup files will have the
#extension ".bak".
perl -pi.bak -e 's/foo/bar/' filelist

#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

#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)
If you have any commands to add, or comments on the above, post them below.

This page last modified on 2007-12-05

Post a comment on this page

cgstock.com provides quality stock photos for commercial, fine-art, education, and non-profit use, with an emphasis on pictures of the Twin Cities of Minneapolis and St. Paul, Minnesota and China & the Philippines.
phone cgstock.com at 612-245-4306   email us:chris@cgstock.com
Chris Gregerson, 150 Green Ave. N., New Richmond, WI 54017 USA
home   |   licensing information   |   site info   |   web development services
http://www.cgstock.com/