Jul 152015
 

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.

Example:

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

Example:

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

Example:

$ w

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.

Example;

$ wall

Write you message here.

^D

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.

Example:

$ who

This command displays the username, line, and time of all currently logged-in sessions.

Output:

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.

Output:

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.

Example:

$ write user1 pts/1

Test Message.

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.

Example:

$ 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

Example:

$ dirname /home/mydir/docs/

Output:

/home/mydir

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.

Example:

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

Example:

File1.txt

John Raj

Sam Paul

File2.txt

John Sameer

Pal    Karan

$ join file1.txt file2.txt

Output:

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.

Example:

File1.txt

Abc

Def

Ghi

Jkl

Mno

$ nl file1.txt

Output:

1 Abc

2 Def

3 Ghi

4 Jkl

5 Mno

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.

Example:

File1.txt

John Raj

Sam Paul

File2.txt

8898

2345

$ paste file1.txt file2.txt

Output:

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.

Example:

File1.txt

apples

oranges

pears

kiwis

bananas

$ sort file1.txt

Output:

apples

bananas

kiwis

oranges

pears

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.

Example;

File1.txt

Thisz is a test message

Find out all the miztakes

File2.txt

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]

Output:

File1.txt:1: thisz

File1.txt:2: miztakes

File2.txt:1:iz

File2.txt:2: outz

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.

Example:

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

File1.txt

This is line1

This is line1

This is line2

This is line2

$ uniq file1.txt

Output:

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.

Example:

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

Example:

$ wc file1.txt

Output:

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.

Example:

$ echo UNIX Commands!

Output:

UNIX Commands! 

47. EXPR: Evaluate expressions 

The “expr” command is used to evaluate an expression to corresponding output value.

Example:

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

Example:

$ printf ‘Hello\nWorld\n!’

Output:

Hello

World

!

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.

Example:

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

Example:

$ 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]

Examples:

$cal

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.

Example:

$cancel

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.

Example:

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

Example:

$ gzip file1

This command compresses the file1 with .gz extension.

Example:

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

Example:

$ date

Output:

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

Example:

$ tty

Output:

/test/pts/2

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.

Example:

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

Example:

$ 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”.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)