This page contains instructions and links for setting up a clean install of Ubuntu 7.04 and Firefox. It was blatantly copied from this page and altered to use my own personal customizations. It serves more or less as a list of programs and Firefox addons/scripts that I've installed for quick reference.
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.original
sudo apt-get install nvidia-glx-new sudo nvidia-glx-config enable
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup.sync_and_refresh sudo gedit /etc/X11/xorg.confFind the following section and fix the HorizSync and VertRefresh values:
Section "Monitor"
...
HorizSync 30-96
VertRefresh 50-160
EndSection
sudo gedit /etc/X11/xorg.confChange:
Section "Device"
...
Driver "nvidia"
...
EndSection
to:
Section "Device"
...
Driver "nvidia"
...
Option "NoLogo" "true"
EndSection
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup sudo gedit /etc/apt/sources.listAdd:
deb http://us.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse deb-src http://us.archive.ubuntu.com/ubuntu/ feisty main restricted universe multiverse deb http://us.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse deb-src http://us.archive.ubuntu.com/ubuntu/ feisty-updates main restricted universe multiverse deb http://us.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse deb-src http://us.archive.ubuntu.com/ubuntu/ feisty-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu feisty-security main restricted universe multiverse ## NTFS-3G ## deb http://ntfs-3g.sitesweetsite.info/ubuntu/ edgy main main-all ## deb http://flomertens.keo.in/ubuntu/ edgy main main-all ## Some multimedia stuff deb http://mirror.ubuntulinux.nl edgy-seveas all ## Fonts deb http://www.telemail.fi/mlind/ubuntu feisty fonts deb-src http://www.telemail.fi/mlind/ubuntu feisty fonts ## Google Picasa for Linux repository deb http://dl.google.com/linux/deb/ stable non-free
wget http://flomertens.keo.in/ubuntu/givre_key.asc -O- | sudo apt-key add - wget http://mirror.ubuntulinux.nl/1135D466.gpg -O- | sudo apt-key add - sudo wget -q http://medibuntu.sos-sts.com/repo/medibuntu-key.gpg -O- | sudo apt-key add - gpg --keyserver subkeys.pgp.net --recv-keys 937215FF gpg --export --armor 937215FF | sudo apt-key add -
Google repositories setup
sudo echo""
sudo apt-get install -y gparted sudo apt-get install -y ntfs-config sudo apt-get install -y gnomebaker sound-juicer sudo apt-get install -y mozilla-thunderbird sudo apt-get install -y acroread cups-pdf sudo apt-get install -y unrar sudo apt-get install -y picasa sudo apt-get install -y totem-xine libxine-extracodecs sudo apt-get install -y nautilus-actions nautilus-open-terminal sudo apt-get install -y ssh openssh-server sudo apt-get install -y cvs tkcvs sudo apt-get install -y build-essential autoconf manpages-dev sudo apt-get install -y gnuplot octave sudo apt-get install -y sun-java6-jre sun-java6-plugin sudo apt-get install -y flashplugin-nonfree sudo apt-get install -y mplayer smplayer sudo apt-get install -y vlc vlc-plugin-* mozilla-plugin-vlc mozilla-mplayer sudo apt-get install -y lame sox ffmpeg mjpegtools mpg321 vorbis-tools libdvdcss2 sudo apt-get install -y msttcorefonts sudo apt-get install -y numlockx deborphan alien sudo apt-get install -y qalculate sudo apt-get install -y kdebase-bin kdebase-data kdebase-dev sudo apt-get install -y amarok sudo apt-get install -y beagle sudo apt-get install -y kommander p7zip sudo apt-get install -y alltray preload thunar gnome-schedule sudo apt-get install -y libfreetype6 libcairo2 libxft2 sudo apt-get install -y apache2 ipcheck php5-mysql libapache2-mod-php5 mysql-server phpmyadmin mysql-admin webmin sudo apt-get install -y nautilus-gksu nautilus-image-converter nautilus-open-terminal
Desktop Data Manager (clipboard)
sudo cp /etc/fstab /etc/fstab.before.ntfs3g sudo gedit /etc/fstabAdd the following to the end:
/dev/hda1 /media/winxp ntfs-3g defaults,locale=en_US.utf8 0 0
sudo dpkg-reconfigure fontconfig-config sudo dpkg-reconfigure fontconfig
sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.beforeDesktopEffectsPerformance sudo gedit /etc/X11/xorg.confAppend the following in the "Device" section:
Option "AddARGBGLXVisuals" "True" Option "RenderAccel" "True" Option "AllowGLXWithComposite" "True" Option "backingstore" "True" Option "TripleBuffer" "True"
sudo cp /etc/X11/gdm/Init/Default /etc/X11/gdm/Init/Default_backup sudo gedit /etc/X11/gdm/Init/DefaultFind this line:
... exit 0Add the following lines above it
if [ -x /usr/bin/numlockx ]; then /usr/bin/numlockx on fi
sudo sed -i.backup -e's@vo=x11,@vo=xv,@g' /etc/mplayer/mplayer.conf
sudo sed -i.backup.acroread -e's@application/pdf=evince.desktop@application/pdf=AdobeReader.desktop@g' /usr/share/applications/defaults.list
sudo hdparm /dev/hdaTurn it on:
sudo hdparm -d1 /dev/hdaEnable it permanently
sudo gedit /etc/hdparm.confAdd the following lines:
/dev/hdc {
dma = on
}
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst_backup-`date +%F` sudo gedit /boot/grub/menu.lstFind this line
... # howmany=all ...Replace with the following line
# howmany=1Do not delete the # symbol.
sudo update-grub
sudo apt-get install -y localepurge
sudo deborphan | xargs sudo apt-get -y remove --purge
wget -c -P /tmp/ http://www.debian-multimedia.org/pool/main/w/w32codecs/w32codecs_20061022-0.0_i386.deb wget -c -P /tmp/ http://www.debian-multimedia.org/pool/main/libd/libdvdcss/libdvdcss2_1.2.9-0.0_i386.deb sudo dpkg -i /tmp/w32codecs_20061022-0.0_i386.deb /tmp/libdvdcss2_1.2.9-0.0_i386.deb
sudo update-alternatives --config javaSelect the appropriate Sun Java option.
nautilus-actions-configand twiddle away.
sudo gedit /etc/apache2/apache2.conf
sudo gedit /etc/php5/apache2/php.iniLook for the 'extension_dir' property. It should be by default '/usr/lib/php5/ext'. If it's not, change it.
mysql -u rootAt the mysql console type:
mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');
A successful mysql command will show:mysql -u root -p
mysql> CREATE DATABASE database1;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;
mysqladmin -u root -p password yourpassword mysqladmin -u root -p create database1
nautilus-actions-config
application/x-cd-image ; application/ogg ; application/vnd.rn-realmedia ; application/x-extension-m4a ; application/x-extension-mp4 ; application/x-flac ; application/x-matroska ; application/x-ogg ; application/x-shockwave-flash ; audio/mpeg ; audio/mpegurl ; audio/vnd.rn-realaudio ; audio/x-flac ; audio/x-m4a ; audio/x-mod ; audio/x-mp3 ; audio/x-mpeg ; audio/x-mpegurl ; audio/x-ms-asf ; audio/x-ms-asx ; audio/x-ms-wax ; audio/x-ms-wma ; audio/x-pn-aiff ; audio/x-pn-au ; audio/x-pn-realaudio-plugin ; audio/x-pn-realaudio ; audio/x-pn-wav ; audio/x-pn-windows-acm ; audio/x-real-audio ; audio/x-s3m ; audio/x-vorbis+ogg ; audio/x-wav ; audio/x-xm ; image/vnd.rn-realpix ; misc/ultravox ; video/dv ; video/mp4 ; video/mpeg ; video/msvideo ; video/quicktime ; video/vnd.rn-realvideo ; video/x-anim ; video/x-avi ; video/x-flc ; video/x-fli ; video/x-mpeg ; video/x-ms-asf ; video/x-msvideo ; video/x-ms-wmv ; video/x-nsv ; video/x-theora+ogg
sudo sysctl dev.cdrom.lock=0
sudo cp /etc/sysctl.conf /etc/sysctl.conf.backup.eject sudo gedit /etc/sysctl.confAdd the following line to the file:
dev.cdrom.lock=0
sudo mount /dev/hdb1 mountPoint -t reiserfs -o notail
sudo mount /dev/hdb1 mountPoint -t ext3
sudo mount /dev/hda1 mountPoint -t ntfs -o nls=utf8,umask=0222
sudo mount /dev/hda1 mountPoint -t vfat -o iocharset=utf8,umask=000
sudo mount /media/cdrom0/ -o unhide
sudo modprobe loop
sudo mount file.iso /media/iso/ -t iso9660 -o loop -r
sudo umount mountPoint
sudo umount -l mountPoint
dd if=/dev/device of=file.iso bs=1024If this step fails with an "input/output error", try various combinations of unmounting/remounting/ejecting the device:
sudo umount -l /dev/device eject /dev/device sudo mount /dev/device
mkisofs -o file.iso dir
md5sum file.iso > file.iso.md5
md5sum -c file.iso.md5
See the Unofficial Ubuntu Starter Guide for more information.
See https://wiki.ubuntu.com/FixVideoResolutionHowto for more information. The following worked for me:
cp ~/.xine/catalog.cache ~/.xine/catalog.cache.backup gedit ~/.xine/catalog.cacheFind the following section:
[/usr/lib/xine/plugins/1.0.0/xineplug_decode_w32dll.so] size=173768 mtime=1112804124 type=131 api=15 id=win32a version=10000 supported_types=50593792 52428800 52822016 ... (long line truncated) decoder_priority=1Replace (in this section only):
decoder_priority=1With:
decoder_priority=7
Only follow these steps if you experience choppy CD/DVD playback. See the Unofficial Ubuntu Starter Guide for more information.
sudo hdparm -d /dev/device
where device is cdrom, cdrom1, dvd, etc. sudo hdparm -d1 /dev/device
sudo cp /etc/hdparm.conf /etc/hdparm.conf.backup.dma
sudo gedit /etc/hdparm.conf
Append the following to the /etc/hdparm.conf
/dev/device {
dma = on
}
where device is cdrom, cdrom1, dvd, etc. sudo gedit /etc/fstabReplace:
/dev/hda1 /media/hda1 vfat defaults,utf8,umask=007,gid=46 0 1With:
/dev/hda1 /media/hda1 vfat iocharset=utf8,umask=000 0 0Note that occurences of hda1 could be different (e.g., hdb2) for you, depending on the disk and partition number of your FAT32 partition.
See CFS's "Connecting to Herakles using SSH" page and this example ~/.ssh/config file for information specific to CUCS tunneling.
nano ~/.ssh/configAdd:
host bastionHostName user bastionUserName hostname bastionHostName.bastionDomain ForwardAgent yes LocalForward 2001 targetHostName.targetDomain:22 host targetHostName user targetUserName hostname localhost port 2001
ssh -fN bastionHostName
ssh targetHostName
Quick explanation:Public key authentication works as follows. First you create a public key and a private key. Think of the public key as being a lock which only opens with the private key. The private key should reside only on your local machine and is stored in encrypted form using a passphrase that you choose when you first create the key. Never send your private key to anyone. The public key is copied to the various systems that you want to access. Once the public key is installed on another system, you can access that system using your private key as authentication. This authentication is done automatically and there is no need for a password entry. You do however need to enter your passphrase in order to decrypt the private key on your local machine in the first place, but you can do this just once per session on your local machine (e.g., when you first log in to your local machine). This will store the decrypted private key in memory until you log out or until you manually tell the local machine to forget the decrypted private key.
ssh-keygen -f ~/.ssh/keyFile -t dsa
I highly recommend using a non-empty passphrase; you can later set up key management so that you only enter your passphrase once per session.
You will now have two files in your ~/.ssh folder:
ssh -i keyFile serverHostName.serverDomainAlternatively, you can add the following line to the appropriate host entry in your ~/.ssh/config file:
IdentityFile ~/.ssh/keyFile
and then ssh to that host as usual without having to use the -i keyFile command line option. cp ~/.ssh/known_hosts ~/.ssh/known_hosts.backup
ssh -fN bastionHostName
ssh-keyscan -H -t rsa,dsa -p 2001 localhost >> ~/.ssh/known_hosts
ssh-keyscan -H -t rsa,dsa -p 2002 localhost >> ~/.ssh/known_hosts
ssh-keyscan -H -t rsa,dsa -p ... localhost >> ~/.ssh/known_hosts
The following allows you to set things up so that you only have to enter your SSH key passphrase once per login session.
sudo apt-get install gnome-keyring-manager
ssh-add
ssh-add -D
NOTE: This assumes that you use GRUB to dual boot and that you do NOT use dmraid.
WARNING: In Edgy, after performing the steps below, I ran into GRUB "Error 18: Selected cylinder exceeds maximum supported by BIOS" and could not boot into Ubuntu. To solve this, I had to boot into Ubuntu recovery mode, and then edit /boot/grub/menu.lst and comment out the savedefault line in the Ubuntu stanza. You probably can't do this remotely once you run into this error (since the computer requires a physical CTRL+ALT+DEL to reboot after encountering the error), so make sure to comment out the savedefault before you perform a remote grub-reboot.
sudo nano /boot/grub/menu.lstChange:
default 0to:
default savedSave and close the file by hitting CTRL+O and then CTRL+X.
sudo grub-reboot number
where number is the number of lines that show up in your GRUB menu before the "Windows" line (typically 4, 6, or 8).
(Don't include the "Windows" line into your count, but do include the "Other operating systems:" line.)
For example, number is 4 in this screenshot because there are four lines above the "Windows" option. NOTE: this assumes that you use GRUB to dual boot, and that Ubuntu is the first boot option in /root/grub/menu.lst.
shutdown /r /t 00
NOTE: The remote computer must be currently booted in WinXP, so you might have to reboot remotely from Ubuntu to Windows first.
ssh -N -f herakles ssh -N -f lion
rdesktop -r disk:sync=/home/localDirectory localhost:2011
Note that disk:sync should be set to an absolute (as opposed to relative) path. NOTE: I find that using SFTP is faster and more reliable.
See CFS's "Samba mounting" page for additional info.
ssh -fN herakles ssh -fN lion
smbclient //smb.cs.cornell.edu/win -U userName -W CUCS -I localhost -p 2017Or smbmount to mount the share:
smbmount //smb.cs.cornell.edu/win localDir -o ip=localhost,port=2017,username=userName,workgroup=CUCSAnd smbumount to unmount it:
smbumount localDirectory
I find this method faster and more reliable than using Samba.
ssh -fN herakles sftp lion
sftp://lion/home/userWindows home directory:
sftp://lion/home/WIN/userLinux Bigbox directory:
sftp://lion/home/BIGBOX/userWindows Bigbox directory:
sftp://lion/home/BIGBOX.win/user
\\cucs\home\UNIX\user
Windows home directory:
\\cucs\home\Windows\user
Windows Bigbox directory:
\\cs.cornell.edu\home\bigbox\user
gksudo network-admin
IMPORTANT: This only applies if you want to move your home directory to another drive, or if you want to activate an existing home directory on another drive.
sudo mkdir /mnt/newNow mount the new partition (e.g., /dev/hdb2) to /mnt/new. If it is an Ext3 partition, use the following:
sudo mount -t ext3 /dev/hdb1 /mnt/new/If it is a ReiserFS partition, use the following:
sudo mount -t reiserfs -o notail /dev/hdb1 /mnt/new/Now copy your existing home directory to the new partition.
sudo cp -R -p /home/user /mnt/new/ sudo chown user:user /mnt/new/user sudo umount /mnt/new/
sudo nano /etc/fstabAssuming your intended home partition is /dev/hdb1, add a line to your /etc/fstab file to automount the partition onto the /home directory. If your intended home partition is Ext3, add the following line just after the main and swap partitions:
/dev/hdb1 /home ext3 defaults,errors=remount-ro 0 2If the intended home partition is ReiserFS, use the following:
/dev/hdb1 /home reiserfs defaults,notail 0 2Save the file (i.e., press CTRL+O) and exit Nano (i.e., press CTRL+X).
sudo cp /boot/grub/menu.lst /boot/grub/menu.lst.backup sudo gedit /boot/grub/menu.lstRemove the splash option from the appropriate lines. I.e., Change:
kernel /boot/... root=... ro quiet splashto:
kernel /boot/... root=... ro quiet
wget -c -O /tmp/mozilla-firefox.png http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/mozilla-firefox.png wget -c -O /tmp/document.png http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/document.png chmod 644 /tmp/mozilla-firefox.png /tmp/document.png sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-firefox.png sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-firefox.xpm sudo dpkg-divert --rename /usr/lib/mozilla-firefox/icons/default.xpm sudo dpkg-divert --rename /usr/lib/mozilla-firefox/icons/document.png sudo dpkg-divert --rename /usr/lib/mozilla-firefox/chrome/icons/default/default.xpm sudo cp /tmp/mozilla-firefox.png /usr/share/pixmaps/mozilla-firefox.png sudo cp /tmp/mozilla-firefox.png /usr/share/pixmaps/mozilla-firefox.xpm sudo cp /tmp/mozilla-firefox.png /usr/lib/mozilla-firefox/icons/default.xpm sudo cp /tmp/document.png /usr/lib/mozilla-firefox/icons/document.png sudo cp /tmp/mozilla-firefox.png /usr/lib/mozilla-firefox/chrome/icons/default/default.xpm
wget -c -O /tmp/mozilla-thunderbird.xpm http://www.cs.cornell.edu/~djm/ubuntu/mozilla-icons/mozilla-thunderbird.xpm chmod 644 /tmp/mozilla-thunderbird.xpm sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird.xpm sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird-menu.xpm sudo dpkg-divert --rename /usr/share/pixmaps/mozilla-thunderbird-pm-menu.xpm sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/mozilla-thunderbird.xpm sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow16.xpm sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow.xpm sudo dpkg-divert --rename /usr/lib/mozilla-thunderbird/chrome/icons/default/default.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird-menu.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/share/pixmaps/mozilla-thunderbird-pm-menu.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/mozilla-thunderbird.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow16.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/messengerWindow.xpm sudo cp /tmp/mozilla-thunderbird.xpm /usr/lib/mozilla-thunderbird/chrome/icons/default/default.xpm
If you have trouble accessing your Ubuntu machine remotely, it might be because the DHCP server needs to be informed of the machine's name.
sudo cp /etc/dhcp3/dhclient.conf /etc/dhcp3/dhclient.conf.backup sudo gedit /etc/dhcp3/dhclient.confAdd the following line to the file:
send "hostname.domain";where hostname is your computer name and domain is the your computer's network domain (e.g., u.cs.cornell.edu).
find dir -name "regexp" -ok rm '{}' \;
#!/bin/bash find directory -mindepth 1 -maxdepth 1 -name "*regexp1*" | while read file do target=$(echo $file | sed -e "s@regexp1@regexp2@g") mv "$file" "$target" done
#!/bin/bash
find directory -mindepth 1 -maxdepth 1 -name "*[A-Z]*" | while read file
do
target=$(echo $file | tr '[A-Z]' '[a-z]')
mv "$file" "$target"
done
chmod +x script_file
Quick explanation: In order to associate an application (e.g., gThumb Image Viewer) with a file-type (e.g., PNG image files), the application needs to have a "desktop entry" (e.g., gthumb.desktop) located in the /usr/share/applications/ directory. Furthermore, the file-type needs to have a mime-type located in the /usr/share/mime/ directory (e.g., /usr/share/mime/images/png.xml). Finally, there should be a line in the /usr/share/applications/defaults.list file that associates the desktop entry with the mime-type (e.g., images/png=gthumb.desktop).
sudo cp /usr/share/applications/defaults.list /usr/share/applications/defaults.list.backup
sudo gedit /usr/share/applications/defaults.listAdd/change appropriate line to:
mimeType=newApp.desktopTo figure out what newApp should be (if necessary):
ls /usr/share/applications/*.desktop | sed -e "s@/usr/share/applications/@@g" | lessTo figure out what mimeType should be (if necessary):
find /usr/share/mime/ -mindepth 2 -maxdepth 2 -name "*" | sed -e "s@/usr/share/mime/@@g" -e "s@[.]xml@@g" | less
killall gnome-panel killall nautilus
sudo grubAt the grub command prompt, run the following commands:
find /boot/grub/stage1You should see something like (hdX,Y) where X and Y will be numbers, e.g., (hd0, 1).
root (hdX,Y)where X and Y above should be replaced by the appropriate numbers returned in step 1.
setup (hdX)
where X above should be replaced by the appropriate number returned in step 1. quit
*.nytimes.com/js/common/screen/altClickToSearch.js
network.protocol-handler.app.mms value = /usr/bin/X11/vlcCreate a new boolean:
network.protocol-handler.external.mms value = trueCreate a new string:
network.protocol-handler.app.rtsp value = /usr/bin/X11/realplayCreate a new boolean:
network.protocol-handler.external.rtsp value = true
Search Dictionary for "$" http://dictionary.reference.com/search?q=$ Search Wikipedia for "$" http://en.wikipedia.org/wiki/Special:Search?search=$&sourceid=mozilla-search Search Google for "$" http://www.google.com/search?q=$&ie=utf-8&oe=utf-8&rls=org.mozilla:en-US:official&client=firefox-a
general.autoScroll=true network.http.pipelining=true network.prefetch-next=false browser.backspace_action=0 browser.link.open_newwindow=3 (3: new tab; 2: new window; 1: current tab) browser.link.open_newwindow.restriction=2 (0: use open_newwindow setting; 1: new window; 2: use open_newwindow setting unless javascript specifies window size) browser.search.openintab=true browser.tabs.autoHide=false browser.tabs.closeButtons=2 browser.tabs.loadFolderAndReplace=false browser.tabs.loadGroup=0 browser.tabs.warnOnClose=false font.size.fixed.x-western=16 font.size.variable.x-western=16 font.default.x-western=sans-serif font.name.monospace.x-western=DejaVu Sans Mono font.name.sans-serif.x-western=DejaVu Sans font.name.serif.x-western=Nimbus Roman No9 L linkification.settings.Linkify_OpenInTab=true linkification.settings.Linkify_OpenTabinBG=true linkification.settings.Linkify_Toggle=false extensions.customizegoogle.web.suggest=false
:%s/^M$//gIMPORTANT: Make the ^M by typing CTRL+V CTRL+M, not ^ M! This expression will replace all the ^M's that have carriage returns after them with nothing. (The dollar ties the search to the end of a line.)
:%s/^M/ /gIMPORTANT: Make the ^M by typing CTRL+V CTRL+M, not ^ M! This expression will replace all the ^M's that didn't have carriage returns after them with a carriage return.
tar -cvzf archiveName.tar.gz fileOrFolder
tar -xvzf archiveName.tar.gz
gpg -c file
You will be asked to enter (and re-enter) a password which will used to create the encrypted file called file.gpg gpg file.gpg