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 1disclaimer: 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 system: 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) #to see all the hard drives on a system, as /dev/devicename, #run (as root): fdisk -l #to see a list of all pci devices connected to your system lspci #to see all volume groups visible under lvm2 (logical volume management) vgscan #to make a volume group active vgchange -ay VolumeGroup00 #to see all the logical volumes visible under lvm2 lvdisplay #to mount a volume group (using the volume group name and #logical volume names found): mount /dev/VolGroupName/LogVolName /mnt/point #use vim to edit the file which controls mounting devices (like hard #drives)...see "man fstab" for more info vim /etc/fstabIf you have any commands to add, or comments on the above, post them below.