26. TALK: Chat to Users
The “talk” command is used to chat with another logged-in user(s) or allow chat to users on other systems.
$ talk user3
This command will allow the current user to talk to user “user3”.
27. UNAME: Print system information
The “uname” command is used to print the name, version and other details about the current machine and the operating system running on it.
$ uname –a
This command displays system information.
28. W: Who is logged on
The “w” command is a quick way to see who is logged on and what they are doing.
This command will show a list of logged on users and their processes.
$ w user1
This command will show information for the user named “user1”.
29. WALL: Write to all
The “wall” command is used to write messages to other logged-in users. This command can be used by root to send out shutting down message to all users just before power off.
Write you message here.
30. WHO/WHO AM I: Print all usernames currently logged in / Print the current user id and name
The “who” command displays a list of all users who are currently logged into the computer.
This command displays the username, line, and time of all currently logged-in sessions.
Sam pts/1 2014-01-17 22:42 (:0.0)
Ruby pts/2 2014-01-18 09:30 (:0.0)
Karan pts/3 2013-12-25 08:52 (:0.0)
John pts/4 2014-01-05 15:33 (:0.0)
Paul pts/0 2013-09-04 22:05 (:0.0)
$ who am i
This command displays the same information, but only for the terminal session where the command was issued.
Sam pts/1 2014-01-17 22:42 (:0.0)
31. WRITE: Write Messages to other Users
The “write” command is used to write messages to another user.
$ write user1 pts/1
This command is used to write a message to the user “user1” on terminal pts/1.
Will show up to the user on that console as:
Message from root@punch on pts/1 at 11:19 …Test Messag
32. BASENAME: Delete prefix up to last slash
The “basename” command is used to delete any prefix up to the last slash (‘/’) character and return the result. Example: $ basename /home/paul/base.txt Output: base.txt
This command will retrieve the last name from a pathname ignoring any trailing slashes.
$ basename / Output:/
33. COMM: Compare two sorted files line by line
The “comm” command is used to compare two files for common and distinct lines. I.e. Compare two sorted files line-by-line. Example: File 1: Fruit1.txt applebananaeggplant File 2: Fruit2.txt applebananazucchini $ comm -12 fruit1.tx fruit2.txt Output: applebanana This command prints only the lines present in both fruit1.txt and fruit2.txt.
34. DIFF: Display the differences between two files
The “diff” command can be used to compare two files, and it will show the contents where they differ.
$ diff file1 file2
This command compares file1 and file2 and displays the difference.
35. DIRNAME: Convert a full pathname to just a path
When “dirname” is given a pathname, it will delete any suffix beginning with the last slash (‘/’) character and return the result
$ dirname /home/mydir/docs/
This command will retrieve the directory-path name from a pathname ignoring any trailing slashes.
36. ED: A line-oriented text editor
The “ed” command is the standard UNIX text editor. It is used to create, display, modify and otherwise manipulate text files.
$ ed filename.txt
This command will open a file “filename.txt“ for any editing.
37. JOIN: Join lines on a common field
The “join” command is used to join the lines of two files which share a common field of data.
$ join file1.txt file2.txt
John Raj Sameer
This command will display the above data as “John” is a common as a first word of both files.
38. NL: Number lines and write files
The “nl” command is used for numbering the lines from a file.
$ nl file1.txt
This command is used to number each line and display the result to standard output.
39. PASTE: Merge lines of files
The “paste” command is used to display the corresponding lines of multiple files side-by-side.
$ paste file1.txt file2.txt
John Raj 8898
Sam Paul 2345
This command displays the corresponding lines of file1.txt and file2.txt side-by-side.
40. SORT: Sort text files
The “sort” command is used to sort the contents of the file numerically or alphabetically.
$ sort file1.txt
This command will sort the lines in file “file1.txt” alphabetically.
41. SPELL: Check misspelled words
The “spell” command is used for spell-checking program which scans a text file for misspelled words, and prints each misspelled word on its own line.
Thisz is a test message
Find out all the miztakes
This iz a test message
Find outz all the mistakes
$ spell –on file1.text file2.txt
[ -o is used to print the filename and –n is used to print line number of each misspelled word]
This command displayed the file and line number along with the misspelled words.
42. TR: Translate, squeeze, and/or delete characters
The “tr” command is used to translate/substitute sets of characters.
$ tr “[:lower:]” “[:upper:]” < file1.txt
This command will translate the contents of “file1.txt” to uppercase.
43. UNIQ: Uniquify files (remove all duplicate lines)
The “uniq” command is used to filter out repeated lines in a file.
This is line1
This is line1
This is line2
This is line2
$ uniq file1.txt
This is line1
This is line2
44. VI: Visual text editor
The “vi” command can be used to create a new file if it doesn’t exist or to open an existing file.
$ vi file1.txt
This command creates a new file “file1.txt”.
The following are some of the commands and description that be used to write or delete in a file and to exit a file.
i: This Command inserts text before cursor’s current location.
I: This Command inserts text at beginning of the current line.
A: This Command inserts text at end of current line.
a: This Command inserts text after cursor’s current location.
o: This Command creates a new line below cursor location.
O: This Command creates a new line above cursor location.
x: This Command deletes the characters under the current cursor location.
X: This Command deletes the characters present before the cursor’s current location.
d$: This Command deletes from current cursor to the end of the line.
D: This Command deletes from the cursor to the end of the current line.
dd: This Command deletes the line where the cursor is on.
:wq This Command exits vi and save changes.
:q! This Command exits vi without saving changes.
45. WC: Print byte, word, and line counts of a file
The “wc” command is used to print counts of newlines, words and bytes for each file.
$ wc file1.txt
10 23 700 file1.txt
Where 10 is the number of lines, 23 is the number of words, and 700 is the number of characters for file “file1.txt”.
46. ECHO: Display message on screen
The “echo” command is used display a line of text.
$ echo UNIX Commands!
47. EXPR: Evaluate expressions
The “expr” command is used to evaluate an expression to corresponding output value.
$ expr 5=5
Returns 1 (true) if the expressions are equivalent or 0 (false) if they are not. Here, the values 5 and 5 are equal, and therefore equivalent, so the output will be: 1
48. PRINTF: Format and print data
The “printf” command is used to print a formatted string to the standard output.
$ printf ‘Hello\nWorld\n!’
49. GREP: Search file(s) for lines that match a pattern
The “grep” (global regular expression) command is used to search one file or multiple files for lines that contain a pattern.
$ grep string file1
This command will display all the lines containing the text as “string” in file1
50. HELP: Display information about built-in commands
The “help” command is used to display information about built-in commands.
$ help echo
This command will display a brief description of the built-in shell command “echo”.
51. CAL: Display a calendar
The “cal” command is used to display formatted calendar from the command line.
Syntax: cal [options] [[[day] month] year]
Displays calendar of current month.
$ cal 04 2015
Displays the calendar for April of the year 20015.
$ cal 2015
Displays the calendar of whole year. i.e. 2015.
52. CANCEL: Cancels a print job
The “cancel” command is used to exit print jobs. The -a option will remove all jobs from the specified destination.
Cancels all pending print jobs.
53. EXIT: Exit the shell
The “exit” command is used to terminate running jobs and cause the shell to exit.
Common aliases for exit are: “bye”, “logout”, and “lo”.
54. GZIP/GUNZIP: Compress/ Decompress files(s) to and from zip format
The “gzip” command can be used to compress the files and “gunzip” command can be used to decompress the files.
$ gzip file1
This command compresses the file1 with .gz extension.
$ gunzip –d file1.gz
This command decompresses the file1.
55. DATE: Display the date and time
The “date” command is used to display the current date including the time.
Wed Jun 3 10:12:26 EST 2015
56. TTY: Print filename of terminal on stdin
The “tty”command prints the file name of the terminal connected to standard input
57. HEAD: Output the first part of file(s)
The “head” command is used to display the first N number of lines in a file. By default, it prints the first 10 lines of a file.
$ head file1.txt
This command will display the first 10 lines of file “file1.txt”.
$ head -7 file1.txt
This command will display the first 7 lines of file “file1.txt”.
58. TAIL: Output the last part of files
The “tail” command is used to display the last N number of lines in a file. By default, it prints the last 10 lines of a file.
$ tail file1.txt
This command will display the last 10 lines of file “file1.txt”.
$ tail -7 file1.txt
This command will display the last 7 lines of file “file1.txt”.