Sie sind auf Seite 1von 9

Ex.

No : Date : AIM:

BASIC UNIX COMMANDS

To execute and implement the basic Shell UNIX commands. DIRECTORY HANDLING COMMANDS 1.[root@localhost root]# mkdir arun //Creates a directory named arun 2.[root@localhost root]# cd arun //Enters into the directory arun Example: [root@localhost root]$ cd arun [root@localhost arun]$ 3.[root@localhost arun]# cd //Comes out of the directory arun [root@localhost root] Example: [root@localhost root]$ cd arun [root@localhost arun]$ cd [root@localhost root]$ 4.[root@localhost root]# pwd //Shows the present working directory Example: [root@localhost root]$ pwd /home/root 5.[root@localhost root]#rmdir arun 6.[root@localhost root]# ls Example: [root@localhost root$ls cse it ec eee mech civil //Used to remove directory arun //Shows the list of files & directories

FILE HANDLING COMMANDS. 1.[root@localhost root]# cat > tksct //Creates a New file tksct I studying B.E CSE. 2.[root@localhost root]# cat tksct //Opens the created file tksct" I studying B.E CSE. 3.[root@localhost root]# cat >> tksct //Appends the details in the file tksct I'm studying in Theni Kammavar Sangam College of Technology. 4.[root@localhost root]# cat tksct I studying B.E CSE. I'm studying in Theni Kammavar Sangam College of Technology. 5.[root@localhost root]$ cp data1 data2 [root@localhost root]$ cat data1 a b c d [root@localhost root]$ cat data2 a b c d //To create duplicate copies

6.[root@localhost root]# rm data1 //Removes the file data1 rm: remove regular file `data1'? y 7. (i) [root@localhost root]# wc tksct //Shows the no. of lines, words & characters. 2 10 65 tksct (ii) [root@localhost root]# wc -l tksct //Shows the no. of lines alone. 2 tksct (iii) [root@localhost root]# wc -w tksct //Shows the no. of words alone. 10 tksct (iv) [root@localhost root]# wc -c tksct //Shows the no. of characters alone. 65 tksct 8. [root@localhost root]$ mv data1 data5 //to move ordinary and directory files [root@localhost root]$ cat data5 a b c d [root@localhost root]$ cat data1 cat: data1: No such file or directory

9.[root@localhost root]$ find data5 //To find a file data5 PATTERN SEARCHING COMMANDS. 1.[root@localhost root]# grep m program //Prints the sentence with the letter m My Name is sachin I'm studying in Theni Kammavar Sangam College of Technology. 2.[root@localhost root]$ egrep "are|College" department // to search for the multiple pattern we belong to Theni Kammavar Sangam College of Technology. we are of cse students. 3.[root@localhost root]$ fgrep "stands for" student //to extract only the fixed string CSE stands for Computer Science and Engineering. GENERAL PURPOSE COMMANDS. SIMPLE COMMANDS. 1.[root@localhost root]# cal March 2006 Su Mo Tu We Th Fr 1 2 3 5 6 7 8 9 10 12 13 14 15 16 17 19 20 21 22 23 24 26 27 28 29 30 31 Sa 4 11 18 25 //Prints the current time. //Prints the calendar if the present month

2.[root@localhost root]# date Thu Mar 9 19:26:27 IST 2006

3.[root@localhost root$ man clear // Opens manual on clear NAME clear - clear the terminal screen SYNOPSIS clear DESCRIPTION clear clears your screen if this is possible. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen. clear ignores any command-line parameters that may be present.

4.[root@localhost root]# bc //Open the Binary Calculator bc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc. This isfree software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 10 * 20 200 STATUS INFORMATION COMMANDS 1.[root@localhost root]$ who //to Display the list of users who are all currently logged into the system. cse pts/4 Feb 23 23:56 (10.0.0.135) cse pts/17 Feb 24 00:05 (10.0.0.221) cse pts/10 Feb 24 00:09 (10.0.0.15) cse pts/13 Feb 24 00:13 (10.0.0.180) cse pts/1 Feb 24 00:14 (10.0.0.49) cse pts/24 Feb 24 00:14 (10.0.0.6) cse pts/3 Feb 24 00:17 (10.0.0.36) cse pts/30 Feb 24 00:19 (10.0.0.137) 2.[root@localhost root]# who am I // To displaysthe current user name cse pts/3 Feb 24 00:17 (10.0.0.36) 3.[root@localhost root]$ tty //It will retun the pathname with your terminal /dev/pts/3 4.[root@localhost root]$ id //To Display the Numerical value that corresponda to you loginname. uid=502(student) gid=502(cse) groups=502(root) 5.[root@localhost root]$ finger student // Gives you more Information about the User. Login: student Name: (null) Directory: /home/student Shell: /bin/bash On since Thu Apr 19 09:38 (IST) on :0 (messages off) On since Thu Apr 19 09:47 (IST) on pts/1 from :0.0 No mail. No Plan. COMMUNICATION COMMANDS 1.[root@localhost root]# wall Hai // To send message hai to all users there who are currently logged in. Hai 2.[root@localhost root]$ mail cse // To send the textual messages from one user to another. Subject: Hai.How are you. All the best for your exams. Have a nice day.

3.[root@localhost cse$ mail // Read your mail Mail version 8.1 6/6/93. Type ? for help. "/var/spool/mail/ece": 1 messages 1 new a) >N 1 cse@localhost.locald Tue Feb 23 23:06 18/720 "Hai."& Message 1: From cse@localhost.localdomain Tue Feb 23 23:06:23 2010 Date: Tue, 23 Feb 2010 23:06:22 +0530 From: cse@localhost.localdomain To: cse@localhost.localdomain Subject: Hai. How are you.Have you prepared for your exams. ALL THE BEST FOR YOUR EXAMS. Have a nice day. b) & reply //To send the reply to the specified user To: cse@localhost.localdomain cse@localhost.localdomain Subject: Re: Hai. ThanksCc: & ece Unknown command: "ece" c)& exit //Exit from the mail d)&type //Print the mail message e)&delete //Delete from the mail box INPUT AND OUTPUT REDIRECTION COMMANDS 1.[root@localhost root]$ date > a1 [root@localhost root]$ cat a1 Tue Feb 23 22:59:03 IST 2.[root@localhost root$< //To redirect the output of a command to a file. [ece@localhost ece]$ cat < department CSE EEE SECURITY COMMANDS 1.[root@localhost root]$ ls -l // To list files & Directories in long format total 3 -rw-rw-r-- 1 ece ece 30 Feb 9 23:47 lop -rwx------ 1 ece ece 30 Feb 9 23:43 pal -rw-rw-r-- 1 ece ece 65 Feb 23 23:16 science 2. [root@localhost root]$ chmod -u science //(-) denotes removing the permission (u)denotes the user acess [root@localhost root]$ ls -l total 3 -rw-rw-r-- 1 ece ece 30 Feb 9 23:47 lop -rwx------ 1 ece ece 30 Feb 9 23:43 pal ---------- 1 ece ece 65 Feb 23 23:16 science //showsMissing Permissions

[root@server1 root]$ cat science cat: science : Permission denied 3.[root@localhost root]$ chmod u+r,u+w science // (+)denotes assigningPermissions (w) denotes writing permissions (r)denotes reading permissions [root@localhost root]$ ls -l total 3 -rw-rw-r-- 1 ece ece 30 Feb 9 23:47 lop -rwx------ 1 ece ece 30 Feb 9 23:43 pal -rw------- 1 ece ece 65 Feb 23 23:16 science //the user now has reading writing permission 4.[root@server1 root]$ cat science hi ! how r u ? WILD CARD COMMANDS 1.[root@localhost root]$ ls m* //To representing any number of characters used in theprefix or suffix. [root@localhost root]$ ls kanna mvj mvs student vikram [root@localhost root]$ ls m* mvj mvs PIPES AND FILTERS COMMANDS 1.[root@localhost root]# more //To Displays the output page by page [root@localhost root]$ ls | more program1 program2 program3 program4 program5 program6 program7 program8 program9 program10 program11 program12 program13 program14 program15 program16 program17 program18 program19 --More-- //Press Enter to see the next page.

2.[root@localhost root]# tr // It is used to translate characters taken from the standard input. [root@localhost root]$ cat dept cse ece eee it mech [root@localhost root]$ cat dept|tr "[a-z]" "[A-Z]" CSE ECE EEE IT MECH [root@localhost root]$ cat sachin arun bala cibi david elango franklin ganesh harish jegan kalidos lalprasanth mahesh nataraj [root@localhost root]$ cat tendulkar yuvaraj zaheer 3.[root@localhost root]$ head -5 sachin //To Display the First Five lines arun bala cibi david elango 4.[root@localhost root]$ tail -5 sachin // To Display the Last Five lines jegan kalidos lalprasanth mahesh nataraj

5.[root@localhost root]# sort sachin // Sorts in ascending order arun bala cibi david elango franklin ganesh harish jegan lalprasanth mahesh nataraj 6.[root@localhost root]# sort -r sachin //Sorts in descending order nataraj mahesh lalprasanth kalidos jegan harish ganesh franklin elango david cibi bala arun 7.[root@localhost root]# cut //To cut the selected fields. [root@localhost root]$ cut -c2 sachin r a i a l r a a e a a a a

8.[root@localhost root]# paste //To paste the contenet from one to another file. [root@localhost root]paste sachin tendulkar arun yuvaraj bala zaheer cibi david elango franklin ganesh harish jegan kalidos lalprasanth mahesh nataraj

RESULT: Thus the Basic Shell Commands were executed

Das könnte Ihnen auch gefallen