A unique blog for Unix, Linux based Tips, tricks and Shell Scripts. This is intended to be one-stop Information Center for all your Unix, Linux needs.
Friday, August 1, 2008
Tracking User's activity using "script -a"
But remember, Its not a User History.... It stores all commands entered by all users (.e. its the shell history .
Add the following line to your BASH profile
script -a ~/.termlog`date +%m%d%y`
This enable to capture all the terminal activities to a file ending with current date
Monday, July 28, 2008
Cut and paste text files by columns
Here’s a generic UNIX way: (startcol and endcol refer to character columns, including whitespace. Tab counts as 1.)
cut -cstartcol-endcol file {>receiving file} paste sourcefile1 sourcefile2 {>final file}
I like to preview and fine-tune my commands by looking at the result on standard out (the shell window) and then redirecting output to a (temporary) file when things look right. Those feeling really adventurous can combine things into a single command line…
Great Unix Tips & Tricks: Vol 1
Whether you are a newbie to Linux or you are a seasoned guru, you are bound to find some scripts or programs which just make your life on the computer exponentially easier. The following is a list of them and explains what they do.
1. tac
tac is a command similar to cat, except that it reverses the output of the specified file.
tac
2. Multiple X-Sessions
Using multiple X-Sessions allows a user to have open more than just one instance of XFree, so multiple desktop environments can be used at a time.
startx -- :
terminal name is simply which terminal X should start on. By default it starts on
0:0. If you want two open, you may want it open on 0:1, which can be run by:
startx -- :1
The resulting desktops will exist on F7 - F12.
3. links
links is a text based browser which has full support for tables
links
sparse files
$ cat bigcore.c
#include
#include
int main(void) {
int fd = open("core", O_CREAT|O_WRONLY|O_TRUNC, 0600);
lseek(fd, 0x12345678, SEEK_SET);
write(fd, "1", 1);
close(fd);
return 0;
}
$ cc -o bigcore bigcore.c
$ ./bigcore
$ ls -l core
-rw------- 1 dmr staff 305419897 May 1 03:50 core
$ du -k core
48 core
$
Tuesday, July 15, 2008
Ctrl+D or exit: Which one is better?
In BASH, to exit from shell we can use Ctrl+D or exit ? which one is better?
-Ctrl+D conveniently exits Bash
-Sometimes too conveniently bcoz session may be terminated if pressed accidentaly.
To avoid the accidental exit, we can specify the no of "Ctrl+D" pressed before exit.
$export IGNOREEOF=1
$ Ctrl+D
$ Use "exit" to leave the shell.
$ Ctrl+D
$ exit
Wednesday, July 9, 2008
Games
Naturally there are also lots of free games, many simple but fun games are included with Linux distributions, but some are not, so I have included links about those too.
Linux Game Publishing
Tux Games
Linux Gaming
Linuxgames
The Linux Game
Mandrake eXPerience FREE GAMES section
Article on Gaming and Linux in 2003
Tuesday, July 8, 2008
Command based Calculator in BASH
To use this feature, simply type in the arithmetic expression you wish to evaluate at the prompt within double parentheses, as illustrated below. Bash will attempt to perform the calculation and return the answer.
bash> echo $((16/2))
8
bash> echo $((16*2))
32