Monday, February 23, 2009

grep,egrep and fgrep

Grep provides two kinds of variant ( egrep(grep -E) and fgrep(grep -F)).

Egrep or grep –E is called extended regular expression based pattern matching.

You can use the following regular expression format.
^, $, \, [], [^], ., *


More information is available in man page for grep.

Sunday, February 22, 2009

Recovering a file deleted with rm.

There are lot of issues regarding recovering a deleted file using rm command.
Even I am not sure, whether it can be recovered or not.

But as per man page for rm says,
.....
Note that if you use rm to remove a file, it is usually possible to
recover the contents of that file. If you want more assurance that the
contents are truly unrecoverable, consider using shred.
.......
It is recoverable.
But the recovery depends on the file system and the reliability of the hard disk.
So try it and add your comments to this post.

Backgrounding a running process

A process is running in the terminal and is associated with the terminal. Through the setsid() sys call we can disassociate it from the Terminal.
But from the command line how to disassociate it from the terminal. ie. If we close the terminal the process should not get terminated.

For this issue,
If process is already running, also if you are able to get the command prompt, try this command
$bg jobid
(Make sure that you are giving job id, not the process id).


If you are not able to get the command prompt, use Ctrl-Z, to stop it get command prompt. Once you get command prompt, use bg command as mentioned.

Disabling login permission to user accounts in unix

In Unix terms it is called as locking, so that no one can use that username to login.

The command for it is "passwd -l username".

And to unlock it "passwd -u username".

You should be logged in as "root" to do the above operations.

What will happen when a user try to login after his home directory get full?

It depends on how the user login, with (telnet,ssh, rlogin) or login through desktop session.
For telnet login, user will be able to login but he won't be able to create any file.

For desktop the answer could be yes and no. Some desktops like GNOME could point the creation of the files to /tmp which would still allow the user temporary files to be created and have a successful login. These would generally be the unix socket files for IPC between applications and the underlying framework. What could get blocked is the further use of the desktop if any configuration changes are done as they would need to be stored in the $HOME.

In earlier versions of GNOME, $HOME was used in which case the login would fail but later they moved on to use $TMPDIR (generally pointing to /tmp or /var/tmp).

Monday, February 9, 2009

Vi editor difficulty in Ubuntu

Vi editor difficulty in Ubuntu

Hi,
I was using Fedora.
I shifted to ubuntu now.
In the first two days I was feeling difficulty with typing in Vi editor.
Up/Down arrow problem,Insert was not working properly.
And it won't show insert while we press insert key etc..

I didn't go deep to learn why it happens and how to learn those key shortcuts.
Rather I started using the Vim.

So Beginners,

instead of using
vi file.c
use
vim file.c