tutorial 1

Download Tutorial 1

If you can't read please download the document

Upload: viren

Post on 20-Nov-2015

5 views

Category:

Documents


3 download

DESCRIPTION

this is tutorial

TRANSCRIPT

Tutorial 1Q-1 :Describe & perform following UNIX command with example1)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 built 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 system3)cal :-The cal (Calendar), it is used to displays calendar of the present month or any other month of any year that is advancing or passed.4)pwdThe command pwd (print working directory), prints the current working directory with 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 youve changed to and are trying to run other commands5)logout :-Type logout at the prompt to disconnect from your Linux machine or to logout a particular user session from the system. Keep in mind that although rudimentary, leaving your critical account logged on may be a security concern. We always recommend promptly using logout when you are finished using your root account6)bc :-bc utility is surely one of the underdogs when it comes to calculations on command line. Its a feature rich utility that has its own fan base but needs time to get comfortable with. Here, in this article, structured in form of Q&A, lets get comfortable with bc utility by discussing both basic and advanced features of this 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 output8)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 folder, folder already exists.9)cd :-Finally, the frequently used cd command stands for (change directory), it change the working directory to execute, copy, move write, read, etc. from terminal itself.10)cd .. :-Move to the parent directory of the current directory. This command will make the current working directory "/home.11)rmdir :-Deletes the specified directory, provided it is already empty12)ls :-ls [option(s)] [file(s)]If you run ls without any additional parameters, the program will list the contents of the current directory in short form.Type ls to see a list of the files and directories located in the current directory. If youre in the directory named games and you type ls, a list will appear that contains files in the games directory and sub-directories in the games directory13)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 >test214)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 your file system.tree is a recursive directory listing program that produces a depth 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 in17)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 structuremkdir scscd scsmkdir mcalmkdir bcamkdir mscitcd mcalmkdir 4th_semmkdir 6th_semcd 4th_semmkdir osmkdir javacd ..cd ..cd mscitmkdir 4th_semmkdir 2nd_semcd 2nd_semmkdir osmkdir 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 characters), 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 permissions so that: 1.the user can read, write, and execute it; 2.members of your group can read and execute it; andHere 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 numbers 4, 2, 1, and 0: 4 stands for "read", 2 stands for "write", 1 stands for "execute", and 0 stands for "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 execute).See below for more examples of both types of notation.Command Syntaxchmod [OPTION]... MODE[,MODE]... FILE...chmod [OPTION]... OCTAL-MODE FILE...chmod [OPTION]... --reference=RFILE FILE...----------3)chownchown command changes the user and/or group ownership of for given filechown owner-user filechown owner-user:owner-group filechown owner-user:owner-group directorychown 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 newnameYou 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 (using wildcards if desired), and then the destination directory:mv file dirmv file1 dir1/file2 dir2mv *.c *.h .. ------------5)cp :-Copies files and directoriescp 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 quickly review various cp command options using some practical examples.Even if you are using cp command all the times, probably one or more examples explained 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 totals for all fileswc [OPTION]... [FILE]...-----------7)umask :-------------8)factor :-factor - factor numbersSYNOPSIS factor [NUMBER]... factor OPTION--------------9)ln :- ln - make links between filesSYNOPSIS ln [OPTION]... [-T] TARGET LINK_NAME (1st form) ln [OPTION]... TARGET (2nd form) ln [OPTION]... TARGET... DIRECTORY (3rd form) ln [OPTION]... -t DIRECTORY TARGET... (4th 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 filesSYNOPSIS 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 filesSYNOPSIS 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 viewingSYNOPSIS 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) pro- vides more(1) emulation and extensive enhancements.-----------13)less :- less - opposite of moreSYNOPSIS less -? less --help less -V less --version less [-[+]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 move- ment 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 ownershipSYNOPSIS 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 filesSYNOPSIS sort [OPTION]... [FILE]...DESCRIPTION Write sorted concatenation of all FILE(s) to standard output.