Search This Blog

Friday, March 7, 2008

Is There a UNIX / Linux unerase / undelete Command?

Q. Is There a UNIX / Linux unerase or undelete command? How do I undelete files under a UNIX / Linux system? A.. Short answer - no.

There is no “unerase” or “undelete” command in Linux / *BSD / Unix like operating system such as AIX or HP-UX . The best solution is to restore file from a backup. You can also use a data recovery tool but there is no guaranty you will get back the data. Always use following method to avoid problems: => Make regular backups and file system snapshots

=> Never ever login as root for non admin related tasks

=> Always use a regular user account for all normal tasks

=> Alias rm / mv / cp command as rm -i / mv -i alias cp='cp -i' alias mv='mv -i' alias rm='rm -i'

=> Make important file copy before editing

=> Use RAID 6 or above hardware card as additional protection for file server

=> Keep files safe from accidental overwriting with noclobber under BASH shell

=> Make a Linux File unchangeable ( unalterable ) so that no one can modify it - including root user

Difference between Linux and UNIX

Q. What is the difference between Linux and UNIX?

A. UNIX is copyrighted name Only big companies are allowed to use the UNIX copyright and name, so IBM AIX and Sun Solaris and HP-UX all are UNIX. The Open Group holds the UNIX trademark in trust for the industry, and manages the UNIX trademark licensing program.

Linux is UNIX clone

But if you consider Portable Operating System Interface (POSIX) standards then Linux can be considered as UNIX. To quote from Official Linux kernel README file: Linux is a Unix clone written from scratch by Linus Torvalds with assistance from a loosely-knit team of hackers across the Net. It aims towards POSIX compliance.

Linux is just kernel

Linux is just kernel. Linux distribution includes GUI system, installation and management tools, compilers, editors etc. Linux distribution makes it

Most UNIX oses considered as compete operating system.

As I said earlier Linux is just kernel with Linux distribution makes it complete usable os. Most UNIX oses comes with A-Z programs such as editor, compilers etc. For example FreeBSD comes with A-Z programs.

License and cost

Linux is Free (as in beer [freedom]). You will see best community support around. Many UNIX oses are not free (but this is changing fast, for example OpenSolaris/Solaris UNIX).

User-friendly

Linux is considered as most user friendly UNIX like os. It makes easy to install sound card, flash players, and other desktop goodies.

End user perspective

The differences are not that big for the average end user.

System administrator perspective

Again, the differences are not that big for the system administrator. However, you may notice difference while performing following operations:

  1. Installation procedure
  2. Hardware Device names
  3. Admin commands or utilities

Following documents or URL should help anyone to get more idea:

How to make a Linux File unchangeable ( unalterable ) so that no one can modify it

Q. How do I write protect file under Linux so that no one can modify it?

A. You need to use chattr command, which changes the file attributes on a Linux second extended file system. The chattr command supports various attributes.

A file with the i attribute cannot be modified: it cannot be deleted or renamed, no link can be created to this file and no data can be written to the file. Only the superuser or a process possessing the CAP_LINUX_IMMUTABLE capability can set or clear this attribute in other words you make a file unchangeable or unalterable.

For example if you want file /data/financial.txt unchangeable by anyone on your system, type the following command (login as the root user): # chattr +i /data/financial.txt Now no one can delete or modify file /data/financial.txt. To reset back permission, type the following command: # chattr -i /data/financial.txt Use lsattr command to lists the file attributes on a second extended file system. It is use to see attributes set by chattr command. # lsattr financial.txt Output:

----i------------ financial.txt

Thursday, March 6, 2008

ping all hosts on the LAN

Today i got a code by which u will get to know which all machines are up in a particular network....

$ for ip in $(seq 1 254); do ping -c 1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo "192.168.1.$ip UP" || : ; done Output:

192.168.1.1 UP
192.168.1.1 UP
192.168.1.2 UP
192.168.1.5 UP
......
...
..
192.168.1.254 UP