UNIT_1_SUDHIR
UNIT_1_SUDHIR
UNIT_1_SUDHIR
man stty rm
printf cd more
script mkdir wc
passwd rmdir lp
uname ls od
echo [string]
printf
“printf” command in Linux is used to
display the given string, number or any
other format specifier on the terminal
window. It works the same way as
“printf” works in programming
languages like C.
Syntax:
uname [OPTION]
who
who command is used to find out the
following information :
1. Time of last system boot
2. Current run level of the system
3. List of logged in users and more.
Description : The who command is
used to get information about currently
logged in user on to system.
Syntax : $who [options] [filename]
date
date command is used to display the
system date and time. date command is
also used to set date and time of the
system. By default the date command
displays the date in the time zone on which
unix/linux operating system is
configured.You must be the super-user
(root) to change the date and time.
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal]
MMDDhhmm[[CC]YY][.ss]]
stty
stty command in Linux is used to
change and print terminal line settings.
Basically, this command shows or
changes terminal characteristics.
stty –all: This option print all current
settings in human-readable form.stty --
all
pwd
pwd stands for Print Working Directory.
It prints the path of the working
directory, starting from the root.
pwd is shell built-in command(pwd) or an
actual binary(/bin/pwd).
$PWD is an environment variable which
stores the path of the current directory.
This command has two flags.
cd
cd command in linux known as change
directory command. It is used to change
current working directory.
Syntax:
$ cd [directory]
mkdir
mkdir command in Linux allows the user
to create directories (also referred to as
folders in some operating systems ). This
command can create multiple directories
at once as well as set the permissions for
the directories. It is important to note
that the user executing this command
must have enough permissions to create
a directory in the parent directory, or
he/she may receive a ‘permission
denied’ error.
rmdir
rmdir command is used remove empty
directories from the filesystem in Linux.
The rmdir command removes each and
every directory specified in the
command line only if these directories
are empty. So if the specified directory
has some directories or files in it then
this cannot be removed
by rmdir command.
ls
ls is a Linux shell command that lists
directory contents of files and
directories.Some practical examples of ls
command are shown below.
1. Open Last Edited File Using ls –t
2. Display One File Per Line Using ls
-1
3. Display All Information About
Files/Directories Using ls -l
cp
cp stands for copy. This command is
used to copy files or group of files or
directory. It creates an exact image of a
file on a disk with different file
name. cp command require at least two
filenames in its arguments
cp Src_file Dest_file
mv
mv stands for move. mv is used to move
one or more files or directories from one
place to another in a file system like UNIX.
It has two distinct functions:
(i) It renames a file or folder.
(ii) It moves a group of files to a different
directory.
No additional space is consumed on a disk
during renaming. This command
normally works silently means no prompt
for confirmation.
rm
rm stands for remove here. rm command is used
to remove objects such as files, directories,
symbolic links and so on from the file system like
UNIX. To be more precise, rm removes references
to objects from the filesystem, where those objects
might have had multiple references (for example, a
file with two different names). By default, it does
not remove directories. This command normally
works silently and you should be very careful while
running rm command because once you delete the
files then you are not able to recover the contents
of files and directories. Syntax:
rm [OPTION]... FILE...
cat
Cat(concatenate) command is very
frequently used in Linux. It reads data
from the file and gives their content as
output. It helps us to create, view,
concatenate files.
$cat filename
more
more command is used to view the text
files in the command prompt, displaying
one screen at a time in case the file is large
(For example log files). The more command
also allows the user do scroll up and down
through the page. The syntax along with
options and command is as follows. Another
application of more is to use it with some
other command after a pipe. When the
output is large, we can use more command
to see output one by one.
wc
wc stands for word count. As the name
implies, it is mainly used for counting purpose.
It is used to find out number of lines, word
count, byte and characters count in the
files specified in the file arguments.
By default it displays four-columnar output.
First column shows number of lines present in a
file specified, second column shows number of
words present in the file, third column shows
number of characters present in file and fourth
column itself is the file name which are given
as argument.
lp
lp command arranges for the files specified by the
Files parameter and their associated information
(called a request) to be printed by a line printer. If
you do not specify a value for the Files parameter,
the lp command accepts standard input. The file
name - (dash) represents standard input and can
be specified on the command line in addition to
files. The lp command sends the requests in the
order specified. If the job is submitted to a local
print queue, the lp command displays the
following to standard output: Job number is: nnn
where nnn is the assigned job number. To suppress
the job number use the -s flag.
od
od command in Linux is used to convert the
content of input in different formats with octal
format as the default format.This command is
especially useful when debugging Linux scripts
for unwanted changes or characters. If more
than one file is specified, od command
concatenates them in the listed order to form
the input.It can display output in a variety of
other formats, including hexadecimal, decimal,
and ASCII. It is useful for visualizing data that
is not in a human-readable format, like the
executable code of a program.
tar
The Linux ‘tar’ stands for tape archive, is
used to create Archive and extract the
Archive files. tar command in Linux is
one of the important command which
provides archiving functionality in Linux.
We can use Linux tar command to create
compressed or uncompressed Archive
files and also maintain and modify
them.
gzip
gzip command compresses files. Each
single file is compressed into a single
file. The compressed file consists of a
GNU zip header and deflated data.
If given a file as an argument, gzip
compresses the file, adds a “.gz” suffix,
and deletes the original file. With no
arguments, gzip compresses the
standard input and writes the
compressed file to standard output.
Networking Commands
unlink ps
du w
df finger
mount arp
unmount ftp
find telnet
umask rlogin
unlink
unlink is a command-line utility for
removing a single file
du
du command-line utility helps you to find
out the disk usage of set of files or a
directory.
//syntax of du command du [OPTION]...
[FILE]... or du [OPTION]... --files0-
from=F
df
The df command (short for disk free), is
used to display information related to file
systems about total space and available
space.
Syntax :
df [OPTION]... [FILE]...
mount
mount command is used to mount the
filesystem found on a device to big tree
structure(Linux filesystem) rooted at ‘/‘.
Syntax:
[file]
cut
The cut command in UNIX is a command for
cutting out the sections from each line of files
and writing the result to standard output. It can
be used to cut parts of a line by byte position,
character and field. Basically the cut
command slices a line and extracts the text. It is
necessary to specify option with command
otherwise it gives error. If more than one file
name is provided then data from each file is not
precedes by its file name.
Syntax:
cut OPTION... [FILE]...
paste
Paste command is one of the useful commands
in Unix or Linux operating system. It is used to
join files horizontally (parallel merging) by
outputting lines consisting of lines from each
file specified, separated by tab as delimiter, to
the standard output. When no file is specified,
or put dash (“-“) instead of file name, paste
reads from standard input and gives output as
it is until a interrupt command [Ctrl-c] is
given.
Syntax:
paste [OPTION]... [FILES]...
join
The join command in UNIX is a command line utility for
joining lines of two files on a common field.
Suppose you have two files and there is a need to
combine these two files in a way that the output makes
even more sense.For example, there could be a file
containing names and the other containing ID’s and the
requirement is to combine both files in such a way that
the names and corresponding ID’s appear in the same
line. join command is the tool for it. join command is
used to join the two files based on a key field present
in both the files. The input file can be separated by
white space or any delimiter.
Syntax:
$join [OPTION] FILE1 FILE2
tee
tee command reads the standard input
and writes it to both the standard output
and one or more files. The command is
named after the T-splitter used in
plumbing. It basically breaks the output
of a program so that it can be both
displayed and saved in a file. It does
both the tasks simultaneously, copies
the result into the specified files or
variables and also display the result.
pg
pg displays a text file, pausing after each
"page" (the height of the terminal screen).
After each page, a prompt is displayed. The
user may then either press the newline key
to view the next page or one of the keys
described below.
If no file name is given on the command line
, pg reads from standard input. If standard
output is not a terminal, pg acts like cat but
precedes each file with its name if there is
more than one.
comm
comm compare two sorted files line by line and
write to standard output; the lines that are
common and the lines that are unique.
Suppose you have two lists of people and you
are asked to find out the names available in one
and not in the other, or even those common to
both. comm is the command that will help you
to achieve this. It requires two sorted files which
it compares line by line.
the syntax of comm command:
Syntax :
$comm [OPTION]... FILE1 FILE2
cmp
cmp command in Linux/UNIX is used to compare
the two files byte by byte and helps you to find out
whether the two files are identical or not.
When cmp is used for comparison between two
files, it reports the location of the first mismatch to
the screen if difference is found and if no difference
is found i.e the files compared are identical.
cmp displays no message and simply returns the
prompt if the files compared are identical.
Syntax: cmp [OPTION]... FILE1 [FILE2 [SKIP1
[SKIP2]]] SKIP1 ,SKIP2 & OPTION are optional and
FILE1 & FILE2 refer to the filenames .
diff
diff stands for difference. This command is used
to display the differences in the files by comparing
the files line by line. Unlike its fellow members,
cmp and comm, it tells us which lines in one file
have is to be changed to make the two files
identical.
The important thing to remember is that diff uses
certain special symbols and instructions that
are required to make two files identical. It tells you
the instructions on how to change the first file to
make it match the second file.
Special symbols are:
a : add c : change d : delete
tr
The tr command is a UNIX command-
line utility for translating or deleting
characters. It supports a range of
transformations including uppercase to
lowercase, squeezing repeating
characters, deleting specific characters,
and basic find and replace. It can be
used with UNIX pipes to support more
complex translation. tr stands for
translate.
Syntax :
cpio
cpio stands for “copy in, copy out“. It
is used for processing the archive files
like *.cpio or *.tar. This command can
copy files to and from archives.
Synopsis:
Copy-out Mode: Copy files named in
name-list to the archive Syntax: cpio -o
< name-list > archive
Copy-in Mode: Extract files from the
archive Syntax: cpio -i < archive