Docsity

Linux Exercises with solved examples, Essays (university) of Operating Systems

Partial preview of the text

Download Linux Exercises with solved examples and more Essays (university) Operating Systems in PDF only on Docsity!

Linux

[email protected] CSEA Silicon

What is Linux?

„^

Linux is a free open-source operating system based on Unix.

„^

Linux was originally created by a young student LinusTorvalds, at the University of Helsinki in Finland with theassistance of developers from around the globe.

„^

So Linux is called the product of internet.

GNU's Not Unix! - Free Software,Free Society^ „^

The GNU Project was launched in 1984 to developa complete UNIX-like operating system which isfree software

„^

GNU is a recursive acronym for “GNU's Not UNIX”;

Linux Distributions „ The kernel, at the heart of all Linux systems, isdeveloped and released under the GNU GeneralPublic License and its source code is freely availableto everyone. It is this kernel that forms the basearound which a Linux operating system is developed. „ There are now literally hundreds of companies andorganizations and an equal number of individualsthat have released their own versions of operatingsystems based on the Linux kernel which are calleddistributions.

Linux File System

„^

It is the data structure that usually resides on part of adisk.

„^

It is organised within a hierarchy of directories. Eachdirectory can further contain files as well as directories.

„^

Originally files on a Linux system were not located instandard places. Which lead to difficulty in maintain anddocument a linux system.

„^

The first version of the first standard for Linux filesystem,the FSSTND(Linux Filesystem Standard), was releasedin Feb 1994.

„^

In early 1995 work was started on a broader standardcovering many UNIX-like systems: FHS(LinuxFilesystem Hierarchy Standard)

Directory Structure bin boot

var^

usr

etc tmp

home

cs

sbin bin

spool mail

root

dev

cs

cs

Directory and their contains

/var

Mostly the file(s) stored in this directory changes their size i.e.variable data files. Data files including spool directories and files,administrative and logging data, and transient and temporary filesetc.

/usr

Central location for all your application program, x-windows, manpages, documents etc are here. Programs meant to be used andshared by all of the users on the system. Mostly you need to exportthis directory using NFS in read-only mode. Some of the importantsub-directories are as follows: bin

  • sub-directory contains executables sbin
    • sub-directory contains files for system administration i.e. binaries include - sub-contains C header files share - sub-contains contains files that aren't architecture-specific like documents, wallpaper etc. X11R - sub-contains X Window System

Directory and their contains

/lib^

All shared library files are stored here. This libraries are needed toexecute the executable files (binary) files in /bin or /sbin.

/tmp

Temporary file location

/dev

Special Device files are store here. For e.g. Keyboard, mouse,console, hard-disk, cdrom etc device files are here.

/mnt

Floppy disk, CD-Rom disk, Other MS-DOS/Windows partitionmounted in this location (mount points) i.e. temporarily mounted filesystems are here.

/boot

Linux Kernel directory

/opt

Use to store large software applications like star office.

Linux Command

„^

Linux command line „^

A command prompt looks like^ [cs04124@linuxserver cpp]$ •^

cs04124 : user name

-^

linuxserver : machine name

-^

cpp: current working directory

„^

A command is an instruction to perform a task in operating system

„^

General syntax of a command command

[arg1] [arg2] … [argn] RETURN

„^

Linux is cAsE sensitive. (Both commands and filenames)

„^

To repeat a command up-down arrow keys may be used

Linux Command

„^

Arguments „^

On the command line each sequence of nonblank charactersis called a token or word.

„^

An argument is a token, such as a filename, string of text,number or other object that a command acts on.

„^

e.g. vim test.c ( vim is the command ; test.c is the argument)

„^

Options „^

An option is an argument that modifies the effects of acommand.

„^

We can frequently specify more than one option.

„^

By convention options are separate arguments that follows thename of the command.

„^

Most utilities require to prefix options with a hyphen( - ).However, this requirement is specific to the utility and not tothe shell.

date, cal

date Change or set current date and time. Syntax date

[date or time string ] Examples $date

will show current date & time

$date

--date=“2001-3-15“

will set date to 2001-Mar-

$date

--date=“2001-3-15 11:59 AM”

date as well as time

cal Displays the calendar of current month and year. Syntax cal^

[month number] [ year ] Examples $cal

will show current month and year calendar

$cal

will show calendar of jan 2007

w, who, finger

w Shows who logged on and what they are doing Syntax w Who [ am i ] Information about all the logged in users (your self). Syntax who [ am i ] finger Get user information. Syntax finger

[user-name]

Examples $finger $finger cs

ls

ls Shows list of files and dirs Syntax ls^

[file or dir name] Options -R^

Recursively display the files & directory. -l^

Long listing of files & directory. -a^

Show all files start with. (DOT) # for e.g.:

.bash_profile

-N^

Name wise sorting. Examples $ ls $ ls -lR $ ls –a The output of ls –l (long listing)

-rw-r--r--

1 cs04123 cs04123 2474 Oct

1 17:25 maze.cpp

drwxrwxr-x

4 cs04123 cs04123 4096 Oct 25 11:19 linux

cat, touch, vi

cat To display text file. Syntax cat

Examples $cat

foo **cat > ** To create a file. Syntax cat

> Examples $cat

> silicon Silicon Institute of Technology ^d ( Ctrl + d EOF)

touch To create multiple files. Syntax touch

Examples $touch

a.c b.c d.c vi To create and modify files. Syntax vi^

Examples $vi a.c b.c d.c