28
LAB FILE UNIX/LINUX Submitted To:- Submitted By:- MR. UTKARSH SHARMA LALIT CHAUDHARY CS 2nd Year 4th Sem BETN1CS12049

Linux Lab File

Embed Size (px)

DESCRIPTION

Linux Lab programs on terminal

Citation preview

Lalit Chaudhary

KUNAL SAHU Lab File Linux

LAB FILEUNIX/LINUX

Submitted To:-Submitted By:-MR. UTKARSH SHARMA LALIT CHAUDHARY CS 2nd Year 4th Sem BETN1CS12049

Table of Contents

1. The Directory Structure 2. Starting an UNIX terminal3. Listing files and directories4. Making Directories5. Changing to a different Directory6. Pathnames7. More about home directories and pathnames8. Copying Files9. Moving Files10. Removing Files and directories11. Displaying the contents of a file on the screen12. Searching the contents of a file16. Appending to the file17. Concatenate the file18. Pipes19. Wildcards20. Changing access rights21. Processes and Jobs22. Killing a process23. Compare the content of file24. Access Rights25. History of Commands26. Filtering the content of file27. Basic Calculator28. Word Count29. System Date and time30. Mathematical Command expr31. Display the code using echo32.VI Editor33.Unix Programs34. PERL Programs35.More about LINUX

1.Directory Structure

2 Starting a Linux terminal

Unix Commands1. Listing files and directory a.%ls-List files and directory. b.ls-a-List all files and directory.2. Making Directorymkdir-make a directory.3.Changing to a different directorya. cd directory- change to named directory.b. Cd-change to home directory.c. cd~ -change to home directory.d. cd ..-change to parent directory.4.Pathnamespwd-display the path of current directory.

5.More about home directories and pathnamesa. %ls unixstuff-to list the contents of your unixstuff directory.b.ls backup-we get a message like thatbackups:No such file or directory.6.Copying filescp file1 file2-copy file1 and call it file27. Moving filesmv file1 file2-move and rename file1 to file28. Removing files and directoriesa.rm file-remove a fileb.rmdir directory- remove a directory

9. Displaying the contents of a file on the screena.cat file-display a file.b.less file-display the file a page at a time10. Searching the contents of a filegrep 'keyword' file- search a file for keywords

11.Appending to a filecat>>file -append the file

12. Concatenate the filescat file1 file2>file0-concatenate file1 and file2 to file0.13. pipesa. who-list users currently logged inb. sort-sort the content of file.c.who|sort- sort the list of users.d. who|wc-l -count the number of user.

14. wildcards* is called wildcard%ls list*-list all files starting with list....%ls *list- list all files ending with ....list

16. Changing access rights%chmod go-rwx biglist-remove read write and execute permission on the file biglist.17. Processes and Jobs%ps- display all running processes%sleep 10- wait 10 sec before returning the command prompt.18.Killing a processkill-terminate or signal a process.

19. Compare the content of two filethis command compare the contents of two files and display the differences.diff file1 file220. chmod21. history-show cammands history list% history

22. tail-display the last ten lines of a file%tail-5 file (display the last five line of file file)23. head- display the first ten lines of a file24. bc-basic calculator25. wc(count the no. of lines words and letter in file.)%wc -l(counts the no. of lines)%wc -w(count the number of words)

26. date- display the date and time of the system.

27. expr-mathematical command used to calculate algebraic expression.28. echo-used to print a line%echo "hello"29. vi editor%vi filename (this command open the file filename in vi editor if file is already created otherwise it creates the file and open it.)

Shell Script Program of Unix/Linux#Program to Display Hello World

#2 Program to add two numbers

#3 Program to check date,time,username and current directory of system

#4 Program to display the fibonacci series

#5 program to find the greatest number among three number

#6 program to find prime number

#7 Program for addition of two number using command line arguments

Perl Programs

#1 Program for implementation of loop

#2 Program to print the fibonacci series of n numbers

More About Linux/Unix#Difference between linux/unix Linux UnixWhat is it?Linux is an example of Open Source software development and Free Operating System (OS).Unix is an operating system that is very popular in universities, companies, big enterprises etc.

CostLinux can be freely distributed, downloaded freely. There are priced versions for Linux also, but cheaper than Windows.Different flavors of Unix have different cost structures according to vendors

UserEveryone. From home users to developers and computer enthusiasts alike.Unix operating systems were developed mainly for mainframes, servers and workstations except OSX, Which is designed for everyone.

ManufacturerLinux kernel is developed by the community. Linus Torvalds oversees things.Three bigest distributions are Solaris (Oracle), AIX (IBM) & HP-UX Hewlett Packard. And Apple Makes OSX, an unix based os..

UsageLinux can be installed on a wide variety of computer hardware, ranging from mobile phones, tablet computers andvideo game consoles, to mainframes and supercomputers.The UNIX operating system is used in internet servers, workstations & PCs. Backbone of the majority of finance infastructure and many 24x365 high availability solutions.

GUILinux typically provides two GUIs, KDE and Gnome. But there are millions of alternatives such as LXDE, Xfce, Unity, Mate, twm, ect.Initially Unix was a command based OS, but later a GUI was created called Common Desktop Environment. Most distributions now ship with Gnome.

File system supportExt2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs, FAT, FAT32, NTFSjfs, gpfs, hfs, hfs+, ufs, xfs, zfs format

Text mode interfaceBASH (Bourne Again SHell) is the Linux default shell. It can support multiple command interpreters.Originally the Bourne Shell. Now it's compatible with many others including BASH, Korn & C.

SecurityLinux has had about 60-100 viruses listed till date. None of them actively spreading nowadays.A rough estimate of UNIX viruses is between 85 -120 viruses reported till date.

Threat detection and solutionIn case of Linux, threat detection and solution is very fast, as Linux is mainly community driven and whenever any Linux user posts any kind of threat, several developers start working on it from different parts of the worldBecause of the proprietary nature of the original Unix, users have to wait for a while, to get the proper bug fixing patch. But these are not as common.

ProcessorsDozens of different kinds.x86/x64, Sparc, Power, Itanium, PA-RISC, PowerPC and many others.

ExamplesUbuntu, Fedora, Red Hat, Debian, Archlinux, Android etc.OS X, Solaris, All Linux

ArchitecturesOriginally developed for Intel's x86 hardware, ports available for over two dozen CPU types including ARMis available on PA-RISC and Itanium machines. Solaris also available for x86/x64 based systems.OSX is PowerPC(10.0-10.5)/x86(10.4)/x64(10.5-10.8)

InceptionInspired by MINIX (a Unix-like system) and eventually after adding many features of GUI, Drivers etc, Linus Torvalds developed the framework of the OS that became LINUX in 1992. The LINUX kernel was released on 17th September, 1991In 1969, it was developed by a group of AT&T employees at Bell Labs and Dennis Ritchie. It was written in C language and was designed to be a portable, multi-tasking and multi-user system in a time-sharing configuration.

#Features of Linux/UnixFollowing are some of the important features of Linux Operating System. Portable- Portability means software can works on different types of hardware in same way Linux kernel and application programs supports their installation on any kind of hardware platform. Open Source- Linux source code is freely available and it is community based development project. Multiple teams works in collaboration to enhance the capability of Linux operating system and it is continuously evolving. Multi-User- Linux is a multiuser system means multiple users can access system resources like memory/ ram/ application programs at same time. Multiprogramming- Linux is a multiprogramming system means multiple applications can run at same time. Hierarchical File System- Linux provides a standard file structure in which system files/ user files are arranged. Shell- Linux provides a special interpreter program which can be used to execute commands of the operating system. It can be used to do various types of operations, call application programs etc. Security- Linux provides user security using authentication features like password protection/ controlled access to specific files/ encryption of data.

#Linux System Architecture

Architecture

Linux System Architecture is consists of following layers:- Hardware layer- Hardware consists of all peripheral devices (RAM/ HDD/ CPU etc). Kernel- Core component of Operating System, interacts directly with hardware, provides low level services to upper layer components. Shell- An interface to kernel, hiding complexity of kernel's functions from users. Takes commands from user and executes kernel's functions. Utilities- Utility programs giving user most of the functionalities of an operating systems.

CS 4th Sem 2nd YearPage 26