Sei sulla pagina 1di 7

Tutorial

Q-1 :Describe & perform following UNIX command with example


1)login :login is used when signing onto a system. It can also be used to switch from one
user to another at any time (most modern shells have support for this feature b
uilt into them, however).
If an argument is not given, login prompts for the username.
2)passwd :passwd [option(s)] [username]
Users may change their own passwords at any time using this command. Furthermore
, the administrator root can use the command to change the password of any user
on the system
3)cal :The cal (Calendar), it is used to displays calendar of the present month or any ot
her month of any year that is advancing or passed.
4)pwd
The command pwd (print working directory), prints the current working directory wi
th full path name from terminal.Type pwd and hit enter. You'll see the full name
of the directory you are currently in. This is your directory path and is very
handy. This is especially handy when you forget which directory you ve changed to
and are trying to run other commands
5)logout :Type logout at the prompt to disconnect from your Linux machine or
articular user session from the system. Keep in mind that although
leaving your critical account logged on may be a security concern.
ommend promptly using logout when you are finished using your root

to logout a p
rudimentary,
We always rec
account

6)bc :bc utility is surely one of the underdogs when it comes to calculations on comma
nd line. It s a feature rich utility that has its own fan base but needs time to g
et comfortable with. Here, in this article, structured in form of Q&A, let s get c
omfortable with bc utility by discussing both basic and advanced features of thi
s command line calculator.
7)cat :The cat stands for (Concatenation). Concatenate (join) two or more plain file and/
or print contents of a file on standard output
8)mkdir :The mkdir (Make directory) command create a new directory with name path. However
is the directory already exists, it will return an error message cannot create fo
lder, folder already exists .
9)cd :-

Finally, the frequently used cd command stands for (change directory), it change t
he working directory to execute, copy, move write, read, etc. from terminal itse
lf.
10)cd .. :Move to the parent directory of the current directory. This command will make th
e current working directory "/home.
11)rmdir :Deletes the specified directory, provided it is already empty
12)ls :ls [option(s)] [file(s)]
If you run ls without any additional parameters, the program will list the conte
nts of the current directory in short form.Type ls to see a list of the files an
d directories located in the current directory. If you re in the directory named g
ames and you type ls, a list will appear that contains files in the games direct
ory and sub-directories in the games directory
13)cat > :cat stands for "catenate." It reads data from files, and outputs their contents.
It is the simplest way to display the contents of a file at the command line.
We will create a file called test2 file with below command.
cat >test2
14)man :Type man followed by a command to get detailed information about how to use the
command. Ex:
man ls
15)tree :tree lists the contents of directories in a tree-like format. It's a really neat
and useful program you can use at the command line to view the structure of you
r file system.tree is a recursive directory listing program that produces a dept
h indented listing of files and output is to tty. With no arguments, tree lists
the files in the current directory.
16)who :The who command prints information about all users who are currently logged in
17)who am i :Whoami prints or writes the user/login name associated with the current user ID
to the standard output.
18)clear :Type clear to clean up your command prompt window.
This is especially helpful when you are typing lots of commands and need a clean
window to help you focus.
This is also useful when you are getting ready to type a rather long command and

do not wish to become confused by other details on the screen.


================================================================
Q-2 : Write a UNIX code for following tree structure
mkdir scs
cd scs
mkdir mcal
mkdir bca
mkdir mscit
cd mcal
mkdir 4th_sem
mkdir 6th_sem
cd 4th_sem
mkdir os
mkdir java
cd ..
cd ..
cd mscit
mkdir 4th_sem
mkdir 2nd_sem
cd 2nd_sem
mkdir os
mkdir php
====================================================================
Q-3)
1)ls -l :shows long format inc. group owner, size, date modified, permissions.
1st Character
File Type: First character specifies the type of the file.
in the 1st character indicates that this is a normal file. Following are the
possible file type options in the 1st character of the ls -l output.
Field Explanation
- normal file
d directory
s socket file
l link file
Field 1 File Permissions: Next 9 character specifies the files permission. Each
3 characters refers to the read, write, execute permissions for user,
group and
world In this example, -rw-r indicates read-write permission
for user,
read
permission for group, and no permission for others.
Field 2
Number of links: Second field specifies the number of links for that
file. In this example, 1 indicates only one link to this file.
Field 3 Owner: Third field specifies owner of the file. In this example, this
file is owned by username ramesh .
Field 4
Group: Fourth field specifies the group of the file. In this example,
this file belongs to team-dev group.
Field 5 Size: Fifth field specifies the size of file. In this example, 9275204'
indicates the file size.

Field 6
Last modified date & time: Sixth field specifies the date and time of
the last modification of the file. In this example, Jun 13 15:27'
specifies
the last modification time of the file.
Field 7 File name: The last field is the name of the file. In this example, the
file name is mthesaur.txt.gz.
--------------2)chmod :chmod is used to change the permissions of files or directories.
There are two ways to represent these permissions: with symbols (alphanumeric ch
aracters), or with octal numbers (the digits 0 through 7).
Let's say you are the owner of a file named myfile, and you want to set its perm
issions so that:
1.the user can read, write, and execute it;
2.members of your group can read and execute it; and
Here the digits 7, 5, and 4 each individually represent the permissions for the
user, group, and others, in that order. Each digit is a combination of the numbe
rs 4, 2, 1, and 0:
4
2
1
0

stands
stands
stands
stands

for
for
for
for

"read",
"write",
"execute", and
"no permission."

So 7 is the combination of permissions 4+2+1 (read, write, and execute), 5 is 4+


0+1 (read, no write, and execute), and 4 is 4+0+0 (read, no write, and no execut
e).
See below for more examples of both types of notation.
Command Syntax
chmod [OPTION]... MODE[,MODE]... FILE...
chmod [OPTION]... OCTAL-MODE FILE...
chmod [OPTION]... --reference=RFILE FILE...
---------3)chown
chown command changes the user and/or group ownership of for given file
chown
chown
chown
chown

owner-user file
owner-user:owner-group file
owner-user:owner-group directory
options owner-user:owner-group file

------------4)mv :To rename a single file on the server, type mv, then the current file name, and
then the new file name:
mv oldfile newname
You can also move the file into a different directory and change the name:

To move one or more files into an existing subdirectory, specify the files (usin
g wildcards if desired), and then the destination directory:
mv file dir
mv file1 dir1/file2 dir2
mv *.c *.h ..
-----------5)cp :Copies files and directories
cp is one of the basic command in Unix. You already know that it is used to copy
one or more files or directories from source to destination.
While this tutorial is for beginners, it is also helpful for everybody to quickl
y review various cp command options using some practical examples.
Even if you are using cp command all the times, probably one or more examples ex
plained below might be new to you.
The general form of copy command:
cp [option] source destination
------------6)wc :The wc (word count) command is a very simple utility found in all Unix variants.
Its purpose is counting the number of lines, words and characters of text files
. If multiple files are specified, wc produces a count for each file, plus total
s for all files
wc [OPTION]... [FILE]...
----------7)umask :-----------8)factor :factor - factor numbers
SYNOPSIS
factor [NUMBER]...
factor OPTION
-------------9)ln :ln - make links between files
SYNOPSIS
ln
ln
ln
ln

[OPTION]...
[OPTION]...
[OPTION]...
[OPTION]...

[-T] TARGET LINK_NAME


TARGET
TARGET... DIRECTORY
-t DIRECTORY TARGET...

(1st
(2nd
(3rd
(4th

form)
form)
form)
form)

DESCRIPTION
In the 1st form, create a link to TARGET with the name LINK_NAME. In
the 2nd form, create a link to TARGET in the current directory. In the

3rd and 4th forms, create links to each TARGET in DIRECTORY. Create
hard links by default, symbolic links with --symbolic. When creating
hard links, each TARGET must exist.
-----------10) head :head - output the first part of files
SYNOPSIS
head [OPTION]... [FILE]...
DESCRIPTION
Print the first 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With
no FILE, or when FILE is -, read standard input.
-----------11)tail :tail - output the last part of files
SYNOPSIS
tail [OPTION]... [FILE]...
DESCRIPTION
Print the last 10 lines of each FILE to standard output. With more
than one FILE, precede each with a header giving the file name. With
no FILE, or when FILE is -, read standard input.
--------12)more :more - file perusal filter for crt viewing
SYNOPSIS
more [-dlfpcsu] [-num] [+/ pattern] [+ linenum] [file ...]
DESCRIPTION
More is a filter for paging through text one screenful at a time. This
version is especially primitive. Users should realize that less(1) provides more(1) emulation and extensive enhancements.
----------13)less :less - opposite of more
SYNOPSIS
less
less
less
less
less

-?
--help
-V
--version
[-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
[-b space] [-h lines] [-j line] [-k keyfile]
[-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
[-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
[-# shift] [+[+]cmd] [--] [filename]...
(See the OPTIONS section for alternate option syntax with long option
names.)

DESCRIPTION
Less is a program similar to more (1), but which allows backward movement in the file as well as forward movement. Also, less does not have

to read the entire input file before starting, so with large input
files it starts up faster than text editors like vi (1).
-----------14)pg :-----------15)chgrp :chgrp - change group ownership
SYNOPSIS
chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...
DESCRIPTION
Change the group of each FILE to GROUP. With --reference, change the
group of each FILE to that of RFILE.
---------16)piping :----------17)sort :sort - sort lines of text files
SYNOPSIS
sort [OPTION]... [FILE]...
DESCRIPTION
Write sorted concatenation of all FILE(s) to standard output.

Potrebbero piacerti anche