[go: up one dir, main page]

0% found this document useful (0 votes)
4 views29 pages

Linux Intro

Uploaded by

abinshaji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views29 pages

Linux Intro

Uploaded by

abinshaji
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 29

Tutorial of Unix/Linux

ABIN SHAJI THOMAS


CIRA- VICE PRESIDENT
Outline
1. Overview of Unix System
2. Basic Commands
3. Relative & Absolute Path
4. Redirect, Append and Pipe
5. Permission
6. Process Management
7. Install Software
8. Text Editor
9. Foreground and Background Jobs
Overview of Unix System
Kernel & Shell
 Unix/Linux is operating system (OS).
 Unix system is described as kernel & shell.

 Kernel is a main program of Unix system. User


it controls hard wares, CPU, memory, hard
disk, network card etc. input

 Shell is an interface between user and Shell


kernel. Shell interprets your input as
commands and pass them to kernel.
Kernel
Unix Overview (cont.)
Multi-user & Multi-process
 Many people can use one machine at the same time.

File & Process


 Data, directory, process, hard disk etc (almost everything)
are expressed as a file.
 Process is an running program identified by a unique id
(PID).
Unix Overview (cont.)
Directory Structure
 Files are put in a directory.
 All directories are in a hierarchical structure (tree
structure).
 User can put and remove any directories on the tree.
 Top directory is “/”, which is called slash or root.
 Users have the own directory. (home directory)
Unix Overview (cont.)
Directory Structure
Unix Overview (cont.)
Important Directories
 /bin This contains files that are essential for correct
operation of the system. These are available for use by all
users.

 /home This is where user home directories are stored.

 /var This directory is used to store files which change


frequently, and must be available to be written to.

 /etc Various system configuration files are stored here.


Unix Overview (cont.)
Important Directories
 /dev This contains various devices as files, e.g. hard
disk, CD-ROM drive, etc.

 /sbin Binaries which are only expected to be used by


the super user.

 /tmp Temporary files.


Basic Commands
Commands
 ls show files in current position
 cd change directory
 cp copy file or directory
 mv move file or directory
 rm remove file or directory
 pwd show current position
 mkdir create directory
 rmdir remove directory
 less, more, cat display file contents
 man display online manual
Basic Commands
Commands
 su switch user
 passwd change password
 useradd create new user account
 userdel delete user account
 mount mount file system
 umount unmount file system
 df show disk space usage
 shutdown reboot or turn off machine
Basic Commands

1. Type following command in 3. In your home directory,


your directory. ls .bash_profile
cp .bash_profile sample.txt
ls
less sample.txt (note: to quit less, press “q”)
ls –a
rm sample.txt
ls –la
ls -Fa
2. Make a directory 4. check disk space usage
df
mkdir linux
df -h
pwd
cd linux
pwd
cd
pwd
rmdir linux
Relative & Absolute Path
 Path means a position in the directory tree.
 To express a path, you can use relative path or
absolute path.
 In relative path expression, the path is not defined
uniquely, depends on your current path.
 In absolute path expression, the path is defined
uniquely, does not depend on your current path.
Absolute Path
 Address from the root
/home/linux/
~/linux
~: ~: Alt+N

 Similar to:
Lausanne University/Lausanne/Canton de Vaud/
Switzerland/Europe/Earth/Solar System/
Relative Path
 Relative to your current location
. : your current location
.. : one directory above your current location
pwd: gives you your current location

 Example
ls ./linux : lists the content of the dir linux
ls ../../ : lists everything that is two dir higer

 Similar to:
Go Left/turn right/take the TSOL/go
Relative & Absolute Path
 Ablsoute Path
 Relative Path
cd
pwd mkdir mydir
pwd
cd . cd /Users/invite
pwd pwd
cd /Users
cd .. pwd
pwd cd /
pwd
cd .. cd /Users/invite
pwd cd ~/mydir

cd
Redirect, Append and Pipe
Redirect and append
 Output of command is displayed on screen.
 Using “>”, you can redirect the output from screen to a file.
 Using “>>” you can append the output to the bottom of the file.

Pipe
 Some commands require input from a file or other commands.
 Using “|”, you can use output from other command as input to the command.
 On MacOSX, The Pipe sign: (Shift+Alt+N: franc, Alt+7)
Redirect, Append and Pipe
Commands
 head show first several lines and omit other lines.

 tail show last several lines and omit other


lines.

 grep XXX File show lines matching pattern XXX in File


Redirect, Append and Pipe
 In home directory, type  Use pipe.
ls -1 > sample.txt less redirect.txt
less sample.txt grep Desk redirect.txt
 Use redirect. grep –n Desk redirect.txt
head -3 sample.txt man grep
tail redirect.txt | grep Desk
head -3 sample.txt > redirect.txt
rm sample.txt
 Use append.
rm redirect.txt
tail -3 sample.txt
tail -3 sample.txt >> redirect.txt
less redirect.txt
Sorting
Commands
 sort Sorts using the first field of each line.

 -n Sorts considering the numeric value of the


strings
 -k3 Sorts using the third field of each line
 -rnk3 Sorts in reverse order, using the numeric
value of the third field
Permission
 All of files and directories have owner and permission.
 There are three types of permission, readable, writeable and
executable.
 Permissions are given to three kinds of group. owner, group
member and others.

Example:
ls -l .bash_profile
-rw-r--r-- 1 cnotred cnotred 191 Jan 4 13:11 .bash_profile

 r:readable, w:writable, x: executable


Permission
Command
 chmod change file mode, add or remove
permission
 chown change owner of the file

Example)
chmod a+w filename
add writable permission to all users
chmod o-x filename
remove executable permission from others
chmod a+x
Gives permission to the usser to execute a file

 u: user (owner), g: group, o: others


a: all
Permission
 Check permission
ls –l .bash_profile
cp .bash_profile sample.txt
ls –l sample.txt

 Remove readable permission from all.


chmod a-r sample.txt
ls –l sample.txt
less sample.txt

 Add readable & writable premissions to file owner.


chmod u+rw sample.txt
ls –l sample.txt
less sample.txt
rm sample.txt
Process Management
 Process is a unit of running program.

 Each process has some information, like process ID, owner,


priority, etc.

Example) Output of “top” command


Process Management
Commands
 kill Stop a program. The program is
specified by process ID.
 killall Stop a program. The program is
specified by command name.
 ps Show process status
 top Show system usage statistics
Process Management

 Check your process.


ps
ps –u

 Check process of all


users.
top (To quit top, press
“q”)
ps –e
ps –ef

 Find your process.

ps –ef | grep cnotred


Install Software
 Unix system has a “de facto standard” way to install a
software.
configure, make & make install

 Typical software installation procedure as following.


1. Download source code. Usually, it’s archived with tar
command and compressed with gzip command.
2. configure command creates Makefile automatically
which is used to compile the source.
3. Program compilation is written in Makefile.
Install Software
Commands
 gzip compress a file
 gunzip uncompress a file
 tar archive or expand files
 configure create Makefile
 make compile & install software
Install Software
Example: parallel programming library installation

gunzip software.tar.gz
tar –xvf software.tar
cd software
./install OR make all OR …
Tutorial of Unix/Linux

END

You might also like