watch – Periodically run and show the output of a Program
Watch runs the specified command(s) repeatedly, displaying its output. This allows us to monitor the output changes over time. Press Ctrl+C to stop the Watch Command.
$ watch ls -- For every 2sec(default), run the 'ls' and show theoutput on the screen. $ watch -n 6 who -- For every 6Sec, run the 'who' and show thelist of current users. $ watch -d date -- Highlight the difference between the successiveupdates. $ watch /sbin/ifconfig eth0 -- Watch the traffic on eth0 interface. $ watch "/sbin/ifconfig eth0 | grep bytes" -- Watch RX/TX bytes. $ watch "/sbin/ifconfig; date" -- Watch multiple commands.
Read: man watch
nl – Number lines of files
Write each FILE to stdout, with line numbers added. With No FILE or -, read from stdin.
$ 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. $ nl -bp"^T" myfile -- Number the lines start with char 'T'. $ ls | nl -- ls Output with line numbers
Read: man nl
ls — List directory contents
List the current or specified directory contents and informations. It is similar to DOS DIR command. ls has option (-F) to show the different types of files with symbol ( / – Directory, * – Executable, @ – Link, nothing – Normal file). ls has option (–color) to show the different types files with different colors. Fields displayed in long (-l) output format: 1st File Type (- Normal file, d Directory, s Socket file, l Link file), 2nd Permissions(Owner, Group, Others), 3rd Number of links, 4th Owner, 5th Group, 6th Size, 7th Last modified Time, 8th Name.
$ ls -- Alphabetically list all files and Dir $ 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 dot $ ls -R -- Recursive output $ ls -Q -- Enclose entry names in double quotes $ ls -lh -- List file is long format and show size in human readable format like KB, MB, GB, .. $ ls -m -- List file in comma separated entries. $ ls -lt -- Sort and show by last modification time. $ ls -lu -- Sort and show by last access time. $ ls -rlu -- Show in reverse order.
Read : man ls
cat — CATenate files and display
Cat will do following functions on the files: Displaying them, Combining copies of them and Creating new ones.
Jargon File: Catenate is an obscure word meaning “to connect in a series”, which is what the “cat” command does to one or more files.
$ cat File -- Dump the file on screen. $ cat File1 File2 File3 -- Concat File1,File2 & File3 and display. $ cat > File -- Concat the STDIN to STDOUT and FILE. Press Enter and Ctrl+D to exit. $ cat - File - Concat STDIN and File to STDOUT. $ cat -n File -- Show the File with number for each line. $ cat -b File -- Show the File with number for non-blank lines. $ cat -s File -- Squeeze multiple blank lines to single. $ cat -A File -- Show the Non-Printable Chars also. STDIN - Standard Input - Keyboard STDOUT - Standard Output - Screen
Read: man cat / info cat
echo – Display a line of text on the screen
Echo is used to show a line of text on the screen with limited Esc sequence (BELL, Backspace, H-Tab, V-Tab,..) handling capabilities.
$ echo -- Display a empty line $ echo $HOME -- Display the env variable value. $ echo -n "No new line" -- Display with-out trailing newline. $ echo "BharathinILUGC" -- Display the line, as it is. $ echo -e "BharathintILUGC" -- Interpret and show the line $ echo -e "33[1;34m ILUGC 33[0m" -- Display with color.
Read: man echo
info – Display documentation in Info format.
In attidion to Man page, some commands comes with a detail manual pages, called info pages, which is in info format. This info command provides Menu, Search, Corss-Ref and many other facilities. Press ? to get on-line info help.
$ info -- List all info pages available in the system. $ info emacs -- Show Emacs info page. (See man emacs, to feel the difference) $ info --show-options gcc -- Show the GCC command line options $ pinfo libc -- Curses based lynx-style info browser. Info files location: /usr/share/info/
Read: info info, info pinfo
whatis — Search the whatis database for complete words.
Whatis DB contains the name and one line description about all man pages. whatis searches for keywords and displays the result(s). Only complete word matches are displayed.
$ whatis ls -- Show small info about ls command. $ whatis perl -- Show small info about Perl. $ whatis gcc -- Show small info about GCC command. $ whatis printf -- Show small info about printf. $ whatis socket -- Show small info about socket. $ whatis compile -- Just try (Error). Location of whatis DB: /var/cache/man/whatis
Read: man whatis
man – Format and display the ‘MAN’ual pages.
Most of the commands are comes with a specially formatted manual file, which explains “how to use the command, option list, etc..”. ‘man’ command is used to view those manual page. Man pages are sorted in categories, as mentioned below:
1. Executable programs / Shell commands 2. System calls 3. Library calls4. Special files 5. Config file formats and conventions6. Games 7. Miscellaneous 8. System administration commands 9. Non-standard
$ man man -- Display the manual page of the man command $ man ls -- Display the manual page of the ls command $ man printf -- Display printf command man page. $ man 3 printf -- Display printf lib call man page. $ man resolv.conf -- Display the manual page of DNS Config file. $ man ./myman -- Display the myman page present in the local dir. Man page location: /usr/share/man/manX
Read: man man
Recently in one of our discussion in ILUGC, I asked for a help to identify a free blog site, which will allow me to post my blog entries thru email. My friend Vamsee Kanakala refered Posterous and gave a good review about it. It is very useful for people, like me, who are very comfortable with email. Thanks Vamsee.