Robert's Linux Notes

Robert's Linux Notes

Back to Fisher Family Home Page
To mount Shares from Windows PC's
To mount shares from Vista PC's
SCP
Sitecopy
Imagemagick
Album
Various Linux Stuff
Thunderbird

To Do before upgrading or changing distro:-

Save fstab, smb.conf
Save /home
Save packages which are possibly not in new version
Export bookmarks, addressbook and calendar
Check (and maybe save) password.pwm, cron.daily and cron.hourly stuff, VMWare image folder
Take note of sound settings

My PC - "Beast"

(Parts from Dove - 6/4/11)
2x Adata 2GB DDR3 1333 DIMM 3yr wty Hynix/Micron/Major
Intel Core i5 2500 3.30GHz 6MB LGA1155 - HD GRAPHICS
Gigabyte GV-N220OC-1GI PCIE HDMI+DVI+VGA
Gigabyte GA-P67A-UD3-B3 ATX LGA1155
200Gb Western Digital SATA drive *8.9m/s *7200 RPM * 8Mb cache
200Gb Seagate Barracuda SATA Drive *7200 RPM * 8Mb cache
LG GSA-H30NS 18x Dual layer DVD-RW SATA drive
Acer AL1916W 1440 x 900 19" diagonal (Wide Screen)
ViewSonic VX2439WM 1920x1080

Running Linux Mint Debian Edition (and nothing else)

To mount Shares from Windows PC's

Create directory e.g /share
To mount.... type...

smbmount //winsys/winshare some-mount-point
Example for me (X = win pc, C = Share name)
smbmount //X/C /share
To unmount (my example)...
smbumount -t smbfs /share

Mounting smbfs Shares Permanently

http://www.justlinux.com/nhf/Filesystems/Mounting_smbfs_Shares_Permanently.html
And some notes I found useful to access Vista shares.....
Using a text editor, create a plain text file containing two lines:

username=windows_username
password=windows_password

Substitute your actual Windows username and password for the italicized text. Save the file in your home folder as .smbpasswd (don't forget the dot at the beginning of the filename, which makes the file hidden). Finally, change the permissions on the file so only you can open and change it by issuing the following command in a Terminal window:
chmod 600 .smbpasswd

On the Linux machine, open /etc/fstab in a text editor.
(On Ubuntu, I used the command sudo gedit /etc/fstab. You can use another editor if you prefer.)

At the end of the file, add a new line containing the following:

//vista_pc_name/share_name mount_folder_name smbfs credentials=/home/linux_username/.smbpasswd,uid=linux_username,gid=users 0 0

Use the UNC path for the Windows share, and replace mount_folder_name with, for example, /mnt/vista_public).
Substitute your Linux username for the values in red. These credentials will be passed to the Vista machine.
(Note: there's no space after the comma and before the uid and gid.)
[Update: Thanks to Jeremy Allison in the comments of the previous post for pointing out that smbfs is deprecated and no longer maintained. You can safely substitute cifs for smbfs in the fstab entry.]

Sitecopy

.sitecopyrc.....
  site mysite
  server fisherfamily.orconhosting.net.nz
  username *******
  password *******
  local /home/robert/Shared/robert/my_web
  remote ~/fisherfamily.orcon.net.nz/htdocs/

Maintenance
sitecopy --update sitename (or for the above)....
sitecopy --update mysite

http://www.imagemagick.org/

To resize...
# convert -sample 80x40 input.jpg output.jpg
for multiple files....
mkdir new
for n in *; do convert -sample blabla $n new/$n; done
where that asterisk stands for any shell glob pattern you wish to use to match the files to be converted (you can also use more than one pattern, space-separated).

For example.....
mkdir new
for n in *jpg; do convert -sample 80x40 $n new/$n; done

or
for n in *jpg; do convert -sample 400x400 $n new/$n; done

Someone else suggested.....
for x in *.jpg; do convert -sample 80x40 $x ${x/.jpg/640x480.jpg}; done

To rotate...
convert -rotate -90 dscf0010.jpg 10.jpg

Album

http://marginalhacks.com/Hacks/album/
To create captions file -
ls > captions.txt
You get a file with the names of all the pics in the directory, then edit it with your captions. Do it with the browser viewing the pics, and an xterm editing the file open at the same time.

WGET

Try wget, it is a commandline tool, but don't be scared! It is very robust.
example:
wget http://www.microsoft.com/win2k.iso
if it stops part way through
wget -c http://www.microsoft.com/win2k.iso
-c = continue.
It will dump the file in your current directory.

I often cut and paste the file's URL into a terminal window to save a lot of retyping.

SCP

To copy a file from where you are working to a remote machine, the command is
$> scp @:{}

where is optional. If the directory is not given after the colon, the file will be saved in your home directory.
The statement
$> scp foo.java blair@foo.clarku.edu:java
will save the file foo.java to my directory java/ on the machine foo.clarku.edu

To retrieve a file from a remote machine, the order is reversed:
$> scp blair@foo.clarku.edu:java/foo.java ./java

will bring foo.java from the java directory on foo and save it to the java directory where I am giving the scp command.
To save to the home directory the ./ is just a . /

Use -r for recursive copies e.g.
scp -r /localfile user@othercomputer:/otherfolder

My examples:-
scp -P xxx 60.234.134.181:Shared/robert/my_web/super15/week10.html .
(Note: The dot at the end means the current local directory. This is a handy trick that can be used about everywhere in Linux.)

scp -P xxx week10.html robert@60.234.134.181:Shared/robert/my_web/super15/

Various Linux Commands:-

cat /proc/bus/usb/devices
cat /proc/pci
cat /proc/modules
cat /proc/cpuinfo
cat /proc/ioports
cat /proc/sys/dev/cdrom/info
cat /proc/scsi/scsi
cat /proc/version

To Display Messages as they occur

tail -f /var/log/messages

To find Default Gateway:-

route -n
ip route show
netstat -rn

To Mount an iso image to see files....

mount -o loop -t iso9660

To see pci devices...

cat /proc/pci

To see Drives...

dmesg | grep hd
or
df

To find files or folders....

locate name
For case insensitvity use -i (locate -i filename)
locate name | less (e.g. locate icon | less)
locate name | most (e.g. locate icon | most)
locate name | grep another_name | most (e.g. locate icons | grep mozilla | most)
or
qpkg -l mozilla|grep icons|less
OR - finding files with specific text......
find dir | xargs (z)grep (e.g. find /etc | xargs grep GENTOO_MIRRORS=)
(the z is used for zipped files)

NZ Mirrors

http://www.wlug.org.nz/NewZealandLinuxMirrors

Creating executable script file

create a text file with
#!/bin/bash
as the first line then just add the command-line stuff you want.
Then when you are finished do:
chmod +x filename
to make it executable
then hey presto you have a script ready to run.

Backups with Linux and Rsync

http://www.mikerubel.org/computers/rsync_snapshots/

Common New Zealand Internet Service Provider Settings

http://www.siliconlogic.co.nz/isps.htm

SSH on different port (normally 22)

For example - ssh ipcop -p 222

How to create Image (ISO) files from CD/DVD

Assuming that /dev/cdrom is the location of CD/DVD-ROM

sudo umount /dev/cdrom
readcd dev=/dev/cdrom f=file.iso
or
Turn a CD/DVD into an .iso
  sudo umount /dev/cdrom
  dd if=/dev/cdrom of=file.iso bs=1024
Turn a folder into an .iso
  mkisofs -r -o file.iso /location_of_folder/
Generate an MD5 checksum file
  md5sum file.iso > file.iso.md5

To test pop3 use telnet:

  telnet pop3.xtra.co.nz 110
  user xxxx
  pass yyyy
  list
  quit

To set up my USB Portable Hard drive enclosure.

Create ntfs partion with
cfdisk /dev/sdc

Format ntfs partition with
mkfs.ntfs /dev/sdc1 -L portable (portable = volume name)

Mount drive (writable) with
mount -t ntfs-3g /dev/sdc1 /mnt/usbdrive/ -o force
(Having first created folder /mnt/usbdrive)
or for my pocket drive.....
mount -t ntfs-3g /dev/sdc5 /mnt/usbpocket/ -o force

My bak backup......
root@beast:~# rsync -urC --delete /mnt/bak/ /media/HP\ Pocket\ Media\ Drive/

To Install Webmin

First, you need to install the components Webmin needs.
This can be done with one command:
#aptitude install libnet-ssleay-perl libauthen-pam-perl libio-pty-perl libmd5-perl
When that is done, you need to download Webmin, the current version is 1.470.
You could simply go to the webmin website and download it
After it is downloaded, install it using dpkg:
#dpkg --install webmin_1.470_all.deb