UNICS and LINUX commands
(7 Chapters)
-Shriram K Vasudevan
-SHRIRAMKV@GMAIL.COM
02/06/21 Shriram & Linux
Chapter 1
Listing files and directories
• ls (list)
• When you first login, your current
working directory is your home
directory.
• Your home directory has the
same name as your user-name,
for example, shriram, and it is
where your personal files and
subdirectories are saved.
• To find out what is in your home
directory, type
% ls
• The ls command ( lowercase L
and lowercase S ) lists the
contents of your current working
directory.
02/06/21 Shriram & Linux
Listing files and directories
• ls does not, in fact, cause all the files
in your home directory to be listed,
but only those ones whose name
does not begin with a dot (.) Files
beginning with a dot (.) are known as
hidden files and usually contain
important program configuration
information.
• They are hidden because you should
not change them unless you are very
familiar with UNIX!!!
• To list all files in your home directory
including those whose names begin
with a dot, type
% ls -a
• As you can see, ls -a lists files that are
normally hidden.
02/06/21 Shriram & Linux
Making Directories
• mkdir (make directory)
• We will now make a
subdirectory in your home
directory to hold the files
you will be creating and
using in the course of this
tutorial. To make a
subdirectory called unixstuff
in your current working
directory type
% mkdir unixstuff
• To see the directory you
have just created, type
% ls
02/06/21 Shriram & Linux
Making Directories
02/06/21 Shriram & Linux
Making Directories – Little Play
02/06/21 Shriram & Linux
Change Directory (cd)
Cd ~ will also take you to
your home directory
02/06/21 Shriram & Linux
The parent directory (..)
• (..) means the parent of the current directory,
so typing
% cd ..
• will take you one directory up the hierarchy
(back to your home directory). Try it now.
02/06/21 Shriram & Linux
pwd (print working directory)
• Pathnames enable you to work out
where you are in relation to the
whole file-system. For example, to
find out the absolute pathname of
your home-directory, type cd to get
back to your home-directory and
then type
% pwd
• The full pathname will look
something like this -
/home/its/ug1/ee51vn
• which means that ee51vn (your
home directory) is in the sub-
directory ug1 (the group
directory),which in turn is located in
the its sub-directory, which is in the
home sub-directory, which is in the
top-level root directory called " / " .
• NOTE: “/” is called as mount point
02/06/21 Shriram & Linux
Here you
02/06/21 Shriram & Linux
Chapter 2
Copying Files
02/06/21 Shriram & Linux
Removing Files and Directories
• To delete (remove) a
file, use the rm
command.
% rm tempfile.txt
02/06/21 Shriram & Linux
Displaying the contents of a file on
the screen
• clear (clear screen)
• Before you start the next section, you may like to
clear the terminal window of the previous
commands so the output of the following
commands can be clearly understood.
• At the prompt, type
% clear
• This will clear all text and leave you with the %
prompt at the top of the window.
02/06/21 Shriram & Linux
Let me catch the CAT’s HEAD and TAIL
cat (concatenate) head
• The command cat can be used to display the • The head command writes the first ten lines
contents of a file on the screen. Type: of a file to the screen.
% cat science.txt • First clear the screen then type
• If the file is longer than the size of the % head science.txt
window, so it scrolls past making it Then type
unreadable. % head -5 science.txt
• What difference did the -5 do to the head
less command?
• The command less writes the contents of a
file onto the screen a page at a time. Type
tail
% less science.txt • The tail command writes the last ten lines of
• Press the [space-bar] if you want to see a file to the screen.
another page, and type [q] if you want to • Clear the screen and type
quit reading. As you can see, less is used in
preference to cat for long files. % tail science.txt
ANSWER THIS NOW:
• Q. How can you view the last 15 lines of the
file?
02/06/21 Shriram & Linux
The CAT has grown bigger
02/06/21 Shriram & Linux
Lets Count - WC
wc (word count) • grep () - "global regular expression
• A handy little utility is the wc printer"
command, short for word count. To • grep is one of many standard UNIX
do a word count on science.txt, type utilities. It searches files for specified
% wc -w science.txt words or patterns. First clear the
• To find out how many lines the file screen, then type
has, type % grep science science.txt
% wc -l science.txt
02/06/21 Shriram & Linux
Here you
02/06/21 Shriram & Linux
Chapter – 3
Re direction
• Most processes initiated by UNIX commands write to the standard output (that is, they write
to the terminal screen), and many take their input from the standard input (that is, they read
it from the keyboard). There is also the standard error, where processes write their error
messages, by default, to the terminal screen.
• We have already seen one use of the cat command to write the contents of a file to the
screen.
• Now type cat without specifying a file to read
% cat
• Then type a few words on the keyboard and press the [Return] key.
• Finally hold the [Ctrl] key down and press [d] (written as ^D for short) to
end the input.
• What has happened?
• If you run the cat command without specifying a file to read, it reads the
standard input (the keyboard), and on receiving the 'end of file' (^D),
copies it to the standard output (the screen).
• In UNIX, we can redirect both the input and the output of commands.
02/06/21 Shriram & Linux
Re - direction
• We will now use the cat command to join (concatenate) list1 and list2 into a
new file called biglist. Type
% cat list1 list2 > biglist
• What this is doing is reading the contents of list1 and list2 in turn, then
outputing the text to the file biglist
• To read the contents of the new file, type % cat biglist
02/06/21 Shriram & Linux
Let the water flow - PIPES
• To see who is on the system with you, type
% who
• One method to get a sorted list of names is to type,
% who > names.txt
% sort < names.txt
• What you really want to do is connect the output of the who
command directly to the input of the sort command. This is
exactly what pipes do. The symbol for a pipe is the vertical
bar |
• For example, typing
% who | sort
will give the same result as above, but quicker and cleaner.
• To find out how many users are logged on, type
% who | wc -l
02/06/21 Shriram & Linux
Contd.,
02/06/21 Shriram & Linux
Here you
02/06/21 Shriram & Linux
Chapter 4
Few New Intros
02/06/21 Shriram & Linux
Wildcards
• The * wildcard
• The character * is called a wildcard, and will
match against none or more character(s) in a file
(or directory) name. For example, in your
directory, type
% ls list*
• This will list all files in the current directory
starting with list....
• Try typing
% ls *list
• This will list all files in the current directory
ending with ....list
02/06/21 Shriram & Linux
Wildcards
• The ? wildcard
• The character ? will match exactly one
character.
So ?ouse will match files like house and
mouse, but not grouse.
Try typing
% ls ?list
02/06/21 Shriram & Linux
Filename conventions
02/06/21 Shriram & Linux
MAN can HELP you to know WHATIS
this! - On-line Manuals
• There are on-line manuals which gives information about most
commands. The manual pages tell you which options a particular
command can take, and how each option modifies the behaviour of
the command. Type man command to read the manual page for a
particular command.
• For example, to find out more about the wc (word count)
command, type
% man wc
• Alternatively
% whatis wc
• gives a one-line description of the command, but omits any
information about options etc.
• And u can do man man
02/06/21 Shriram & Linux
Are you appropriate?
• Apropos
• When you are not sure of the exact name of a command,
% apropos keyword
• will give you the commands with keyword in their manual
page header. For example, try typing
% apropos date
02/06/21 Shriram & Linux
Here you
02/06/21 Shriram & Linux
Chapter 5
File system security (access rights)
• In your directory, type
% ls -l (l for long listing!)
02/06/21 Shriram & Linux
File system security (access rights)
Access rights on files.
• r (or -), indicates read permission (or otherwise), that is, the presence or absence of permission to
read and copy the file
• w (or -), indicates write permission (or otherwise), that is, the permission (or otherwise) to change
a file
• x (or -), indicates execution permission (or otherwise), that is, the permission to execute a file,
where appropriate
Access rights on directories.
• r allows users to list files in the directory;
• w means that users may delete files from the directory or move files into it;
• x means the right to access files in the directory. This implies that you may read files in the
directory provided you have read permission on the individual files.
02/06/21 Shriram & Linux
Changing access rights – Lets Change
• chmod (changing a file mode)
• Only the owner of a file can use
chmod to change the permissions of
a file. The options of chmod are as
follows
02/06/21 Shriram & Linux
Changing access rights – Lets Change
• For example, to remove read write and execute permissions on the file
biglist for the group and others, type
% chmod go-rwx biglist
• This will leave the other permissions unaffected.
• To give read and write permissions on the file biglist to all,
% chmod a+rw biglist
02/06/21 Shriram & Linux
Processes and Jobs
• A process is an executing program identified by a unique
PID (process identifier). To see information about your
processes, with their associated PID and status, type
% ps
• A process may be in the foreground, in the background, or
be suspended. In general the shell does not return the UNIX
prompt until the current process has finished executing.
• Some processes take a long time to run and hold up the
terminal.
• Backgrounding a long process has the effect that the UNIX
prompt is returned immediately, and other tasks can be
carried out while the original process continues executing.
02/06/21 Shriram & Linux
Processes and Jobs
• Running background processes
• To background a process, type an & at the end of the command line. For example,
the command sleep waits a given number of seconds before continuing. Type
% sleep 10
• This will wait 10 seconds before returning the command prompt %. Until the
command prompt is returned, you can do nothing except wait.
• To run sleep in the background, type
% sleep 10 &
[1] 6259
• The & runs the job in the background and returns the prompt straight away,
allowing you do run other programs while waiting for that one to finish.
• The first line in the above example is typed in by the user; the next line, indicating
job number and PID, is returned by the machine.
• The user is be notified of a job number (numbered from 1) enclosed in square
brackets, together with a PID and is notified when a background process is
finished.
• Backgrounding is useful for jobs which will take a long time to complete.
02/06/21 Shriram & Linux
Backgrounding a current foreground
process
• You can suspend the process running in the
foreground by typing ^Z, i.e.hold down the
[Ctrl] key and type [z]. Then to put it in the
background, type
% bg
• Note: do not background programs that
require user interaction e.g. vi
02/06/21 Shriram & Linux
listing suspended and background
processes
• When a process is running, backgrounded or suspended, it will be
entered onto a list along with a job number. To examine this list,
type
% jobs
• An example of a job list could be
[1] Suspended sleep 1000
[2] Running netscape
[3] Running matlab
• To restart (foreground) a suspended processes, type
% fg %jobnumber
• For example, to restart sleep 1000, type
% fg %1
• Typing fg with no job number foregrounds the last suspended
process.
02/06/21 Shriram & Linux
Killing a process
kill (terminate or signal a process)
• It is sometimes necessary to kill a process (for
example, when an executing program is in an
infinite loop)
• To kill a job running in the foreground, type ^C
(control c). For example, run
% sleep 100
^C
02/06/21 Shriram & Linux
ps (process status)
• Alternatively, processes can be killed by finding their process
numbers (PIDs) and using kill PID_number
% sleep 1000 &
% ps
• PID TT S TIME COMMAND
20077 pts/5 S 0:05 sleep 1000
21563 pts/5 T 0:00 netscape
21873 pts/5 S 0:25 nedit
• To kill off the process sleep 1000, type
% kill 20077
and then type ps again to see if it has been removed from the list.
• If a process refuses to be killed, uses the -9 option, i.e. type
% kill -9 20077
• Note: It is not possible to kill off other users' processes !!!
02/06/21 Shriram & Linux
Here U
<-- (Lets Recap here)
02/06/21 Shriram & Linux
CHAPTER 6
FEW MORE USEFUL COMMANDS
• quota • Uname –a
• All students are allocated a • This will let u know which version of
certain amount of disk space linux are u using!
on the file system for their
personal files, usually about • du
100Mb. If you go over your • The du command outputs the
number of kilobyes used by each
quota, you are given 7 days to subdirectory. Useful if you have gone
remove excess files. over quota and you want to find out
• To check your current quota which directory has the most files. In
your home-directory, type
and how much of it you have
% du -s *
used, type
• The -s flag will display only a
% quota -v summary (total size) and the * means
all files and directories.
02/06/21 Shriram & Linux
Contd.,
• gzip • zcat
• This reduces the size of a file, thus • zcat will read gzipped files without
freeing valuable disk space. For needing to uncompress them first.
example, type % zcat science.txt.gz
% ls -l science.txt • If the text scrolls too fast for you,
and note the size of the file using ls -l pipe the output though less .
. Then to compress science.txt, type % zcat science.txt.gz | less
% gzip science.txt
• This will compress the file and place • diff
it in a file called science.txt.gz • This command compares the
• To see the change in size, type ls -l contents of two files and displays the
again. differences. Suppose you have a file
• To expand the file, use the gunzip called file1 and you edit some part of
command. it and save it as file2. To see the
% gunzip science.txt.gz differences type
% diff file1 file2
02/06/21 Shriram & Linux
History is important
% history (show command history list)
% !! (recall last command)
% !-3 (recall third most recent command)
% !5 (recall 5th command in list)
% !grep (recall last command starting with grep)
• You can increase the size of the history buffer
by typing
% set history=100
02/06/21 Shriram & Linux
Chapter 7
We are nearing to end
• environment Variables
• An example of an environment variable is the OSTYPE variable. The
value of this is the current operating system you are using. Type
– % echo $OSTYPE
• More examples of environment variables are
– USER (your login name)
– HOME (the path name of your home directory)
– HOST (the name of the computer you are using)
– ARCH (the architecture of the computers processor)
– DISPLAY (the name of the computer screen to display X windows)
– PRINTER (the default printer to send print jobs)
– PATH (the directories the shell should search to find a command)
02/06/21 Shriram & Linux
Finding out the current values of
these variables.
• ENVIRONMENT variables are set using the
setenv command, displayed using the printenv
or env commands, and unset using the
unsetenv command.
• To show all values of these variables, type
• % printenv | less
02/06/21 Shriram & Linux
What is Process??
Let`s have some food for
brain
02/06/21 Shriram & Linux
What is Process?? - Most important
thing to know
• Process is any kind of program or task carried out
by your PC. For e.g. $ ls -lR , is command or a
request to list files in a directory and all
subdirectory in your current directory. It is a
process.
• A process is program (command given by user)
to perform some Job.
• In Linux when you start process, it gives a
number (called PID or process-id), PID starts from
0 to 65535.
02/06/21 Shriram & Linux
Contd.,
02/06/21 Shriram & Linux
Process Related Commands
NOTE that you can only kill process which are created by yourself. A
Administrator can almost kill 95-98% process. But some process can
not be killed, such as VDU Process.
02/06/21 Shriram & Linux
Advanced Commands in Alphabetical
Order
• 1. Alias
02/06/21 Shriram & Linux
AWK
• awk command is used
to manipulate the text.
This command checks
each line of a file,
looking for patterns
that match those given
on the command line.
02/06/21 Shriram & Linux
AWK – Slight Improvement
02/06/21 Shriram & Linux
Bc – Basic Calculator
shri@ubuntu:~$ bc -l
bc 1.06.94 • bc command is used for command line
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation,
Inc. calculator. It is similar to basic
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
calculator. By using which we can do
basic mathematical calculations.
1+2
3
3+2
5 shri@ubuntu:~$ cat > file1.txt
quit 1+2
quit
shri@ubuntu:~$ bc
bc 1.06.94
Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation,
shri@ubuntu:~$ bc file1.txt
Inc.
This is free software with ABSOLUTELY NO WARRANTY.
bc 1.06.94
For details type `warranty'. Copyright 1991-1994, 1997, 1998, 2000, 2004,
9*2
2006 Free Software Foundation, Inc.
18 This is free software with ABSOLUTELY NO
9+2
WARRANTY.
11 For details type `warranty'.
10-10 3
0
shri@ubuntu:~$
Quit - Will take you out of the calculator.
02/06/21 Shriram & Linux
Bg and jobs
It is helpful to list the jobs that are running in the background.
shri@ubuntu:~$ jobs
[1]+ Running gedit file1.txt &
shri@ubuntu:~$ bg
bash: bg: job 1 already in background
shri@ubuntu:~$
02/06/21 Shriram & Linux
Lets zip it
• bzip2 COMMAND: Now Zipping
bzip2 linux command is used to compress the
file. Each file is replaced by a compressed version shri@ubuntu:~$ cat file1.txt
of itself with .bz2 extension 1+2
Quit
shri@ubuntu:~$ bzip2 -c -1 file1.txt > file1.txt.bz2
shri@ubuntu:~$ ls -lrt | grep *.bz2
-rw-r--r-- 1 shri shri 54 2010-03-30 02:42 file1.txt.bz2
shri@ubuntu:~$
Now Zipping Better
• - 1 Performs fast compression,creating $ bzip2 -c -9 hiox.txt > hscripts.txt.bz2
a relatively large files. This is an $ ls -l
important option over here
-rw-rw-r-- 1 hiox hiox 9150000 Sep 26 18:37 hiox.txt
• When the file is compressed with -1 the
size was 17706 bytes and now the -rw-rw-r-- 1 hiox hiox 17706 Sep 27 12:38 hiox.txt.bz2
filesize is 2394 bytes. The 9 makes best -rw-rw-r-- 1 hiox hiox 2394 Sep 27 13:01 hscripts.txt.bz2
compression but the default is 6.
02/06/21 Shriram & Linux
Lets Catch ‘C’
CALENDAR - CAL
02/06/21 Shriram & Linux
C - Here
• We have spent time on
Cat, cd, cp, clear, Cal
and chmod.
• So let us see rest of the
advanced commands
here.
02/06/21 Shriram & Linux
Going advanced …
• chattr COMMAND:
chattr command is used to change the file attributes. This is
an admin command. Root user only can change the file
attributes/Process.
+i Make the file as Read-Only.
-i Remove the Read-Only.
+a Can't open file for writing.
-a Open file for writing.
$chattr +a file1.txt
$chattr: Operation not permitted while setting flags on file1.tx
As this is an Admin commands.. We got the above message!
02/06/21 Shriram & Linux
Going advanced
• chgrp COMMAND:
chgrp command is used to change
the group of the file or directory. This
is an admin command. Root user only
can change the group of the file or
directory.
• This is again a privileged command.
So cant make use of it.
02/06/21 Shriram & Linux
Going advanced
• chown COMMAND:
chown command is used to change the owner / user of the file or directory. This is an admin
command, root user only can change the owner of a file or directory.
SYNTAX:
The Syntax is chown [options] newowner filename/directoryname
The owner of the ‘file1.txt' file is shri, Change to new user root.
-rw-r--r-- 1 shri shri 12 2010-03-30 02:34 file1.txt
shri@ubuntu:~$ chown root file1.txt
chown: changing ownership of `file1.txt': Operation not permitted
02/06/21 Shriram & Linux
Cmp command
• cmp COMMAND:
cmp linux command compares
two files and tells you which line
numbers are different.
SYNTAX:
The Syntax is
cmp [options..] file1 file2
OPTIONS:
- c Output differing bytes as
characters.
- l Print the byte number (decimal)
and the differing byte values
(octal) for each difference.
- s Prints nothing for differing files,
return exit status only.
02/06/21 Shriram & Linux
cut
• cut COMMAND: • EXAMPLE:
cut command is used to cut Lets create a file file1.txt and
out selected fields of each line of let it have the following data:
a file. The cut command uses
delimiters to determine where to Data in file1.txt
split fields.
• This is, an example program,for
SYNTAX: cut command.
The Syntax is
cut [options] • cut -c1-3 text.txt
OPTIONS:
-c Specifies character • Output:
positions. -b Specifies byte Thi
positions.
• Cut the first three letters from
the above line.
02/06/21 Shriram & Linux
LETS GET INTO D
• df COMMAND:
df command is used to report how much free disk space is available
for each mount you have. The first column show the name of the disk
• date command partition as it appears in the /dev directory. Subsequent columns show
total space, blocks allocated and blocks available.
date shri@ubuntu:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
• The above command will /dev/sda1 4878132 2476452 2153880 54% /
print udev 254668 224 254444 1% /dev
none 254668 180 254488 1% /dev/shm
Wed Jul 23 10:52:34 IST 2008 none 254668 92 254576 1% /var/run
none 254668 0 254668 0% /var/lock
none 254668 0 254668 0% /lib/init/rw
shri@ubuntu:~$
02/06/21 Shriram & Linux
LETS GET INTO D
shri@ubuntu:~$ du
76 ./.gconfd
8 ./.cache/gedit
28 ./.cache
116 ./.mozilla/firefox/day8z6r3.default/Cache
4 ./.mozilla/firefox/day8z6r3.default/extensions
12 ./.mozilla/firefox/day8z6r3.default/chrome
12 ./.mozilla/firefox/day8z6r3.default/bookmarkbackups
3932 ./.mozilla/firefox/day8z6r3.default
3940 ./.mozilla/firefox
4 ./.mozilla/extensions/{ec8030f7-c20a-464f-9b0e-13a3a9e97384}
8 ./.mozilla/extensions
3952 ./.mozilla
du command is used to
4
4
./.gnome2_private
./t12 report how much disk space
12
8
./.update-manager-core
./.gnome2/gedit a file or directory occupies.
4 ./.gnome2/nautilus-scripts
4 ./.gnome2/panel2.d/default/launchers
8 ./.gnome2/panel2.d/default
12 ./.gnome2/panel2.d
8 ./.gnome2/keyrings
28 ./.gnome2/accels
64 ./.gnome2
4 ./Documents
20 ./.thumbnails/normal
24 ./.thumbnails
0 ./.gvfs
4 ./.update-notifier
4 ./.config/gnome-session/saved-session
8 ./.config/gnome-session
02/06/21 Shriram & Linux
E – Only Echo!
02/06/21 Shriram & Linux
F
Fg:
fg command is used to place a job in foreground.
Run some process in background.Use fg… the process will
be brought to foreground.
shri@ubuntu:~$ gedit file1.txt &
[1] 4970
shri@ubuntu:~$ fg 1
gedit file1.txt
02/06/21 Shriram & Linux
F - Finger
shri@ubuntu:~$ finger
Login Name Tty Idle Login Time Office Office Phone
shri shriram tty7 4d Mar 26 20:02 (:0)
shri shriram pts/0 Mar 26 21:19 (:0.0)
shri@ubuntu:~$
shri@ubuntu:~$ finger shri
Login: shri Name: shriram
Directory: /home/shri Shell: /bin/bash
On since Fri Mar 26 20:02 (PDT) on tty7 from :0
4 days 11 hours idle
On since Fri Mar 26 21:19 (PDT) on pts/0 from :0.0
No mail.
No Plan.
• finger command displays the user's login name, real name,
terminal name and write status (as a ''*'' after the terminal
name if write permission is denied), idle time, login time,
office location and office phone number
02/06/21 Shriram & Linux
File..
• file COMMAND:
file command tells you if the object you are looking at
is a file or a directory.
File * will list you the types of files available in that
system.
shri@ubuntu:~$ file *.txt
f1.txt: ASCII text
f2.txt: ASCII text
file1.txt: ASCII text
file2.txt: ASCII text
file_t1.txt: empty
file_t2.txt: empty
file.txt: ASCII text
linux.txt: ASCII text
result.txt: ASCII text
shriram.txt: ASCII text
test2.txt: ASCII text
02/06/21 Shriram & Linux
You are free after this slide.
• free COMMAND:
free command displays information about free and used
memory on the system.
shri@ubuntu:~$ free
total used free shared buffers cached
Mem: 509336 480580 28756 0 140528 189548
-/+ buffers/cache: 150504 358832
Swap: 281096 48 281048
shri@ubuntu:~$
02/06/21 Shriram & Linux
G
All these are used to Add groups, Delete
Groups, Modify an Existing group etc., as
all these are admin commands you will
end up in not having permission for
executing these commands..
Typing groups will get u the details of all the available groups in you system.
shri@ubuntu:~$ groups
shri adm dialout cdrom plugdev lpadmin admin sambashare
02/06/21 Shriram & Linux
Can We Halt? – System Related
• Commands
To halt the system:
halt
This command is similar to poweroff, which
shutdown the system.
• To Poweroff the system:
poweroff
Poweroff command used for turnoff the system.
• To reboot the system:
reboot
Reboot command used for reboots/restarts the
system.
02/06/21 Shriram & Linux
Host
• host COMMAND:
host command is used to find the ip address of
the given domain name and also prints the domain
name for the given ip.
shri@ubuntu:~$ host vit.ac.in
vit.ac.in has address 192.168.64.3
vit.ac.in mail is handled by 5 alt1.aspmx.l.google.com.\032.
vit.ac.in mail is handled by 5 alt2.aspmx.l.google.com.
vit.ac.in mail is handled by 10 aspmx2.googlemail.com.\032.
vit.ac.in mail is handled by 10 aspmx3.googlemail.com.\032.
vit.ac.in mail is handled by 10 aspmx4.googlemail.com.\032.
vit.ac.in mail is handled by 10 aspmx5.googlemail.com.\032.
vit.ac.in mail is handled by 1 aspmx.l.google.com.\032.
shri@ubuntu:~$ host yahoo.co.in
yahoo.co.in has address 68.180.206.184
yahoo.co.in has address 206.190.60.37
yahoo.co.in mail is handled by 10 in32.mxauth.yahoo.com.
shri@ubuntu:~$ host 68.180.206.184
184.206.180.68.in-addr.arpa domain name pointer w2.rc.vip.sp1.yahoo.com.
shri@ubuntu:~$
02/06/21 Shriram & Linux
Host id and Host Name
• hostid COMMAND:
shri@ubuntu:~$ hostid
hostid command prints the 007f0101
numeric identifier or id of the shri@ubuntu:~$
current host in hexadecimal.
SYNTAX:
The Syntax is
hostid
• hostid COMMAND:
hostid command prints the
numeric identifier or id of the shri@ubuntu:~$ hostname
current host in hexadecimal. UBUNTU
shri@ubuntu:~$
SYNTAX:
The Syntax is
hostid
02/06/21 Shriram & Linux
id
id COMMAND:
id command prints the effective(current) and real userid(UID)s and
groupid(GID)s.
SYNTAX:
The Syntax is
id
shri@ubuntu:~$ id
uid=1000(shri) gid=1000(shri)
groups=4(adm),20(dialout),24(cdrom),46(plugdev),104(lpadmin),115(ad
min),120(sambashare),1000(shri)
02/06/21 Shriram & Linux
info
• info command is used to display • shri@ubuntu:~$ info man
the readable online documentation
for the specified command .
• Typing just info will lead you screen
to be filled with hell a lot of data! • shri@ubuntu:~$ info cp
• IFCONFIG
• ifconfig command displays information about the
network interfaces attached to the system and also
used to configure the network interface.
To Assign IP address to Network Interface[Ethernet
Card]:
ifconfig eth0 192.168.0.12 up
The above command will Assign IP address 192.168.0.12
to Ethernet card with name eth0.
To inactivate the Network Interface[Ethernet Card]:
ifconfig eth0 down
The above command inactivates the ethernet card.
02/06/21
Shriram & Linux
netstat
• nestat command displays statistics • unix 3 [ ] STREAM CONNECTED
information and current state of network 9803 @/tmp/dbus-3Imoh4QFZa
connections, protocol, ports/ sockets and • unix 3 [ ] STREAM CONNECTED
devices. 9802
• unix 3 [ ] STREAM CONNECTED
9801 /tmp/orbit-shri/linc-7b7-0-
28f9f13a74fe6
• unix 3 [ ] STREAM CONNECTED
9800
• unix 3 [ ] STREAM CONNECTED
9799 /tmp/orbit-shri/linc-773-0-
455a56f8d87af
• unix 3 [ ] STREAM CONNECTED
9796
• unix 3 [ ] STREAM CONNECTED
9792 @/tmp/.X11-unix/X0
• unix 3 [ ] STREAM CONNECTED
9791
• unix 3 [ ] STREAM CONNECTED
9790 /tmp/orbit-shri/linc-7b6-0-
3923529828c29
02/06/21 Shriram & Linux
route
• route command displays
routing table resides in kernel
and also used to modify the
routing table.
• The tables which specifies how
packets are routed to a host is
called routing table.
shri@ubuntu:~$ route –n (Where –n is net)
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.98.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
0.0.0.0 192.168.98.2 0.0.0.0 UG 0 0 0 eth0
shri@ubuntu:~$
02/06/21 Shriram & Linux
Yes… Am Saying Bye
• yes command repeatedly prints the shri@ubuntu:~$ yes shriram | more
given string separated by a space and shriram
followed by a newline until it is killed. shriram
If no string is given, it just prints 'y' shriram
repeatedly until it is killed. It is
normally used in scripts, its output is shriram
piped to a command or program that shriram
prompts you to do this or that (do shriram
you want to delete this file press 'y' shriram
or 'n')
shriram
shriram
shriram
shriram
shriram
02/06/21 Shriram & Linux
Let me say bye to commands
here!
Itz your turn
02/06/21 Shriram & Linux