KEMBAR78
03-Unix Operating System | PDF | Filename | Computer File
0% found this document useful (0 votes)
14 views31 pages

03-Unix Operating System

The document provides an overview of the Unix Operating System, detailing its components, including the kernel, shell, and programs, as well as its multi-user and multi-process capabilities. It explains the directory structure, essential commands for file and process management, and the differences between normal and super users. Additionally, it covers command syntax, various basic commands, and their functionalities within the Unix environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views31 pages

03-Unix Operating System

The document provides an overview of the Unix Operating System, detailing its components, including the kernel, shell, and programs, as well as its multi-user and multi-process capabilities. It explains the directory structure, essential commands for file and process management, and the differences between normal and super users. Additionally, it covers command syntax, various basic commands, and their functionalities within the Unix environment.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 31

Unix OS

SADDAM HUSSAIN
The Unix Operating
System

User
Input
 Unix OS is made of three parts
 The Kernel – manages the hardwares
Shell
 The Shell – Interface between User and kernel
 The programs – bunch of codes Kerne
 Multi user & Multi process l
Files and Processes

 Everything in UNIX is either file or process


 Process is an running program identified by a unique id ( PID )
 PID is a unique number that identifies each of the running processes in an operating system

 Files – is collection of data. They are created by users using text


editors, running compilers.
 A documents (word, text, essay)
 Programs that written with high level languages
 A directory – containing its information
Directory Structure

 Files are puts in directory


 Directories are in a hierarchical structure ( tree structure )
 User can put and remove directories on the tree
 Top directory is ‘ / ’ called slash or root
 Every user have the own directory ( Home directory )
Directory Structure
/

bin home lib etc dev usr proc root var tmp

User User X11R


Local bin
1 2 6

bin
Directory Structure

 /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, database files, cache files.

 /etc
 Various system configuration files are stored here
Directory Structure

 /dev
 This contains various devices as files -> disk, CD-R, Drive, etc

 /sbin
 Binaries which are only expected to be used by the super user

 /tmp
 This contains temporary files
Normal User & Super User

 In Unix system there is one special user for administration, which can do
anything.
 This special user is called root or super user
 Normal user also can do operations but not as root
Case Sensitivity

 Unix is case-sensitive
 INDEX.php, Index.php, Index.php are different files.
Commands

 How to run commands


 Finder => Application => Utilities => Terminal
 When you log in to Unix machine you will see your name
 [shahir]$
 One command consists of three parts
 Command name
 Options
 arguments [user]$ Command-name Option1 Option2 Arg1 Arg2
Commands

 Between command name, option and arguments, space is necessary


[user]$ Command-name Option1 Option2 Arg1 Arg2

Space Space Space Space Space

 Options always starts with “ - ”


 Example
 ls –l
Basic Commands  man, help, info – display online manual
 ls - show files in current position
 pwd – show current position
 cd – change directory
 mkdir – create directory
 rmdir – remove directory
 cp – copy file or a directory
 rm – remove file or a directory
 mv – move file or directory
 less, more, cat – display file contents
Basic Commands  adduser – create new user with all info
 useradd – create user
 passwd – change password
 userdel – delete user account
 su – switch user
 mount – mount file system
 unmount – unmount file system
 df – show disk space usage
 history – shows the command history
 shutdown – reboot or turn off machine
man command

 On Linux and other Unix-like operating systems, man is the interface used to view
the system's reference manuals.
 man is the system's manual viewer
 man has capability to get the manuals from online sites
ls command

 ls command is linux shell command that list directory contents or files


 Syntax
 Command – option – directory
 Options
 -a – shows the hidden files also
 -l – shows the all the details of listed documents
 -d */ - list all the directories
 -ls – list the documents and sort it by the size
Relative & Absolute path

 A path is a unique location to a file or a folder in a file system of an OS.


 Path means a position in the directory tree.
 To express a path, you can use relative path or absolute path.
Absolute path

 An absolute path is defined as specifying the location of a file or directory from


the root directory(/). In other words, we can say that an absolute path is a
complete path from start of actual file system from / directory.
 Address from root to text.txt file
 /home/Desktop/Files/text.txt
 Similar to
 Solar System/Earth/Asia/Afghanistan/Balkh/Amiri Town/Aria University
Relative path

 Relative path is defined as the path related to the present working directly(pwd). It
starts at your current directory and never starts with a / .
 Relative to your current location
 .: your current location
 ..: one directory above your current location
 Example
 ls ./linux – lists all the contents of the linux dir
 ls ../../ - lists everything that is two dir higher
 Similar to
 Out of the class / go straight / turn left / go
pwd command

 pwd stands for Print Working Directory.


 It prints the path of the working directory, starting from the root.
 pwd is shell built-in command(pwd) or an actual binary(/bin/pwd)
cd command

 In Linux ‘cd‘ (Change Directory) command is one of the most important and most
widely used command for newbies as well as system administrators.
 ‘cd‘ is the only way to navigate to a directory to check log, execute a
program/application/script and for every other task.
 cd syntax
 cd [option] [directory]
 Example
 Move to users home directory from anywhere. -> Shahir@Ubuntu:/usr/locals$ cd ~
mkdir command

 mkdir command in Linux allows user to create directories.


 Mkdir stands for ( make directory ).
 This command can create multiple directories at once as well as set the permission for
the directories.
 User must have enough permission to create directory.
 Syntax
 mkdir [option] [directory-name]
rmdir command

 The rmdir command removes each directory specified on the command line, if they
are empty.
 This command stands for ( remove directory )
 rmdir is functionally equivalent to the command rm -d.
 Syntax
 rmdir [option] [directory-name]
 Example
 rmdir dir_1 dir_2 dir_3
cp command

 cp is a Linux shell command to copy files and directories. It stands for ( copy )
 Syntax
 cp [option] [source] [destination]
 Example
 cp file_1.txt file_2.txt /home/student/Desktop
 cp *.ext dir_1 – copy all ext files in dir_1
 cp –f file_1.txt dir_1 – force to copy a file or directory
 cp –i file_1.txt /home/student/Desktop – interactive prompt before file overwrite
 cp –u * dir_1 – update all the files of dir_1 from our current directory
rm command

 rm command is used to remove objects such as files, directories, symbolic links and so
on from the file system like UNIX.
 rm stands for ( remove ), by default it does not remove directories.
 This command normally works silently and you should be very careful while
running rm command because once you delete the files then you are not able to
recover the contents of files and directories.
 Syntax
 rm [option] [file-name]
rm command

 Example
 rm –i text.txt – ‘-I’ option in rm command will prompt before deleting a file
 rm –d dir_1 – ‘-d’ option in rm command to delete a empty directory
 rm –r dir_1/ – ‘-r’ option will delete all the files and sub-directories recursively of the parent dir
 rm –ri dir_1/ - ‘-ri’ option will delete the files and sub-directories interactively.
 rm –f dir_1 – ‘-f’ option will remove or delete the files forcefully regardless of its permissions
and will also ignore non-existing files.
mv command

 Just like cp for copying and rm for deleting, Linux also offers an in-built command for
moving and renaming files.
 mv stands for move. mv is used to move one or more files or directories from one
place to another in file system like UNIX. It has two distinct functions:
 It rename a file or folder
 It moves group of files to different directory
 This command normally works silently means no prompt for confirmation.
 Syntax
 mv [option] [source] [destination]
mv command

 Example ( Rename )
 mv [filename] [new-filename]
 mv old_name.txt new_name.txt
 mv –i old_name.txt new_name.txt – ‘-i’ prompt before overwriting
 mv –n old_name.txt new_name.txt – ‘-n’ command will prevent from overwriting
 Example ( Move )
 mv file-name.txt /home/student/Desktop/log/
 all option will have same functionality to each of method
cat command

 The cat command (short for “concatenate “) is one of the most frequently used
command in Linux/Unix.
 cat command allows us to view contain of file, concatenate files and redirect output in
terminal or files.
 Also you can use ‘cat’ command for quickly creating a file.
 Syntax
 cat [file-name] [file-name-2] or cat > [file-name]
 cat [option] [file-name]
 Example => cat –n file-name.txt – ‘-n’ option shows line with numbers
more command

 As 'cat' command displays the file content. Same way 'more' command also displays
the content of a file. Syntax are the same.
 difference is that, in case of larger files, 'cat' command output will scroll off your
screen while 'more' command displays output one screenfull at a time.
 Following keys are used in ‘more’ command
 Enter key: To scroll down page line by line.
 Space bar: To go to next page.
 b key: To go to the backward page.
 / key: Lets you search the string.
less command

 “less” command is used to view files instead of opening the file. This post describes
“less” command used in Linux along with usage.
 Syntax
 less [option] [file-name]
 Less is a program similar to more but which allows backward movement in the file as
well as forward movement.
 Example
 less log.txt
su command

 The su command, which is short for substitute user or switch user, enables the current
user to act as another user during the current login session.
 It stands for Switch User
 Syntax
 su [option] [username]
 If no username is specified, su defaults to becoming the superuser (root).

You might also like