Bharathi's 'One Day One Command'

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 console.

Examples :

$ sort -- Take the input from stdin, sort and output in stdout.

$ sort myfile -o myoutput -- Sort the myfile content and store 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 -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

Bharathi's 'One Day One Command'

ulimit - Control the resources available to processes

Summary :

ulimit, Bash Built-in Command, provides control over the
resources (Virtual Mem, Max no .of process, Core file
size, ...) available to processes started by the shell.

If Max no. of user process is set to 5, then the particular
user can't run more then 5 process.

Examples :

$ ulimit -a -- Show All current limits.

$ ulimit -c -- Show core file size (If Core file size is 0, Core file will not be created during the SEG fault).

$ ulimit -c 1000 -- Set new core file size.

$ ulimit -u 3 -- Set max no .of user processes

$ ulimit -n -- Show max open files.

Read : info bash (or) help ulimit

Bharathi's 'One Day One Command'

nl - Number lines of files

Summary :

Write each FILE to stdout, with line numbers added.
With No FILE or -, read stdin

Examples :

nl myfile -- Writes all non-empty lines with number.

nl -ba myfile -- Number all lines.

nl -ba -l2 myfile -- Count 2 empty line as 1 and display

nl -nln myfile -- Numbers are left justified.

nl -nrz myfile -- Numbers are right justified and leading zeros

nl -w2 myfile -- Uses 2 column for the line number.

nl -s"> " myfile -- Insert "> " in between number and line.

ls | nl -- ls Output with line numbers

Read : man nl

Bharathi's 'One Day One Command'

touch - Change File Timestamps

Summary :

Update the access and modification times of each FILE to the current time.

Examples :

$ touch myfile -- change the time stamp to current time.
If myfile is not there then touch will create it.

$ touch -c myfile -- Same as above. But If myfile is not there, then it won't create it.

$ touch -r f1 f2 -- Set f1's time to f2 instead of current time

$ touch -a myfile -- Change only access time.

$ touch -m myfile -- change only the modification time

$ touch -t 200412251122.33 -- set this time instead of current time

$ ls -lu myfile -- Shows the last access time

Read : man touch

Bharathi's 'One Day One Command'

comm - Compare 2 Sorted files line by line

Summary :

Compare two sorted files F1 and F2 line by line.

Examples :

$ comm F1 F2 -- Output contain 3 col.
Col 1 - Uniq to F1, Col 2 - Uniq to F2 and Col 3 - Comman to F1 & F2

$ comm -1 F1 F2 -- Suppress lines unique to F1

$ comm -2 F1 F2 -- Suppress lines unique to F2

$ comm -3 F1 F2 -- Suppress comman lines to F1 & F2

$ comm -13 F1 F2 -- Show lines from F2, which is not in F1

$ comm -23 F1 F2 -- Show lines from F1, which is not in F2

Read : man comm

Bharathi's 'One Day One Command'

ls -- List directory contents

Summary :

List the current directory contents and informations.

Examples :

$ ls -- Alphabetically list all files and dir

$ ls -r -- Reverse order

$ ls --color=always -- Output in color

$ ls -F -- Files are classified with /@|= symbols

$ ls -1 -- Output in single column

$ ls -a -- Display hidden entries starting with .

$ ls -R -- Recursive output

$ ls -Q -- Enclose entry names in double quotes

Read : man ls

Bharathi's 'One Day One Command'

uname - Display system informations


Display system infos like OS Type, Kernel version, Arch,
Host name etc... Main this uname will collect the info
from the /proc/sys/kernel/{ostype, hostname, osrelease,
version, domainname}.

Examples :-

$ uname -- Kernel Name

$ uname -n -- Show the machine name

$ uname -rv -- Show kernel's release & Ver info

$ uname -om -- Show Arch and OS Type

$ uname -a -- Show all info

Read: man uname

Bharathi's 'One Day One Command'

df -- Disk Free and Usage report


df command display the amount of disk space available on
the FileSystem (FS) containing each file name argument.
If no file name is given, the space available on all
currently mounted FSs is shown.

Examples :-

$ df -- Usage report of all mounted FS.

$ df myfile -- Display usage report of FS which contain
the myfile.

$ df /home -- Usage report of Home partition

$ df /dev/hda1 -- Usage report of /dev/hda1

$ df -Th -- Display the partition type and size is in human
readable format

$ df -x tmpfs -- Don't list the 'tmpfs' partitions.

$ df -P -- Output in POSIX format. (Remove -P and see the

Read: man df

(no subject)

free -- Display Information about Memory utilization


Displays the total amount of free and used physical memory
& swap space in the system, as well as the buffers & cache
consumed by the kernel.

Examples :-

$ free -- Display the mem info in KB.

$ free -m -- Display the mem info in MB.

$ free -m -t -- Display the total mem info.

$ free -s 2 -- Display the mem info for every 2Sec.

$ free -s 2 -c 5 -- Display the mem info for every 2Sec
But only 5 times

$ cat /proc/meminfo -- This is the original info which
is used by free command for the report.

Read: man free

Bharathi's One Day One Command

watch - Periodically run and show the output of a program


Watch runs command repeatedly, displaying its output This allows you to monitor the program output change over time.

Examples :-

$ watch ls -- Every 2sec(default time) 'ls' is executed and output is showed on the screen.

$ watch -n 6 who -- Every 6Sec 'who' run and list the current users

$ watch -d date -- Highlight the difference b/w successive updates

Press Ctrl+C to stop the Watch Command.

Read: man watch