Useful Apps to Aid Parental Control in Linux
So, you have a machine running Linux which is also used by kids. We all know how the Web may be dangerous, especially for youngest of Internet fans. But do you know how to shield your Linux system and control what your kids do online?
Even though there are many Linux distros especially aimed at children, this article will focus on how to get your current “adult” distro kid-safe, complementing a previous Make Tech Easier article.
![]()
Offline Control
An important aspect of kids’ computer usage is the amount of time they spend in front of the screen. A limitation and control of kids’ computing time is vital to avoid future addictions, and let’s face it, kids need to play with real toys, exercise, and so on.
timekpr is a program developed to track and control the computer usage time of a system’s accounts on a daily basis. It allows this limitation to be set both as a “green” period of the day (setting a period of time in which that specific user may use the system) and/or as an amount of hours per day. Unfortunately, timekpr is not available for ubuntu 11.04+ yet, even though its creators expect to provide a new release by August 2013.
Controlling Internet Usage
Surfing on the web requires lots of care and responsibility even to adults. Kids are curious and have a natural tendency to explore, so it is no wonder that they end up visiting dangerous or less appropriate websites (not only in a content point of view, but also dangerous to the system’s security). In order to prevent these kind of situations, there are several programs available, usually called “parental control” programs.
![]()
Gnome Nanny will help with parental control in Linux and is probably the most well-equipped and user-friendly program available. Specially directed to infant control, it helps define separate rules for different users. It has a tabbed interface divided in “PC use time”, “Web browser”, “Mail client” and “Instant messaging”.
The first feature presents the same functionality as timekpr, so if you want a full suite, Nanny is probably better to fulfill your needs. The second feature is probably the most important, giving the possibility to establish which sites are forbidden and which allowed, either by hand or by downloading lists available online. As far as the site informs, the latest (and unstable) Nanny version was released back in 2010, so its development probably ended back then. It is also reported that Nanny works only with three browsers, Epiphany, Firefox and Konqueror, so if you use other browser I recommend that you test Nanny’s effectiveness.
![]()
DansGuardian is another program, this one designed for web content filtering, using several methods such as phrase matching and URL filtering. It is also more tailored for running on servers, which is specially useful for schools, libraries and such. The great advantage provided by DansGuardian in comparison to other software is the previously mentioned filtering through phrase matching; sometimes pages with bad content do not have addresses revealing such content. DansGuardian searches pages for “bad” words such as “hate” or “pornography”, providing a much more effective content filtering.
![]()
Finally, WebContentControl is a different kind of program, since it is made to, with its GUI, take control and help users configure other programs – specifically, DansGuardian, FireHol, and TinyProxy. Besides controlling these apps, it provides an easier way to start/stop filtering, backs up configuration files, only changes what is really necessary, and provides SSL filtering.
Now, back to you, how do you configure your computer to restrict Internet access for your kids?
Some Fascinating Programs in Java
Program for Eliminating and Sorting Separatly using Collections
/**
* This is a program for Eliminating and Sorting Separatly using Collections
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
public class ElimatingDuplicatesInArrayAndSorting
{
public static void main(String[] args)
{
int[] a={5, 5, 6, 7 ,8, 8, 9, 3, 2, 4, 2, 3, 2, 4, 9};
HashSet h=new HashSet();
ArrayList al=new ArrayList();
for(int i=0;i<=14;i++ )
{
Integer o=new Integer(a[i]);
h.add(o);
}
Iterator itr=h.iterator();
while(itr.hasNext())
{
String w=itr.next().toString();
//int u=Integer.parseInt(w);
System.out.println(“Results in Set”+w);
Integer q=new Integer(w);
al.add(q);
}
Iterator iter=al.iterator();
Collections.sort(al);
while(iter.hasNext())
{
System.out.println(“Results after sorting :”+iter.next());
//al.add(iter.next());
}
}
}
Prime Number and number of Prime Number
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import java.
/**
* This is a program for Checking Whether the number is Prime number and if its not a Prime number the program generates the prime number till that number
* @author Gowtham Raam
*
*/
public class PrimeNumberOrOtherPrimeNos{
public static void main(String[] args)throws Exception {
BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
String r=in.readLine();
int z=Integer.parseInt(r);
if(PrimeNumberOrOtherPrimeNos.Prim1(z)==1)
{
System.out.println(“This si a Prime number” +z);
}
else
{
PrimeNumberOrOtherPrimeNos.wow(z);
}
}
static void wow(int q)
{
for(int i=2;i<=q;i++)
{
int count=0;
for(int j=2;j<=i/2;j++)
{
if(i%j==0)
{
count++;
}
}
if(count==0)
{
System.out.println(“This si a Prime number” + i);
}
}
}
static int Prim1(int o)
{
int count=0;
for(int i=2;i<=o/2;i++)
{
if(o%i==0)
{
count++;
}
}
if(count==0)
return 1;
else
return 0;
}
}
Eliminating Duplicates by using Loop
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class UserInputEliminatingDuplicates
{
public static void main(String args[]) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter a number”);
String a[]=new String[6];
for(int i=0; i<=5;i++)
{
int count=0;
String s=br.readLine();
for(int j=0;j<=i;j++)
{
if(s.equals(a[j]))
{
count++;
}
}
if(count==0)
{
a[i]=s;
}
}
for(int k=0;k<=5;k++)
{
if(a[k]==null){
System.out.println();
}
else
System.out.println(a[k]);
}
}
}
Oracle Java Intro Program JDBC Implementation
import java.sql.*;
/**
* JdbcRetrieve.java - Demonstrates how to Retrieve data from Oracle
* database using Java JDBC.
*/
/**
* Add your JDBC drivers In order to work your Program
*/
class AnothJDBC {
public static void main (String[] args) {
try {
Class.forName(“oracle.jdbc.driver.OracleDriver”).newInstance();
String url = ”jdbc:oracle:thin:@192.168.100.107:1521:XE”;
Connection conn = DriverManager.getConnection(url,”hr”,”hr”);
Statement st = conn.createStatement();
String sql;
sql = ”SELECT * FROM employees”;
ResultSet rs = st.executeQuery(sql);
while(rs.next()){
//int custId = rs.getInt(“EMPLOYEE_ID”);
//String custName = rs.getString(“LAST_NAME”);
System.out.println(rs.getString(“LAST_NAME”)+” ”+rs.getString(“Employee_id”));
//System.out.println(“…CUSTOMER NAME :…”+custName);
}
conn.close();
} catch (Exception e) {
System.err.println(“Got an exception! ”);
System.err.println(e.getMessage());
}
}
}
Some Fascinating Sql Programs-2
Addition of Salary with Previous
Query -1
SELECT R.FIRST_NAME||’,'||R.LAST_NAME ”EMPLOYEE NAME”, R.SALARY, D.DEPARTMENT_NAME, R.SALARY+M.SAL1 INC_SAL
FROM(SELECT ROWNUM+1 MR1, SALARY SAL1 FROM (SELECT ROWNUM RO, SALARY FROM
EMPLOYEES) UNION
SELECT 1,0
FROM DUAL) M,
(SELECT SALARY, FIRST_NAME, LAST_NAME ,DEPARTMENT_ID, ROWNUM R1 FROM EMPLOYEES) R, DEPARTMENTS D
WHERE M.MR1=R.R1 AND R.DEPARTMENT_ID=D.DEPARTMENT_ID
Query-2
SELECT R.SALARY, ZZ.SS+R.SALARY WOW FROM (select st.mr1, case when mr1=1 then 0 else salary end ss from
(SELECT ROWNUM MR1,
CASE WHEN (ROWNUM - 1) = 0 THEN salary - salary ELSE salary END sal1
FROM (SELECT ROWNUM RO, SALARY FROM EMPLOYEES)) st, (SELECT ROWNUM+1 RO1, SALARY FROM EMPLOYEES) gt where st.mr1=gt.ro1(+)
order by mr1) zz, (SELECT SALARY, FIRST_NAME, LAST_NAME ,DEPARTMENT_ID, ROWNUM R1 FROM EMPLOYEES) R where zz.mr1=r.r1
Query-3
SELECT s1.e1,s1.sal1,
case
when s1.e1=1 THEN s1.sal1+0
else s1.sal1+s2.sal2
end total
FROM
(SELECT salary sal1,rownum e1
FROM employees) s1,
(SELECT salary sal2,
case
when rownum=1 then rownum+1
else rownum+1
end e2
FROM employees) s2
WHERE s1.e1=s2.e2(+)
order by e1
Query - 4
SELECT R3,
SAL,
SALARY,
SAL + SALARY UP_SAL
FROM ( SELECT CASE WHEN R2 = 107 THEN R2 - 106 ELSE R2 + 1 END R3, SAL
FROM (SELECT ROWNUM R2,
CASE WHEN ROWNUM = 107 THEN 0 ELSE SALARY END
SAL
FROM EMPLOYEES)
ORDER BY R3) EZ,
(SELECT SALARY, ROWNUM R4 FROM EMPLOYEES) EN
WHERE EN.R4 = EZ.R3
Logic
Almost Every query has the same logic that is changing the rownum and making a data zero or inserting a zero data.
Palindrome
SELECT CASE
WHEN SUM (EA) = LENGTH (:D) THEN ’PALINDROME’
ELSE ’ NOT PALINDROEM’
END
PALINDROME_CHECK
FROM (SELECT SUBSTR (:D, ROWNUM, 1), SUBSTR (:D, -ROWNUM, 1), CASE
WHEN SUBSTR (:D, ROWNUM, 1) = SUBSTR (:D, -ROWNUM, 1)
THEN
’1′
ELSE
’0′
END
EA
FROM EMPLOYEES)
Output
I/P: wow: Palindrome
I/P: hai: not a Palindrome
Logic
We split the word or string into rows in a column and then we inverse the string and make it in another column. Now we compare the both columns and when both match we give number 1 or 0. Now we check the length of the string and the sum of the column. When it is matched it is a palindrome. Else it is not a palindrome
Some Fascinating Sql Programs
Query for ArmStrong Number
Query -1
SELECT :a,
CASE
WHEN SUM (rev * rev * rev) = :a THEN ’Armstrong number’
ELSE ’Not Armstron number’
END
Arm_number
FROM (SELECT SUBSTR (:a, ROWNUM, 1) rev FROM employees)
Query -2
SELECT CASE
WHEN SUM( ( SUBSTR (:num, ROWNUM, 1)
* SUBSTR (:num, ROWNUM, 1)
* SUBSTR (:num, ROWNUM, 1))) = :num
THEN
‘ Armstrong’
ELSE
‘not Armstrong’
END ”Number is”
FROM employees;
Input:123
Output : not a Armstrong no
LOGIC
1*1*1+2*2*2+3*3*3<>123, ——–This is a not Armstrong number
1*1*1+5*5*5+3*3*3=153 ——This is a Armstrong number
The subquery seperates the given input into rows. So it becomes easy to process
SUBSTR (:a, ROWNUM, 1) is important for splitting a word to rows which makes easy to process
Pruning Branches
The Below Query Gives the organisational levels for who is under whom
SELECT employee_id, last_name, LPAD(last_name, LENGTH(last_name)+(LEVEL*2)-2, ’–’)
FROM employees
WHERE last_name <> ’Bruce’ AND rownum<20
START WITH last_name=’King’
CONNECT BY PRIOR employee_id=manager_id AND last_name <> ’Hunold’
ORDER BY employee_id;
Logic
With the use of LPAD we are able to insert the symbol – and find the levels.
Last Friday Salary
SELECT HIRE_DATE,
CASE
WHEN TO_CHAR(HIRE_DATE, ’DD’)<=15
THEN NEXT_DAY(LAST_DAY(HIRE_DATE)-7, ’FRIDAY’)
ELSE NEXT_DAY(LAST_DAY(ADD_MONTHS(HIRE_DATE,1))-7, ’FRIDAY’)
END MONTH_SAL_DATE
FROM EMPLOYEES
Input:17-06-1987
Output:31-07-1987
Logic
In this the below line fetches the last date and it subtracts seven days. After the subtraction when we give the next day as Friday. We get the last Friday of the month.
NEXT_DAY(LAST_DAY(HIRE_DATE)-7, ’FRIDAY’)
Displaying Months dates
Query 1
SELECT ROWNUM || ’/' || ’&mon’ || ’/' || ’&yyyy’ ”DATE”
FROM employees
WHERE ROWNUM <=
(SELECT TO_CHAR (LAST_DAY (‘&dd/&mon/&yyyy’), ’dd’) FROM DUAL);
Query-2
SELECT ROWNUM || ’-' || ’&DATE’ DATEE
FROM EMPLOYEES
WHERE ROWNUM <=
SUBSTR (
LAST_DAY (
TO_CHAR (TO_DATE (‘&DATE’, ’Mon-YYYY’), ’dd-mon-yyyy’)),1, 2 )
Logic
User will give the input
Query -2
Calculate the last date of the Month and display it with the Rownum
Query-1
Get the date, month and year as user input and then process the last day and display
Cumulative Amount Calculation
Query
SELECT department_id, salary, SUM(salary) OVER (PARTITION BY department_id) AS total_amount,
SUM(salary) OVER (PARTITION BY department_id ORDER BY department_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS cumulative_amount
FROM EMPLOYEES;
Logic
The logic here is the below line which tells to (Partition by) as group by department id. The next is the below line calculates the row and the preceding sum of values
SUM(salary) OVER (PARTITION BY department_id ORDER BY department_id ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
Finding count of a letter
SELECT CASE
WHEN LENGTH (REPLACE (:input, ’a', ”)) IS NULL
THEN
LENGTH (:input)
ELSE
LENGTH (LOWER (:input))
- LENGTH (REPLACE (LOWER (:input), ’a', ”))
END
|| ’ a’
“Name Contains”
FROM DUAL;
Logic
We Replace the required character with no space and we subtract the total length from the replaced length.
Some Fascinating Java Programs
Finding Prime Number
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.*;
public class PrimeNo {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter a number”);
String s=br.readLine();
int i=Integer.parseInt(s);
int j=i/2;
int count=0;
for(int a=2;a<=j;a++)
{
if(i%a==0)
count++;
}
if(count==0)
{
System.out.print(“Prime number”);
}
else
{
System.out.print(“Not Prime number”);
}
}
}
Printing Words In Different Order
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class PrintingWordsInDiffProb
{
static String str=” ”;
static char a ;
//static String s=”Welcome to 4i apps and we welcome you”;
static int cc=0;
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter a number”);
String s=br.readLine();
String c=s;
String k;
String y;
for(int i=0; i <= s.length()-1; i++)
{
if(c.charAt(i) == ’ ’)
cc=cc+1;
}
//System.out.println(cc);
for(int i=0;i<=cc;i++)
{
int j=c.indexOf(‘ ’);
k=c.substring(j);
y=c.substring(0, j);
c=k+” ”+y;
c=c.trim();
//System.out.println(k);
System.out.println(c);
}
}
}
Printing Diamond Star Program
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class DiamondStar {
//import java.io.*;
static int e;
public static void main(String[] args)throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter a number”);
String q=br.readLine();
int z=Integer.parseInt(q);
String j=” ”;
String k=” ”;
int g=z/2;
int p=g-1;
int r=0;
String s=”**”;
String m=”*”;
for(int i=1;i<z;i++)
{
if(i<=g)
{
j= k.substring(0, (z-g)-i)+j.trim()+s;
//j=j+s;
System.out.println(j.substring(0, j.length()-1));
e=j.length();
}
else{
String w = k.substring(0,r+1)+j.substring(0, z-i)+j.substring(0, z-i-1);
System.out.println(w);
e–; r++;
}
}
}
}
Converting number to char in String
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RepNumWithWords
{
static String y;
static String y1=” ”;
public static void main(String[] args) throws Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter a String with number”);
String str=br.readLine();
char c=’a';
String k[]=new String[27];
int j[]=new int[27];
String e[]=new String[27];
String a=”a”;
for(int i=1;i<=26;i++)
{
e[i]=”"+i;
j[i]=c;
k[i]=Character.toString ((char) j[i]);
c++;
}
for( int r=str.length()-1;r>=0;r–)
{
y=str.substring(r, r+1);
for(int v=1;v<=26;v++)
{
if(y.equals(e[v]))
{
y=k[v];
}
}
y1=y+y1;
}
System.out.println(y1);
}
}
Taking GNOME 3 to the next level (again)
Reblogged from As far as I know:
GNOME 3 is making major progress with each and every release. Six months ago, when 3.6 was close to release, I wrote about how excited I was about the improvements that were on their way. That release was a big step up from the previous version in terms of user experience. Now we're on the cusp of GNOME 3.8, and I find myself in exactly the same position.
Recover Your Deleted Files In Linux using Scalpel Utility
Reblogged from Flossstuff's Blog:
Have you accidentally deleted an important file because you are in a habit of using “Shift+Del” rather than delete only?? Well don't panic. There is a utility named as "scalpel" which helps you in recovering the so called “permanent deleted” files. Actually when you delete a file permanently (Accidentally or By Intention) , It doesn't get removed from your hard disk.
Mounting Usb drive in Linux
To use thumb drive in Linux, the device must first be mounted into the system. In older days, you must specify the file system type so Linux can mount it to he system. Today, Linux is clever enough to recognise it and manually mounting the file system is much easier. Here is what the mount command means:
mount – The mount command serves to attach the file system found on some device to the big file tree. Conversely, the umount(8) command will detach it again.
This is an example on how to mount a USB drive (thumb drive) in Linux:
1. Plug in the usb drive into the usb port on your computer. Wait a few seconds until your Linux system detect it. If not, pull the usb drive and plug in again. If you are using Ubuntu desktop, the usb drive will be detected and mounted automatically. In Ubuntu server command line terminal, a message will appear to notice you that some information about the usb drive that has been plug in.
If nothing happens, you can check the information in the /proc directory. From the command prompt, type ‘cat /proc/scsi/scsi‘ to read the scsi file.
root@slackware:~# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD800JD-75JN Rev: 05.0
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: Kingston Model: DataTraveler 2.0 Rev: 1.02
Type: Direct-Access ANSI SCSI revision: 02
|
The highlighted text in red shows that the usb drive (thumb drive) is detected. Note that in real situation, the text is in white colour (default) not red. It’s highlighted for the sake of learning. You can see the detail in Host, Vendor and Type. If Linux can’t detect the usb drive and the usb drive data cannot be found in /proc/scsi/scsi, run rescan-scsi-bus -l from Slackware command line terminal. Below is the example:
root@slackware:~# rescan-scsi-bus -l
Host adapter 2 (ata_piix) found.
Host adapter 3 (ata_piix) found.
Host adapter 4 (ata_piix) found.
Host adapter 5 (ata_piix) found.
Host adapter 6 (pata_marvell) found.
Host adapter 7 (pata_marvell) found.
cat: /sys/class/scsi_host/host8/proc_name: No such file or directory
Host adapter 8 () found.
cat: /sys/class/scsi_host/host9/proc_name: No such file or directory
Host adapter 9 () found.
Scanning SCSI subsystem for new devices
Scanning host 2 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD1600AAJS-0 Rev: 05.0
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 3 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 3 0 0 0 ...
OLD: Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: HL-DT-ST Model: DVDRAM GSA-H62N Rev: CL00
Type: CD-ROM ANSI SCSI revision: 05
Scanning host 4 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 4 0 0 0 ...
OLD: Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: ST3250820SV Rev: 3.AC
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 5 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 6 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 7 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 8 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 8 0 0 0 ...
NEW: Segmentation fault
root@slackware:~#
|
2. The next step is to check with dmesg command to see what drive your thumb drive is. From the command line, type dmesg | grep sd (dmesg pipe grep sd). See example below:
root@slackware:~# dmesg |grep sd
SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
SCSI device sda: drive cache: write back
SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
SCSI device sda: drive cache: write back
sda: sda1 sda2 < sda5 sda6 sda7 >
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
sdb: sdb1
Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0
root@slackware:~#
|
If you installed KDE, thumb drive or usb drive will be detected automatically when you plug it in. You can check what drive your thumb drive represents by looking at the device property. Here are steps on how you can check your thumb drive name from x-window kde or gnome:
Step 1 – Open System from kde desktop.
Step 2 – Open Storage media.
Step 3 – Right-click thumb drive icon and choose Properties. The thumb drive name displays at the top of the newly open pane (Properties title).
3. Now you can ‘su’ and create a proper directory to mount your thumb drive in /mnt directory. The standard form of the mount command, is mount -t type device dir. This tells the kernel to attach file system found on device (-t option for file system type) at the directory dir. The file system types which are currently supported include: adfs, affs, autofs, cifs, coda, coherent, cramfs, ebugfs, devpts, efs, ext, ext2, ext3, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs.
From the command line, type mount -t vfat /dev/sdb1 /mnt/usb and enter. Change directory into /mnt/usb directory.
Note – Replace sdb1 with your thumb drive name and /mnt/usb with your mount directory.
bill@slackware:~$
bill@slackware:~$ su -
Password:
root@slackware:~#
root@slackware:~# mount -t vfat /dev/sdb1 /mnt/usb
root@slackware:~# cd /mnt/usb
root@slackware:~# ls
nbtscan-1.5.1a/ snort-2.0.5.tar.gz
nbtscan-1.5.1.tar.gz wintest*
root@slackware:~#
|
If it’s not working, or you are not sure of file system type, just ignore the -t option. Try this instead: mount <device> <destination>:
root@slackware:~# mount /dev/sdb1 /mnt/usb
root@slackware:~# cd /mnt/usb
root@slackware:/mnt/usb# ls ls
nbtscan-1.5.1a / snort-2.0.5.tar.gz
nbtscan-1.5.1.tar.gz wintest *
root@slackware:~#
|
If you want to access usb drive in Ubuntu using terminal, Ubuntu desktop automatically mount usb drive in /media/disk. So what you have to do is just cd into /media/disk directory.
Linux unmount usb drive
umount – The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory.
Note that a file system cannot be unmounted when it is `busy’ – for example, when there are open files on it, or when some process has its working directory there, or when a swap file on it is in use. The offending process could even be umount itself – it opens libc, and libc in its turn may open for example locale files. A lazy unmount avoids this problem.
To unmount file system or devices, you must be out of the directory you want to unmount. Type cd and enter to go to the user’s home directory. Then perform this command:
root@slackware:/mnt/usb# cd
root@slackware:~# umount /mnt/usb/
root@slackware:~#
|
Replace the target directory with the location where you mounted your usb device or thumb drive directory. If there is no error, your device should be unmounted now. you can try listing the directory again to be sure:
root@slackware:~# umount /mnt/usb/ root@slackware:~# ls /mnt/usb/
You can check Cannot unmount dvd – Device is busy for more information about umount problem. It is a tutorial about unmonting cdrom/dvd device.
OR
- Open a console window (under KDE is called konsole)
- Login as root: type su and enter the password
- Change directory: cd /mnt
- Create a new directory: mkdir usbkey (if not exists)
- Try to mount your USB-key: mount /dev/sda1 /mnt/usbkey
- If it doesn’t works you may try another device (e.g. /dev/sda2)
- If it works you can list the files in the key: ls /mnt/usbkey
- Unmount the device: umount /mnt/usbkey
- Open for edit the file /etc/fstab with a text-editor
- Add this line: /dev/sda1 /mnt/usbkey vfat noauto,users,rw,umask=0 0 0
- Save and close the file
- Leave the root user: press CTRL+D or enter the command exit
- Now you can mount the key from your account: mount /mnt/usbkey
- For unmounting the key: umount /mnt/usbkey
Thank you for reading
Linux mount usb drive
To use thumb drive in Linux, the device must first be mounted into the system. In older days, you must specify the file system type so Linux can mount it to he system. Today, Linux is clever enough to recognise it and manually mounting the file system is much easier. Here is what the mount command means:
mount – The mount command serves to attach the file system found on some device to the big file tree. Conversely, the umount(8) command will detach it again.
This is an example on how to mount a USB drive (thumb drive) in Linux:
1. Plug in the usb drive into the usb port on your computer. Wait a few seconds until your Linux system detect it. If not, pull the usb drive and plug in again. If you are using Ubuntu desktop, the usb drive will be detected and mounted automatically. In Ubuntu server command line terminal, a message will appear to notice you that some information about the usb drive that has been plug in.
If nothing happens, you can check the information in the /proc directory. From the command prompt, type ‘cat /proc/scsi/scsi‘ to read the scsi file.
root@slackware:~# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD800JD-75JN Rev: 05.0
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: Kingston Model: DataTraveler 2.0 Rev: 1.02
Type: Direct-Access ANSI SCSI revision: 02
|
The highlighted text in red shows that the usb drive (thumb drive) is detected. Note that in real situation, the text is in white colour (default) not red. It’s highlighted for the sake of learning. You can see the detail in Host, Vendor and Type. If Linux can’t detect the usb drive and the usb drive data cannot be found in /proc/scsi/scsi, run rescan-scsi-bus -l from Slackware command line terminal. Below is the example:
root@slackware:~# rescan-scsi-bus -l
Host adapter 2 (ata_piix) found.
Host adapter 3 (ata_piix) found.
Host adapter 4 (ata_piix) found.
Host adapter 5 (ata_piix) found.
Host adapter 6 (pata_marvell) found.
Host adapter 7 (pata_marvell) found.
cat: /sys/class/scsi_host/host8/proc_name: No such file or directory
Host adapter 8 () found.
cat: /sys/class/scsi_host/host9/proc_name: No such file or directory
Host adapter 9 () found.
Scanning SCSI subsystem for new devices
Scanning host 2 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 2 0 0 0 ...
OLD: Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: WDC WD1600AAJS-0 Rev: 05.0
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 3 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 3 0 0 0 ...
OLD: Host: scsi3 Channel: 00 Id: 00 Lun: 00
Vendor: HL-DT-ST Model: DVDRAM GSA-H62N Rev: CL00
Type: CD-ROM ANSI SCSI revision: 05
Scanning host 4 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 4 0 0 0 ...
OLD: Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: ST3250820SV Rev: 3.AC
Type: Direct-Access ANSI SCSI revision: 05
Scanning host 5 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 6 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 7 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning host 8 channels 0 for SCSI target IDs 0 1 2 3 4 5 6 7, LUNs 0 1 2 3 4 5 6 7
Scanning for device 8 0 0 0 ...
NEW: Segmentation fault
root@slackware:~#
|
2. The next step is to check with dmesg command to see what drive your thumb drive is. From the command line, type dmesg | grep sd (dmesg pipe grep sd). See example below:
root@slackware:~# dmesg |grep sd
SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
SCSI device sda: drive cache: write back
SCSI device sda: 156250000 512-byte hdwr sectors (80000 MB)
SCSI device sda: drive cache: write back
sda: sda1 sda2 < sda5 sda6 sda7 >
Attached scsi disk sda at scsi0, channel 0, id 0, lun 0
SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
SCSI device sdb: 1007616 512-byte hdwr sectors (516 MB)
sdb: Write Protect is off
sdb: Mode Sense: 23 00 00 00
sdb: assuming drive cache: write through
sdb: sdb1
Attached scsi removable disk sdb at scsi2, channel 0, id 0, lun 0
root@slackware:~#
|
If you installed KDE, thumb drive or usb drive will be detected automatically when you plug it in. You can check what drive your thumb drive represents by looking at the device property. Here are steps on how you can check your thumb drive name from x-window kde or gnome:
Step 1 – Open System from kde desktop.
Step 2 – Open Storage media.
Step 3 – Right-click thumb drive icon and choose Properties. The thumb drive name displays at the top of the newly open pane (Properties title).
3. Now you can ‘su’ and create a proper directory to mount your thumb drive in /mnt directory. The standard form of the mount command, is mount -t type device dir. This tells the kernel to attach file system found on device (-t option for file system type) at the directory dir. The file system types which are currently supported include: adfs, affs, autofs, cifs, coda, coherent, cramfs, ebugfs, devpts, efs, ext, ext2, ext3, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs.
From the command line, type mount -t vfat /dev/sdb1 /mnt/usb and enter. Change directory into /mnt/usb directory.
Note – Replace sdb1 with your thumb drive name and /mnt/usb with your mount directory.
bill@slackware:~$
bill@slackware:~$ su -
Password:
root@slackware:~#
root@slackware:~# mount -t vfat /dev/sdb1 /mnt/usb
root@slackware:~# cd /mnt/usb
root@slackware:~# ls
nbtscan-1.5.1a/ snort-2.0.5.tar.gz
nbtscan-1.5.1.tar.gz wintest*
root@slackware:~#
|
If it’s not working, or you are not sure of file system type, just ignore the -t option. Try this instead: mount <device> <destination>:
root@slackware:~# mount /dev/sdb1 /mnt/usb
root@slackware:~# cd /mnt/usb
root@slackware:/mnt/usb# ls ls
nbtscan-1.5.1a / snort-2.0.5.tar.gz
nbtscan-1.5.1.tar.gz wintest *
root@slackware:~#
|
If you want to access usb drive in Ubuntu using terminal, Ubuntu desktop automatically mount usb drive in /media/disk. So what you have to do is just cd into /media/disk directory.
Linux unmount usb drive
umount – The umount command detaches the file system(s) mentioned from the file hierarchy. A file system is specified by giving the directory where it has been mounted. Giving the special device on which the file system lives may also work, but is obsolete, mainly because it will fail in case this device was mounted on more than one directory.
Note that a file system cannot be unmounted when it is `busy’ – for example, when there are open files on it, or when some process has its working directory there, or when a swap file on it is in use. The offending process could even be umount itself – it opens libc, and libc in its turn may open for example locale files. A lazy unmount avoids this problem.
To unmount file system or devices, you must be out of the directory you want to unmount. Type cd and enter to go to the user’s home directory. Then perform this command:
root@slackware:/mnt/usb# cd
root@slackware:~# umount /mnt/usb/
root@slackware:~#
|
Replace the target directory with the location where you mounted your usb device or thumb drive directory. If there is no error, your device should be unmounted now. you can try listing the directory again to be sure:
root@slackware:~# umount /mnt/usb/ root@slackware:~# ls /mnt/usb/
You can check Cannot unmount dvd – Device is busy for more information about umount problem. It is a tutorial about unmonting cdrom/dvd device.
OR
- Open a console window (under KDE is called konsole)
- Login as root: type su and enter the password
- Change directory: cd /mnt
- Create a new directory: mkdir usbkey (if not exists)
- Try to mount your USB-key: mount /dev/sda1 /mnt/usbkey
- If it doesn’t works you may try another device (e.g. /dev/sda2)
- If it works you can list the files in the key: ls /mnt/usbkey
- Unmount the device: umount /mnt/usbkey
- Open for edit the file /etc/fstab with a text-editor
- Add this line: /dev/sda1 /mnt/usbkey vfat noauto,users,rw,umask=0 0 0
- Save and close the file
- Leave the root user: press CTRL+D or enter the command exit
- Now you can mount the key from your account: mount /mnt/usbkey
- For unmounting the key: umount /mnt/usbkey
Thank you for reading
Ubuntu 12.04.2 LTS released and available for download
Ubuntu releases can be categorized in two types, normal releases (such as Ubuntu 12.10) and LTS (Long-Term Support,–like for example, Ubuntu 12.04–), latter Ubuntu version that centers solid-as-a-rock stability as a first-class citizen.
As a consequence, users and companies interested in stability (while ignoring the latest app versions and newest features) utilize LTS releases.
Ubuntu 12.04.2 LTS has been released, covering all Ubuntu components, such as desktop, server, cloud and core products.

Ubuntu 12.04.2 LTS comes with updated kernel and X stack (for new installations on x86 architectures) and “matches the ability of 12.10 to install on systems using UEFI firmware with Secure Boot enabled”.
Furthermore, the micro release brings numerous updates (security-wise, fixed bugs, enhanced stability), as well as updated installation media (generating a decreased number of updates necessary to be downloaded and installed after the Ubuntu 12.04.2 installation).
Ubuntu 12.04.2 LTS is available for download on http://www.ubuntu.com/download
Interview Java Programs
Floyds Triangle
import java.io.*;
class FloydsTriangle
{
public static void main(String args[]) throws Exception
{
int num,i,j,k,s=40;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter number “);
num=Integer.parseInt(br.readLine());
for(i=1;i<=num;i++)
{
for(j=1;j<=s;j++)
System.out.print(” “);
for(k=1;k<=i;k++)
System.out.print(k);
for(k=i-1;k>0;k–)
System.out.print(k);
System.out.print(“\n”);
s–;
}
}
}
Output is:
Enter number
5
1
121
12321
1234321
123454321
//Reversing of String program 1
class ReversingStr1
{
public static void main(String args[])
{
String st=args[0];
String reversed=ReversingStr1.reverseMe(st);
System.out.println(“”+reversed);
}
static String reverseMe(String re)
{
StringBuilder sb=new StringBuilder();
for(int i=re.length()-1; i>=0;–i)
{
sb.append(re.charAt(i));
}
return sb.toString();
}
}
//Reversing of String program 2
class RevesingStr2
{
public static void main(String args[])
{
String st=args[0];
String reversed=RevesingStr2.reverseMe(st);
System.out.println(“”+reversed);
}
public static String reverseMe(String s)
{
if(s.length()==0)
return “”;
return s.charAt(s.length()-1)+reverseMe(s.substring(0, s.length()-1));
}
Tower of Hanoi
import java.io.*;
class TowerOfHanoi
{
public static void main(String args[])throws IOException
{
hanoi obj=new hanoi();
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println(“Enter number of rings”);
int N=Integer.parseInt(br.readLine());
obj.ha(‘A’,'B’,'C’,N);
}
}
class hanoi
{
void ha(char a,char b,char c,int n)
{
if(n==0)
System.out.println(“WRONG INPUT !!!”);
if(n==1)
System.out.println(“Move from “+a+” to “+c);
if(n>1)
{
ha(a,c,b,n-1);
ha(a,b,c,1);
ha(b,a,c,n-1);
}
}
}
Output
Enter number of rings
3
Move from A to C
Move from A to B
Move from C to B
Move from A to C
Move from B to A
Move from B to C
Move from A to C
}





