Wayno's Adventures and sojourns through Linux

  • Home
  • About
  • Contact
  • Email Subscription
  • Facebook Like
  • RSS

2

May

Mounting an iso9660 iso file in Linux (ubuntu/debian)

Posted by Wayno  Published in DVD, Joe, Skill Level: Easy, Skill Level: Medium

In a previous article, I showed how to install the FBReader programme.

I download the April 2010 Dual Layer iso torrent from the Project Gutenberg Site.

I opened the torrent in Bit Tornado (Ubuntu 10.10 comes with this), and downloaded the iso. Took about 6.5 hours on a 3 meg connection. The file is a little over 8 gig.

Once I downloaded the file, I did:


sudo mount -t iso9660 pgdvd042010.iso /mnt -o loop

What does it mean?

the -t tells us the filetype is an iso9660 image (ready to burn to a cd/dvd). It uses the archaic Microsoft 8×3 (i.e. filename.ext) filename format, in all CAPITALS.

The pgdvd042010.iso is the name of the file we downloaded.

/mnt is the mount point.

-o loop tells Linux it is a loopback device. This allows us to mount the iso, so we can access the contents of the iso.


df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 50G 21G 26G 45% /
/dev/loop0 7.8G 7.8G 0 100% /mnt

It makes sense to mount the iso image (sorry Windows users), since not all computers have optical disc (cd/dvd) readers. My netbook does NOT have an optical disc, but I could put iso image file there, and access it. Look MA! No CD/DVD Burning required!

Navigate to /mnt (cd /mnt) and launch index.html in this case.

Project Gutenberg on Wayno's Machine

Thanks Joe and Terry

Wayno

2 comments

20

Apr

Simple annotated bash script to zap a user

Posted by Wayno  Published in bash, Joe, Skill Level: Advanced

This is a really simple script, but it underscores some key concepts here. Variable assignments, while statements, checking for null input, reading input from the terminal, comparing strings, etc.

I tried to annotate this script so you could follow along the major concepts. This is pretty basic, and so are the concepts, but I hope it gives you enough to build upon.

Bash Pitfalls helps, but you need to be fairly familiar with Bash to begin with. This was over my head. YMMV applies.

Opera renders this page correctly, Chrome not so well.

Thanks Joe for the skill command/commentary

Wayno


#!/usr/bin/bash
#
#
# By. W. Guerrini 04/20/2011 V 1.0
#
# simple script to zap a user
#
#
# configuring parameters
#
# note a very common mistake is using a $ to assign a string a value
# here we are just defaulting all the string variables to null
#
# note that there is NO white noise around the equal (=) signs a very
# common mistake! (been there done that)
#
person="" # name of person we want to zap (string/not null)
ans="" # answer received from user (string/not null)
ok2nuke="Y" # the answer we expect if it's okay to zap user
#
# the echo command does just that. it echos the contents between the
# quote marks to the terminal
#
echo "Displaying Logged in Users"

#
# issue the who command to see who is logged in
#

who

#
# The who command listed all the people logged into the system.
# Choose one to terminate

echo "What person do you want to zap?"

#
# read waits for the person to enter some text on stdin, and puts
# the contents into the variable NOTE: person NOT $person
#
read person

#
# we are checking for a null string
# the while statement will loop, until the person string is NOT null
#
# the -z checks to see if the string is null. Notice here we use
# $string name ($person vs person) for the comparison
# the brackets [] are required because we are doing various type of
# operators
#
# also note the semi-colon ; at then end of the while statement --
# yup that's needed.
#
# so this while statement says, while the string $person is null
# echo hey the string is null and re-read the input
#
# once the condition is satifisfied (non null string) the while exits (done)

while [ -z "$person" ];
do
echo "Null string. Not permitted. Enter a person to zap: "
read person
done

echo "$person is NOT null."
#
# display to the user, the name of the person we want to zap.
# note again we want to display the contents of the string $person

echo "confirm you want to zap User" $person "(Y/N)"

read ans

echo "the answer is: " $ans

#
#
# again another while loop - the answer can't be a null (nothing) string
# keep prompting and waiting till the answer is not a null
#

while [ -z "$ans" ];
do
echo "$ans String is null."
read ans
done
#
#
#
echo "$ans is NOT null."

#
# now check the answer and make sure it is a CAPITAL Y
# remember we set ok2nuke to "Y" above
#
#
#
# again in the if statement note the $string names,
# the equal signs, the brackets [], and the semi-colon ;
#
# If we got a capital "Y" then execute the if statement (skill commented out)
#
# we want to compare the strings, so we enclose them in quotes (")
# NOTE: you could also use "Y" instead of $ok2nuke but this way
# it's easier to change the value
#
if [ "$ans" = "$ok2nuke" ];
then
echo "$ans was okay to zap"
# sudo skill -n -u $person
# where n is the signal you want to send
# (-1 is a graceful hangup, -15 is a termination, -9 is an immediate kill)
echo "He's Dead, Jim!"
fi
#
#
# if we didn't get a capital "Y" for the answer, it just falls through and
# exits.
#
echo "we are finished"

Script execution looks something like:


nwayno@Homer:~$ sh zap.sh
Displaying Logged in Users
nwayno tty7 2011-04-19 18:15 (:0)
nwayno pts/6 2011-04-20 14:25 (:0.0)
donuts tty9 2011-04-20 14:45 (:2)
nwayno pts/10 2011-04-20 16:16 (:0.0)
What person do you want to zap?

Null string. Not permitted. Enter a person to zap:
donuts
$person is NOT null.
confirm you want to zap User donuts (Y/N)
Y
the answer is: Y
$ans is NOT null.
$ans was okay to zap
He's Dead, Jim!
we are finished
nwayno@Homer:~$

1 comment

25

Mar

two ways to id a web server in Linux (or Telnet in Windows)

Posted by Wayno  Published in Browsers, Joe, Skill Level: Easy

First I will show you the easy way to id a web server. Then I’ll show you how the magic works.

1. first the easy way (Linux):

You may need to install curl first.


sudo apt-get install curl

2. Then it’s easy!


curl -I www.pkill-9.com

(that’s a capital I (eye))

and you will get output that looks like:

HTTP/1.1 301 Moved Permanently
Date: Fri, 25 Mar 2011 22:33:35 GMT
Server: Apache
X-Powered-By: PHP/5.2.14
X-Pingback: http://pkill-9.com/xmlrpc.php
Location: http://pkill-9.com/
Content-Type: text/html; charset=UTF-8

so we know that pkill-9.com uses an Apache Server. (Thank you, Jeremy!)

3. Now the magic. First telnet to the web server address, port 80 This will work in Linux OR Windows. You can use the Putty Client in Windows.


telnet www.pkill-9.com 80

Next enter:


HEAD / HTTP/1.0
[enter] [enter]

Note the query MUST be capitalised, and you MUST hit enter TWICE.

You will get output that looks like:

nwayno@Homer:~$ telnet www.pkill-9.com 80
Trying 72.167.232.233…
Connected to pkill-9.com.
Escape character is ‘^]’.
HEAD / HTTP/1.0

HTTP/1.1 403 Forbidden
Date: Fri, 25 Mar 2011 22:39:31 GMT
Server: Apache
Connection: close
Content-Type: text/html; charset=iso-8859-1

Connection closed by foreign host.
nwayno@Homer:~$

And again, we know it’s Apache (Linux).

If it says Server: Microsoft-IIS/7.5

as does www.usatoday.com then it’s a Microsoft’s Internet Information Server.

Thanks Joe. I couldn’t remember the http goodness method!

Wayno

4 comments

25

Feb

The difference between su and su -

Posted by Wayno  Published in bash, gnome, Joe, Skill Level: Easy

I have to keep explaining this to newbies – this should be a FAQ, you may want to write it up on pkill9 if it’s not already there,

The difference between su and su -

Joe

no comment

16

Jan

Simple rsync backup/restore bash scripts for Ubuntu/Debian

Posted by Wayno  Published in backup, bash, Joe, rsync, Skill Level: Easy, Skill Level: Medium

Two (2) Rules for Successful Computing:

1. Always have a path back to the way it was, before you messed it up!

2. Always follow Rule #1!

This is something I’ve been meaning to post for a long time. How to do simple command line backup and restore operations, using a very simple bash script.

As always anything with a # in a command is simply a comment and need NOT be coded. So here’s the simple backup script, you can just copy, paste and save it (mine is called dailyhome.sh, yours might be different), with your favourite editior: gedit, nano, vi. Whatever makes your boat float!

This post will seem excessively long, but I am trying to make this simple enough that a n00b could do this. Apologies in advance.

So, using the editor of your choice (gedit, nano, vi), create a file. Copy/Paste, save the following to something like dailyhome.sh


#!/bin/bash
#
#
# BACKUP the /home/ directory
# * this script is now executable!
# * fully qualified path for rsync
# * now invoked with bash since the ubuntu 'sh' is anemic
# * used end of line continuation character for greater readability
# * js
#
/usr/bin/rsync -azvu --log-file=/var/log/waynodaily.log --append
--exclude '.gvfs'
/home/ /media/bfdlinux/Homer/homerbkup/

well let’s see what we have here.

1. the options -azvu says:

a – archive mode. Files are compared against the backup,and only those files that have been added, changed, deleted, moved, since the last backup, are sent. This is an “incremental” backup. If this is the first time you are running this script, ALL files are backed up.

z – compress files during transfer
v – verbose mode (gives us a lot of debug info
u – update. skip files that are newer in the destination.

2.
–logfile points us to where we want to the logfile to appear. in this case we want the output to go to /var/log/ which is the same place we would find the system messages file: /var/log/messages (you can use dmesg to look at the last few entries in the system log.

the log will contain a list of all the files archived, debug messages, and other things like:

sent 4598381 bytes received 23273 bytes 70559.60 bytes/sec
total size is 234383146344 speedup is 50714.13

3.
–append simply says, hey append the output of rsync to the current file. Someday we’ll talk about logrotate but I just want to backup things.

4. By now you are wondering what the is all about. You will notice there is nothing after the backslash. This simply tells bash that more information is on the following line. We do this so we can read it! Remember there is NOTHING after the backslash. No spaces, no tabs. NOTHING!

5. on the next line, you’ll see:


--exclude='.gvfs'

what this tells rsync is to exclude the .gvfs directory. What’s that? It’s the gnome virtual file system. This way, we shouldn’t get any error codes returned from running this script.

6. The

/home/ /media/bfdlinux/Homer/homerbkup/

is the meat and potatoes here.

/home/ (yes it MUST have the trailing /) tells rsync that the source of the backup is the entire /home/ directory.

7. By now you might have guessed that


/media/bfdlinux/Homer/homerbkup/

points us to the destination. /media/ is used by Ubuntu, to point to usb devices. In my case a 1 t/b usb backup drive.

the /bfdlinux is the volume label (and MOUNT POINT) of the volume.

/Homer is the hostname of my computer. I use that because I do multiple machine backups, and I can easily identify what machine I want.

/homerbkup/ (yup MUST have the trailing /) is the location where I want to backup the home directory.

Replace the /media/ (and so on) with whatever is applicable in your case.

8. Since we are backing up the entire /home/ directory, we MUST have root access so we’d run the script:


sudo sh dailyhome.sh

9. Okay how are we doing so far? Not too hard, is it?

So now that we have the system backed up, and a user just accidently
shot himself in the foot (nobody EVER does that, right?) or we need to transfer the files to another machine. What do I do? First of all like Douglas Adams said: Don’t Panic!

10. Restoring is pretty dang easy. All you do is just swap the source and destination in the script. So to restore the last line in the script would read:


/media/bfdlinux/Homer/homerbkup/ /home/

The entire restore script is simply:


#!/bin/bash
#
# RESTORE the /home/ directory
#
# * this script is now executable!
# * fully qualified path for rsync
# * now invoked with bash since the ubuntu 'sh' is anemic
# * used end of line continuation character for greater readability
# * js
#
/usr/bin/rsync -azvu --log-file=/var/log/waynodaily.log --append
--exclude '.gvfs'
/media/bfdlinux/Homer/homerbkup/ /home/

And again, you can copy, paste to your favourite editor, and save it as say restore.sh

Replace the /media/ (and so on) with whatever is applicable in your case.

And to run it:


sudo sh restore.sh

or whatever you saved it as.

simple, huh?

but let’s say we only want to restore ONE user directory. How should that look?

easy:


/media/bfdlinux/Homer/homerbkup/mikey/ /home/

Again, replace the /media/ (and so on) with whatever is applicable in your case.

terminal output will look like:

mikey/
mikey/myfile

sent 4603815 bytes received 23279 bytes 52881.07 bytes/sec
total size is 234383634253 speedup is 50654.61
nwayno@Homer:/etc/nwaynobkup$ sudo sh restore.sh
sending incremental file list
./
myfile

sent 216 bytes received 34 bytes 500.00 bytes/sec
total size is 4691 speedup is 18.76

In the next post, I’ll show you how to automatically run the backup script using crontab.

So how did you do?

no comment

31

Dec

Pandora Application for Linux

Posted by Wayno  Published in Joe, Music, Skill Level: Easy

Nice one from Joe:

Solid Pandora Application for Linux

Thanks Joe! Great way to end the year!

Wayno

no comment

20

Dec

How To Send Desktop Notifications on Ubuntu Using notify-send

Posted by Wayno  Published in gnome, Joe, Skill Level: Easy, Uncategorized

Great article (with examples)

How to Send Desktop Notifications on Ubuntu using notify-send

Thanks Joe!

Wayno

no comment

16

Nov

Getting x-windows to work over an ssh connection

Posted by Wayno  Published in Joe, loni, Skill Level: Medium, ssh, X11

This is something I do so frequently, I don’t even think twice about it.  Yet it does require some tweaking.  So here’s the magic behind getting x-windows to work over an ssh connection.

1.  Let’s make sure you have what we need to get started.  If not already installed, let’s install the openssh-server on both the SERVER and CLIENT machines.

sudo apt-get install openssh-server

2.  Now let’s backup the config files:  (as always the # (octothorpe) is a comment and that, or anything after that does NOT need to be coded!)

cd /etc/ssh  # change to the ssh configuration file directory

3.  First let’s make backup copies of the files:

sudo cp sshd_config sshd_config.org # back up the SERVER config file (WITH D)

sudo cp ssh_config ssh_config.org # copy over the CLIENT  config file (NO D)

4.  Using the editor of your choice, let’s change the files to allow x-11 forwarding.  First the SERVER file

Let’s change the coding!

gksudo gedit sshd_config # edit the SERVER config file (WITH D)

Find the line and make sure it reads:

X11Forwarding yes

There MAYBE an ‘#’ in front of the line, you may need to remove it!

Save the file!

6.  Now we’ll change the client side:


gksudo gedit ssh_config # edit the client side (NO D)

change the lines so they look like:

ForwardX11 yes
ForwardX11Trusted yes

You may need to remove the ‘#’ in front to uncomment.

Save it!

7.  Restart ssh


sudo service ssh restart

8.  Try it!

-X      Enables X11 forwarding.


ssh -X (hostname)

9.  Try to bring up gedit on the client side by simply typing:


gedit

If we did your homework right, gedit will come up on the client machine, running under ssh.  X rides for free.  This is great for remote execution of a programme.  Could be any X programme.

10. The programme will NOT show up on the other computer. However if you want to start something, but let the other person use it,


export DISPLAY=:0.0

You lose control though. (thanks for this tip, Loni)

1 comment

8

Jul

How to configure Samba in Ubuntu using a gui

Posted by Wayno  Published in filesharing, Joe, samba, Skill Level: Easy, Skill Level: Medium

From Joe:

How to configure samba using a graphical interface in Ubunbu

Thanks Joe!

no comment

8

Jul

Fixing gnome-typing-monitor in Ubuntu 10.04/10.10

Posted by Wayno  Published in gnome, Joe, Skill Level: Medium

For those of us who need to take breaks from our computer (mine for medical reasons), the gnome-typing-monitor is indispensable.

However, it does NOT work in Ubuntu 10.04 (lucid) or 10.10 (meerkat) . Which for me, was a show stopper. I have Deep Vein Thrombosis and so I can’t sit for extended periods of time.

Ubuntu 10.04 Bug #565757 (gnome-typing-monitor)

This solution, fixes the problem. You will need to obtain the gnome-typing monitor from version 9.10. You can find 32 and 64 bit versions here.

Note that you will need to change the permissions (chmod) and ownership (chown) once you have downloaded and moved the file.

it needs to look like:

ls -l gnome-typing-monitor
-rwxr-xr-x 1 root root 34920 2010-07-07 23:53 gnome-typing-monitor

note that in the following example ‘#’ is the comment character.
You don’t code that or anything that follows:

1. Let’s go to the directory where the gnome-typing-monitor is stored:


cd /usr/bin

2. Let’s create a backup copy of the programme.


sudo cp gnome-typing-monitor gnome-typing-monitor_org

3. Copy the programme from our home directory (or where ever you downloaded it to, to /usr/bin


sudo cp ~/gnome-typing-monitor /usr/bin

4. Change the owner on the file back to root.


sudo chown root gnome-typing-monitor

5. Change the file permissions.


sudo chown 755 gnome-typing-monitor #change the permissions on the file (rwx for root, rx for group and world)

Now we have to fix gconf we do that by:

1. Start gconf-editor in the shell


gconf-editor

2. Go to desktop

3. gnome

4. typing break

Click on “enabled”
That’s what worked for me

Joe

gconf editor changes

Now I can finally upgrade from 9.10 (karmic) to 10.XX

Thanks Joe!

1 comment
« Previous Page — Next Page »

 

May 2012
S M T W T F S
« Apr    
 12345
6789101112
13141516171819
20212223242526
2728293031  

Recent Posts

  • de-smurfing youtube (or why are all the people on youtube blue?)
  • Monzy kill -9 (Nerdcore)
  • Finding and installing 64 bit Firefox and Thunderbird for Debian
  • Allowing more then one user to start an X session (pam authentication)
  • First Look: Ubuntu 12.04 lts

Categories

  • Android
  • apt-get
  • Audio
  • backup
  • bash
  • Browsers
  • Compiling Source Code
  • crontab
  • debian
  • debugging
  • Deposit @ Home
  • DNS – Domain Name System
  • DVD
  • filesharing
  • fstab
  • ftp
  • gnome
  • grub
  • howto
  • Humour
  • Internet Connection Sharing
  • java
  • Joe
  • Linux Networking
  • loni
  • Misc. other devices/things
  • Music
  • Natty
  • netbook
  • Printers/Printing
  • rsync
  • samba
  • Security
  • Skill Level: Advanced
  • Skill Level: Easy
  • Skill Level: Medium
  • sound
  • ssh
  • Thunderbird
  • Uncategorized
  • ups
  • video
  • wireless
  • word processors
  • X11

Archives

  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • September 2010
  • July 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009

Blogroll

  • Hak5 – Trust your Technolust
  • Scott Linux – A place to geek out
  • Tucson Computer Society

Meta

  • Register
  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Recent Posts

  • de-smurfing youtube (or why are all the people on youtube blue?)
  • Monzy kill -9 (Nerdcore)
  • Finding and installing 64 bit Firefox and Thunderbird for Debian
  • Allowing more then one user to start an X session (pam authentication)
  • First Look: Ubuntu 12.04 lts
  • Gnome classic (fallback) in Ubuntu 12.04
  • Cat listening to Music
  • How to send broadcast messages to all users in Windows or Linux
  • Cox Communications “quality challenged” internet connection (of Cats and Cox)
  • Why RTFM is important

Recent Comments

  • Shannon in de-smurfing youtube (or why are all the people on …
  • Juan Pedro Sanchez in Getting a Webcam/Logictech Quick Cam to work with …
  • Khorshed Alam in Mounting an iso9660 iso file in Linux (ubuntu/debi…
  • ActionParsnip in Installing gnome-3 on Ubuntu 10.10/10.04
  • Wayno in Cox Communications "quality challenged" internet c…
  • sandeep in How to mount a usb or micro sd card, when Linux do…
  • Wayno in How to mount a usb or micro sd card, when Linux do…
  • sandeep in How to mount a usb or micro sd card, when Linux do…
  • mahesh in How to install Java 1.7 for Ubuntu/Debian (apt-get…
  • Wayno in Why RTFM is important
© 2007 Wayno's Adventures and sojourns through Linux



Theme by WebRehash | Free WordPress Templates | Valid XHTML | Valid CSS 3.0 | Powered by Wordpress