Sie sind auf Seite 1von 16

STUDY OF UNIX / LINUX COMMANDS

AIM To study the Linux command and to implement them SL.NO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 COMMAND as at awk basename bc bdiff bfs bg break bs bye cal calendar cancel cat cc cd chdir checkeq chmod chown chsh cksum clear DESCRIPTION An assembler. Command scheduler. Awk script processing program. Deletes any specified prefix from a string. Calculator. Compare large files. Editor for large files. Continues a program running in the background. Break out of while, for, foreach, or until loop. Battleship game. Alias often used for the exit command. Calendar Display appointments and reminders. Cancels a print job. View and/or modify a file. C compiler. Change directory. Change directory. Language processors to assist in describing equations. Change the permission of a file. Change the ownership of a file. Change login shell. Display and calculate a CRC for files. Clears screen.

25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

cls cmp col comm continue copy cp csh csplit ctags cut date df diff dircmp dirname dos2unix du echo ed edit egrep emacs env eqn ex exit

Alias often used to clear a screen. Compare files. Reverse line-feeds filter. Compare files and select or reject lines that are common. Break out of while, for, foreach, or until loop. Copy files. Copy files. Execute the C shell command interpreter Split files based on context. Create a tag file for use with ex and vi. Cut out selected fields of each line of a file. Tells you the date and time in Unix. Display the available disk space for each mount. Displays two files and prints the lines that are different. Lists the different files when comparing directories. Deliver portions of path names. Converts text files between DOS and Unix formats. Tells you how much space a file occupies. Displays text after echo to the terminal. Line oriented file editor. Text editor. Search a file for a pattern using full regular expressions. Text editor. Displays environment variables. Language processors to assist in describing equations. Line-editor mode of the vi text editor. Exit from a program, shell or log you out of a Unix

n/w 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 expand expr fg fgrep file find finger fmt for foreach fromdos fsck ftp groupmod gunzip gview gvim gzip halt hash hashstat head help history Expand copies of file s. Evaluate arguments as an expression. Continues a stopped job by running it in the foreground Search a file for a fixed-character string. Tells if the object looking at is a file or if it is a directory. Finds one or more files assuming that you know their approximate filenames. Lists information about the user. Simple text formatters. Shell built-in functions to repeatedly execute action(s) for a selected number of times. Shell built-in functions to repeatedly execute action(s) for a selected number of times. Converts text files between DOS and Unix formats. Check and repair a Linux file system. Enables ftp access to another terminal. Enables a super user or root to modify a group. Expand compressed files. A programmers text editor. A programmers text editor. Compress files. Stop the computer. Remove internal hash table. Display the hash stats. Displays the first ten lines of a file, unless otherwise stated. If computer has online help documentation installed this command will display it. Display the history of commands typed.

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

host hostid hostname id ifconfig ifdown ifup jobs join keylogin kill ld less lex link ln lo login logname logout lp lprm lpstat ls mach mail mailcompat mailx

DNS lookup utility. Prints the numeric identifier for the current host. Set or print name of current host system. Shows you the numeric user and group ID on BSD. Sets up network interfaces. take a network interface down bring a network interface up List the jobs currently running in the background. Joins command forms together. Decrypt the user's secret key. Cancels a job. Link-editor for object files. Opposite of the more command. Generate programs for lexical tasks. Calls the link function to create a link to a file. Creates a link to a file. Allows you to exit from a program, shell or log you out of a Unix network. Signs into a new system. Returns users login name. Logs out of a system. Prints a file on System V systems. Removes print requests from the print queue. Lists status of the LP print services. Lists the contents of a directory. Display the processor type of the current host. One of the ways that allows you to read/send E-Mail. Provide SunOS 4.x compatibility for the Solaris mailbox format. Mail interactive message processing system.

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126

make man mesg mkdir mkfs more mv netstat newform newgrp on pack pagesize passwd paste pcat pgrep pico pine ping pkill poweroff pr

Executes a list of shell commands associated with each target. Display a manual of a command. Control if non-root users can send text messages to you. Create a directory. Build a Linux file system, usually a hard disk partition. Displays text one screen at a time. Renames a file or moves it from one directory to another directory. Shows network status. Change the format of a text file. Log into a new group. Execute a command on a remote system, but with the local environment. Shrinks file into a compressed file. Display the size of a page of memory in bytes, as returned by getpagesize. Allows you to change your password. Merge corresponding or subsequent lines of files. Compresses file. Examine the active processes on the system and reports the process IDs of the processes Simple and very easy to use text editor in the style of the Pine Composer. Command line program for Internet News and Email. Sends ICMP ECHO_REQUEST packets to network hosts. Examine the active processes on the system and reports the process IDs of the processes Stop the computer. Formats a file to make it look better when printed.

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152

printf ps pwd quit rcp reboot red rehash remsh repeat rgview rgvim rlogin rm rmail rmdir rn route rpcinfo rsh rview rvim sar script sdiff sendmail

Write formatted output. Reports the process status. Print the current working directory. Allows you to exit from a program, shell or log you out of a Unix network. Copies files from one computer to another computer. Stop the computer. Line oriented file editor. Recomputes the internal hash table of the contents of directories listed in the path. Runs a command on another computer. Shell built-in functions to repeatedly execute action(s) for a selected number of times. A programmers text editor. A programmers text editor. Establish a remote connection from your terminal to a remote machine. Deletes a file without confirmation (by default). One of the ways that allows you to read/send E-Mail. Deletes a directory. Reads newsgroups. Show / manipulate the IP routing table. Report RPC information. Runs a command on another computer. A programmers text editor. A programmers text editor. Displays the activity for the CPU. Records everything printed on your screen. Compares two files, side-by-side. Sends mail over the Internet.

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

set setenv sh shred shutdown sleep sort spell split stat stop strip stty sysinfo sysklogd tabs tail talk tac tar tcpdump tee telnet time timex

Set the value of an environment variable. Set the value of an environment variable. Runs or processes jobs through the Bourne shell. Delete a file securely, first overwriting it to hide its contents. Turn off the computer immediately or at a specified time. Waits a x amount of seconds. Sorts the lines in a text file. Looks through a text file and reports any words that it finds in the text file that are not in the dictionary. Split a file into pieces. Display file or filesystem status. Control process execution. Discard symbols from object files. Sets options for your terminal. Get and set system information strings. Linux system logging utilities. Set tabs on a terminal. Delivers the last part of the file. Talk with other logged in users. Concatenate and print files in reverse. Create tape archives and add or extract files. Dump traffic on a network. Read from an input and write to a standard output or file. Uses the telnet protocol to connect to another remote computer. Used to time a simple command. The timex command times a command; reports process data and system activity.

178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203

todos top touch ul umask unalias unhash uname uncompress uniq unmount unpack untar until useradd userdel usermod vacation vedit vgrind vi vim view w wait wc

Converts text files between DOS and Unix formats. Display Linux tasks. Change file access and modification time. Reads the named filenames or terminal and does underlining. Get or set the file mode creation mask. Remove an alias. Remove internal hash table. Print name of current system. Uncompressed compressed files. Report or filter out repeated lines in a file. Crates a file systems and remote resources. Expands a compressed file. Create tape archives and add or extract files. Execute a set of actions while/until conditions are evaluated TRUE. Create a new user or updates default new user information. Remove a users account. Modify a users account. Reply to mail automatically. Screen-oriented (visual) display editor based on ex. Grind nice program listings Screen-oriented (visual) display editor based on ex. A programmers text editor. A programmers text editor. Show who is logged on and what they are doing. Await process completion. Displays a count of lines, words, and characters in a file

204 205 206 207 208 209 210 211 212 213 214

whereis while which who whois write xrdb yacc yes yppasswd zcat

Locate a binary, source, and manual page files for a command. Repetitively execute a set of actions while/until conditions are evaluated TRUE. Locate a command. Displays who is on the system. Internet user name directory service. Send a message to another user. X server resource database utility. Short for yet another compiler-compiler, yacc is a compiler. Repeatedly output a line with all specified STRING(s), or 'y'. Changes network password in the NIS database. Compress files.

RESULT : Thus the Linux commands have been executed.

GREP COMMAND

AIM : To write a linux program to implement the grep command ALGORITHM : 1. Assign the string value hi to char [] variable ar. 2. If argv is less than 3 then print usage : grep <pattern>file name . 3. Open the file args[2] in read mode and assign the file address to file pointer f. 4. while not end of file ,do the following 5. Assign i=0 6. Read each character from the file and store it in char array str 7. Compare the length of str array with args[1]. 8. if str array has more characters than args[1] ,then copy the excess characters from str array to the temp variable 9. Compare the temp with args[1],if they are equal then print the str array and return.

SOURCE CODE: #include < stdio.h> #include < string.h> int main(int argv,char *args[] ) { FILE *f; char str[100],c,temp[30],ar[]=hi; if (argv<3 ) { printf(Usage : grep <pattern>file name .); return ; } f= fopen(args[2],r); while(!feof (f)) { i=0; while(1) { fscanf(f,%c,&c); if(feof(f)) { str[i++]=\0; break; } if(c == \n) { str[i++]=\0; break; } str[i++]=c; } if (strlen(str)>=strlen(args[1])) { for (k=0;k<=strlen(str)-strlen(args[1]);k++) { for (m=0;m<strlen(args[1]);m++) { temp[m]=str[k+m]; } temp[m]=\0; if(strcmp(temp,args[1])==0) { printf(%s \n ,str);

break; } } } } return 0; }

Output : [user15@localhost saraviji]$ cc grep.c [user15@localhost saraviji]$ /a.out. grep Usage : grep <pattern><file name> [user15@localhost saraviji]$ grep printf grep.c printf(Usage : grep <pattern>file name .); printf(%s \n ,str); [user15@localhost saraviji]$ grep scanf grep.c fscanf(f,%c,&c); [user15@localhost saraviji]$ grep while grep.c while(!feof (f)) while(1) [user15@localhost saraviji]$ grep if grep.c if (argv<3 ) if(feof(f)) if(c == \n) if (strlen(str)>=strlen(args[1])) if(strcmp(temp,args[1])==0)

RESULT : Thus using linux program grep command using linux command has been executed successfully and ouput is verified.

FIBONACCI SERIES echo "Enter the limit:" read n echo "The fibonacci series is" a=-1 b=1 i=0 while [ $i -lt $n ] do c=`expr $a + $b` a=$b b=$c echo "$c" i=`expr $i + 1` done

OUTPUT: Enter the limit 5 The Fibonacci Series is 0 1 1 2 3

Das könnte Ihnen auch gefallen