Bharathi Subramanian

The Social Animal 

One Day One GNU/Linux Command (APT-GET)

apt-get -- Debian Package handling tool

Summary:

apt-get is a powerful package handling tool used in the Debian Distribution. It has in-build capability to resolve the conflicts and dependencies.

Examples:

 
# apt-get update -- Update the Pkg lists from the repositories. 
 
# apt-get install pkgName -- Install the new package from the 
repositories with all dependencies. 
 
# apt-get upgrade -- Install newest version of the all packages,
which are currently installed in the system. 
 
# apt-get dist-upgrade -- Same as above. But with advanced conflict
resolution capability. 
 
# apt-get remove pkgName -- Remove the package. But won't remove
the config files. 
 
# apt-get --purge remove pkgName -- Remove the packet and it's
config files. 

Read: man apt-get

Debian Mirrors in India: http://ftp.iitm.ac.in/linux/ AND
http://mirror.cse.iitk.ac.in/

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (GREP)

grep -- (Global Regular Expression Print) Print lines matching a pattern

Summary:
`grep' searches the input files for lines containing a match to a given pattern list. Grep has a no .of useful options, character classes and support regular expressions.

Examples:

 
$ grep -i bharathi Midas.txt -- Print the lines which contains the 
string "bharathi" in the Midas.txt file.
 
$ grep -v bharathi ILUGC.txt -- Print the line which is not the
string "bharathi".
 
$ grep -A 2 "ram" file -- Along with matching line, prints the next
2 lines. 
 
$ grep -B 2 "siva" file -- Along with matching line, prints the
previous 2 lines. 
 
$ grep -C 2 "rupa" file -- Along with matching line, prints the 
previous and next 2 lines. 
 
$ grep -n "vijay" file -- Print the matching lines with its
line number. 
 
$ grep -c "Linux" file -- Prints count of match. 
 
$ grep -w "is" file -- Match the whole word only. Match "is",
but not "this". 
 
$ grep "^A" file -- Prints the line starting with A. 
 
$ grep "Z$" file -- Prints the line with ending letter Z. 
 
$ grep '^[012]' file -- Prints the line starting with 0/1/2. 
 
$ grep -E "Linux|Unix" file -- Print the lines containing "Linux"
or "Unix". 

Read : info grep / egrep / fgrep

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (ULIMIT)

ulimit - Control the resources available to processes

Summary :
ulimit, Bash Built-in Command, provides fine control over the amount of resources (Virtual Mem, Max no .of process, Core file size,..) available to any processes started by the shell. Except for -t, which is in seconds, -p, which is in increments of 512 bytes, and -u, which is an unscaled number of processes, all other values are in 1024-byte increments.

For example, if the maximum no. of user process is set to 5, then that user can't run more then 5 process.

Examples :

 
$ ulimit -a -- Show All current limits. 
 
$ ulimit -n -- Show max open files limit. 
 
$ ulimit -t -- Show max CPU time limit. 
 
$ ulimit -c -- Show core file size. 
 
$ ulimit -c 6000 -- Set new core file size. 
 
$ ulimit -u 60 -- Set max no .of processes per user to 60. 
It will protect the system from shell booms. 

Read : info bash

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (SORT)

sort - Sort lines of text files

Summary :
Sort the file contents based on options given to it. By default the output is showed in the display.

Examples :

 
$ sort -- Take the input from stdin, sort and output in stdout. 
 
$ sort myfile -o myoutput -- Sort the myfile content and store
it in "myoutput". 
 
$ sort -b myfile -- Ignore the leading blanks and sort. 
 
$ sort -br myfile -- Same as above but in reverse order. 
 
$ sort -c myfile -- Only Check whether myfile is already sorted 
 
$ sort -f myfile -- Ignore the case and sort (a == A) 
 
$ sort -u myfile -- Sort and output only unique lines 
 
$ sort -n myfile -- Numerically sort the content. 
 
$ sort -g myfile -- Same as above. It understand more complex 
notations like +, -, NaN, infinity, expo. 
 
$ sort -M months -- Month sort (Jan < Feb <..< Dec). 
 
$ sort -t : -k 2,2n -k 5.3,5.4 myfile -- Sort numerically on the 
2nd field and resolve ties by sorting alphabetically on the 3rd
and 4th characters of field 5. Use `:' as the field delimiter. 

Read : man sort

Filed under  //   linux   odoc  

Comments [0]

Unbelievable!!

Last month, I was traveling in a public transport bus from Chennai to Vaitheeswaran Kovil, very famous temple in Tamilnadu, for attending my brother-in-law marriage. During the journey, few foreigners also traveled in the same bus and I never had any interaction with them. They took few photos with-in the bus.

Nearly one and half month after, My friend (Satish) forward one of that photo to me. I am very surprised to see that. Actually thous foreign guys are from Belgium and working with my friend in a same office.

Filed under  //   life  

Comments [0]

One Day One GNU/Linux Command (TAIL)

tail - Output the last part of files.

Summary :
Print the last 10 lines of each FILE to stdout. With more than one FILE, precede each with a header giving the file name.

Examples :

 
$ tail myfile -- Show only the last 10 Lines. 
 
$ tail f1 f2 -- Show the last 10 lines from 2 files with
small header. 
 
$ tail -vn 6 myfile -- Show only last 6 Lines with header. 
 
$ tail -c 24 myfile -- Show only last 24 Bytes. 
 
$ tail -q myfile -- Don't show headers. 
 
$ tail --retry myfile -- Keep retrying to open myfile. 
 
$ tail -f maillog -- Output appended data as the file grows.
Useful to monitor logs. 
 
$ tail -f -s 10 maillog -- Once in every 10s update the output. 
 
$ tail -f --pid=600 myfile -- Terminate tail after the process
with PID 600 dies. 

Read : man tail

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (SHUTDOWN)

shutdown -- Bring the system down (Need Root privilege)

Summary :

Shutdown brings the system down in a proper and secure way. All logged-in users are notified that the system is going down, and login is blocked. All processes are first notified that the system is going down by the signal SIGTERM. Runlevel 0 is used to halt the system, run level 6 is used to reboot the system.

Examples :

 
# shutdown 12:00 -- Shutdown at 12:00 
 
# shutdown +10 -- Shutdown after 10min 
 
# shutdown now -- Immediate shutdown (now == +0) 
 
# shutdown -t 10 -- Wait 10 Sec after warn the user 
 
# shutdown -k -- Don't really shutdown; only warn 
 
# shutdown -r -t 5 -- Reboot after shutdown 
 
# shutdown -h -t 5 -- Halt after shutdown 
 
# shutdown -f now -- Skip fsck (File System Check) on reboot 
 
# shutdown -F now -- Force fsck on reboot 
 
# shutdown -c -- Cancel the already waiting shutdown process. 

Read : man shutdown

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (HEAD)

head - Output the 1st part of files.

Summary :
Print first 10 lines of each FILE to stdout. With more than one FILE, precede each with a header giving the file name. With no FILE, or when FILE is -, read stdin.

Examples :

 
$ head -- Read 10 lines from stdin and dump to stdout 
 
$ head myfile -- Show 1st 10 lines of the file. 
 
$ head f1 f2 -- Show 1st 10 lines of file f1 and f2 with header.
 
$ head -q f1 f2 -- same as above But with-out header. 
 
$ head -n 5 myfile -- Show 1st 5 lines only. 
 
$ head -c 15 myfile -- Show 1st 15Bytes only. 
 
$ head -c 15k myfile -- Show 1st 15KB only. 

Read : man head

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (CSPLIT)

csplit -- Split the files into pieces based on a Context

Summary:
CSplit will read the input file and write into number of files as per the option given to it. By default, output file names will start with the prefix 'xx' and followed by the 2 suffix characters (aa, ab,..,zz). Suffix length can be changed. During the splitting, it will print the number of characters written into each file.

Examples:

 
$ csplit file /section/ -- Split the file into two parts. Part one
is content before the 1st occurrence of word "section" and part
two is content after that. 
 
$ csplit -z file /section/ -- Same above. It will not create zero 
size output file. 
 
$ csplit file /one/ /two/ /three/ -- Split the file into 3 parts. 
 
$ csplit myfile 10 40 80 -- 1st file contains 1-9 lines, 2nd 10-39,
3rd 40-79 and 4th 80-EOF. 
 
$ csplit myfile %India% -- Skip upto, but not the matching line
and copy the remaining into a file. 
 
$ csplit myfile /India/ -- Copy upto, but not the matching line
to 1st file and remaining in 2nd file. 
 
$ csplit myfile /India/ {*} -- Every occurrence of the pattern
"India" is the splitting point. 
 
$ csplit myfile /India/ {6} -- Only first 6 occurrences of the
pattern "India" is the splitting point. 

Read : man csplit

Filed under  //   linux   odoc  

Comments [0]

One Day One GNU/Linux Command (TR)

tr - TRanslate or Delete characters

Summary :
tr will translate, squeeze, and/or delete characters from stdin and writing to stdout.

Examples :

 
$ echo "tenet" | tr "nt" "NT" -- Translate n to N and t to T.
 
$ echo "ilugc" | tr "[a-z]" "[A-Z]" -- Change case (lower
to upper). 
 
$ echo "HelloooOOOoooo" | tr -s '[:lower:]' -- Squeez the
"lower" case letters. 
 
$ echo "IxLyUzGyC" | tr -d xyz -- Remove xyz characters.
 
$ cat myfile | tr -s '\n' -- Remove repeated new lines. 
 
$ echo "ABCDEFG" | tr -c "ACEG" "\n" -- Expect "ACEG" translate
others to newline char. 

'tr' supports few standard ESC Sequences, Regular Expressions, Char Classes (lower, upper, space, blank, alpha,..), etc.

Read : man tr

Filed under  //   linux   odoc  

Comments [0]