0% found this document useful (0 votes)
22 views

Unix Command Basic

The document provides information on various UNIX commands including echo, passwd, uname, who, find, bc, tty, touch, cat, cp, mv, mkdir, ls, cmp, comm, diff, uniq, head, tail, more, tr, sort, cut, paste, and join. It describes what each command is used for and provides the basic syntax for each command. Pipes are also described as a way to connect the output of one command to the input of another command in UNIX.

Uploaded by

Anannya Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Unix Command Basic

The document provides information on various UNIX commands including echo, passwd, uname, who, find, bc, tty, touch, cat, cp, mv, mkdir, ls, cmp, comm, diff, uniq, head, tail, more, tr, sort, cut, paste, and join. It describes what each command is used for and provides the basic syntax for each command. Pipes are also described as a way to connect the output of one command to the input of another command in UNIX.

Uploaded by

Anannya Pal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIX

echo

It displays a line of text.

Syntax : echo [OPTION]... [STRING]...

passwd command

The passwd command is used to change passwords for user accounts.

Syntax : passwd [options] [LOGIN]

uname command

Print certain system information.

Syntax : uname [OPTION]...

who command:

who command prints information about all users who are currently logged in.

Syntax : who [OPTION]... [ FILE ] [ am i ]

find command:

find is one of the powerful utilities of Unix (or Linux). It can search

the entire file-system to locate files and directories according to the specific

search criteria. Other than searching files in can also perform actions(executing

commands) on searched files.

Syntax: $ find [option] [action]

bc command:

bc is the command used for basic mathematical calculations.

tty command:

Prints the file name of the terminal connected in standard input.

Syntax : tty [OPTION]...


UNIX FILE COMMANDS
touch command

Touch command is used in Unix to create an empty file.

Syntax: $ touch file1

cat command

'cat' command is used to display file content.

Syntax: $ cat filename

cat > and cat >> command

Redirection operator ( > and >>) can be used with cat commands to take input from
standard input devices(keyboard) and store them in a file.

Syntax: $ cat > [filename]

cp command

cp command is used to copy one file's content to another file.

Syntax: $ cp [source filename] [destination filename]

mv command

mv command is used for:

1. for renaming a file in the same directory.

2. for moving a file to a different directory.

Syntax:

$ mv [sourcefilename] [destination filename]

$ mv [source_directory] [destination_directory]
● Directory Commands

mkdir(make directory) command:

The mkdir command creates a directory with a specified name in the present working
directory or specified path.

Syntax: $ mkdir [ ]

ls Command

Lists the contents of any directory (current directory if no directory specified).

Sorts entries without option

Syntax: $ ls [option(s)] [filename]

● File comparison commands:

cmp – This command is used to compare two files, and if they differ, tells the first byte
and line number where they differ. If input files are the same , return nothing.

Syntax: cmp options file1 file2

comm- This command is used to compare two sorted files.

Syntax: comm [options] file1 file2

diff - This command is used to compare two files line by line.

Syntax: diff [options] file1 file2


Filters
Some common filters in UNIX are:

● uniq – Removes identical adjacent lines


● head – displays first n lines of a file .
● tail – displays last n lines of a file .
● sort – sorts files by line (lexically or numerically)
● cut – select portions of a line.
● wc – word count (line count, character count)
● tr – translate
● grep, egrep – search files using regular expressions

head

Syntax: head [OPTION] [FILE]

tail

Syntax: tail [OPTION]... [FILE]...

more

more commands allows to view text files or other output in a scrollable manner.

Syntax: more [option] filename

tr

Syntax: tr [OPTION] set1 [set2]

sort

Syntax: sort -t field_delemeter [OPTION] file1 [file 2]

uniq

Syntax: uniq [option] filename

cut

Syntax: cut –option filename


paste

This is the command for merging together different files into a single, multi-column file.
In combination with cut, useful for creating system log files.

Syntax: paste file1 file2

join

This utility allows merging two files in a meaningful fashion, which essentially creates a
simple version of a relational database.

Pipe

In unix , you can connect two commands together so that the output from one program
becomes the input of the next program. Two or more commands connected in this way
form a pipe. In shell the symbol '|’ is used to represent a pipe.

You might also like