SlideShare a Scribd company logo
1 of 32
Unix Basics



    Prepared by
         Dima Gomaa
What Is an Operating System?

•   Interface between Users and the Hardware
•   Take care of Storage Management
•   Take care of I/O device management
History of the UNIX Operating System
 1969        AT&T Bell Labs UNICS system -designed by Ken
             Thompson & Dennis Ritchie

 1970        UNICS finally became UNIX
 1973        UNIX rewritten in C, making it portable to different hardware

 Mid 1970s   University of California at Berkeley (BSD) contributed many
             important features like vi, C shell etc.

 1982        AT & T came back and started commercial production-
             Editions ->Systems

 Late 1980s AT & T released SVR4 unification of SV3.2,BSD,SunOs &
            XENIX

 1991        Linux from Linus Torvalds

 1990s       POSIX Standard, MIT introduced X-Windows

                                                                             3
UNIX Architecture – Kernel & Shell




User   Shell     Kernel    Hardware




                                      4
More Features of UNIX


•   Hierarchical file system
•   Multi tasking
•   Multi user
•   Pattern matching (wildcard characters)
•   Programming facility
•   Documentation




                                             5
Command Line Format

Syntax:

 $ command [-options] [arguments]

1. Separation

2. Order

3. Multiple options

4. Multiple arguments


                                    6
Basic Commands(1)
   ls             list files and directories
   ls -a          list all files and directories
   mkdir          make a directory
   cd directory   change to named directory
   cd             change to home-directory
   cd ~           change to home-directory
   cd ..          change to parent directory
   pwd            display current dir path
   useradd        add new user in the system
   usermod        modify user
   userdel        delete user
   groupadd       add new group in the system
Basic Commands(2)

   cp file1 file2         copy file1 and call it file2
   mv file1 file2         move or rename file1 to file2
   rm file                remove a file
   rmdir directory        remove a directory
   cat file               display a file
   more file              display a file a page at a time
   who                    list users currently logged in
   lpr -Pprinter psfile   print postscript file to named printer
   *                      match any number of characters
   ?                      match one character
   man                    command read the online manual page for a
                           command
Basic Commands(3)
   command > file            redirect standard output to a file
   command >> file           append standard output to a file
   command < file            redirect standard input from a file
   grep 'keyword' file       search a file for keywords
       % grep science science.txt
   wc file                   count number of lines/words/characters in file
       % wc -w science.txt
   sort                      sort data (numerically or alphabetically)
       Ex:
       to sort the list of object, type
       % sort < biglist
       and the sorted list will be output to the screen.
The File System Hierarchy


                                 /




       usr          etc   home       dev    var   tmp




bin          sbin         dsk        rdsk   adm     sadm


  ls         who
                                                           10
File Path name
A sequence of file names, separated by slashes (/), that
describes the path, the system must follow to locate a
file in the file system


Absolute pathname (start from the /-directory):
       Eg: /export/home/user1/file1
Relative pathname (start from the current directory)
       ./test1 (. = current directory)
       ../team03/.profile (.. = parent directory)
                                                           11
File Characteristics

 $ ls -l
 -rw-r--r-- 1 user3 class 37   Jul 24 11:06 f1
 -rwxr-xr-x 1 user3 class 52   Jul 24 11:08 f2
 drwxr-xr-x 2 user3 class 1024 Jul 24 12:03 memo



File        Links           Group                      Name
Type                                       Timestamp
                    Owner           Size
  Permissions




                                                              12
Who can access a File?
The UNIX system incorporates a three-tier structure to define who
 has access to each file and directory:

   user The owner of the file
   group A group that may have access to the file
   other Everyone else
• The ls -l command displays the owner and group who has
  access to the file.
  $ ls -l
  -rw-r--r-- 1 user3 class 37 Jul 24 11:06 f1
  -rwxr-xr-x 1 user3 class 37 Jul 24 11:08 f2
  drwxr-xr-x 2 user3 class 1024 Jul 24 12:03 memo
                      | |
                   owner group
                                                                13
File system security (access rights)




        -rwxrwxrwx   a file that everyone can read, write and execute
                     (and delete).


        -rw-------   a file that only the owner can read and write - no-
                     one else can read or write and no-one has
                     execution rights (e.g. your mailbox file).
Unix File Permissions

   File type, owner, group, others
drwx------      2   jjoshi   isfac 512       Aug 20 2003 risk management
lrwxrwxrwx      1   jjoshi   isfac   15      Apr 7 09:11 risk_m->risk management
-rw-r--r--      1   jjoshi   isfac 1754      Mar 8 18:11 words05.ps
-r-sr-xr-x      1   root     bin   9176      Apr 6 2002 /usr/bin/rs
-r-sr-sr-x      1   root     sys   2196      Apr 6 2002 /usr/bin/passwd

   File type: regular -, directory d, symlink l, device b/c, socket s, fifo f/p
   Permission: r, w, x, s or S (set.id), t (sticky)
   chmod [options] file        change access rights for named file

      For example, to remove read write and execute permissions on the file
         biglist for the group and others, type

      % chmod go-rwx biglist

      This will leave the other permissions unaffected.

      To give read and write permissions on the file biglist to all,


      % chmod a+rw biglist
Default Permissions

The default protections for newly created files and directories
are:


       File           -rw-r—r--     644
       Directory      drwxr-xr-x    755


These default settings may be modified by changing the umask
value.

                                                                  17
umask - Permission Mask

Umask specifies what permission bits will be set on a new
file or directory when created.


New Directory:        777 – 022     755      rwxr-xr-x
New File      :       666 – 022     644     rw-r—r—


The default value of umask is set in /etc/profile. This can be
changed for all the users or a particular user

                                                                 18
chown - Change File Ownership

Syntax:
chown owner [:group] filename ...
                                                  Changes owner of a
                                                  file(s) and, optionally, the
Example:                                          group ID
 $ id
 uid=101 (user1), gid=101 (group1)
 $ cp f1 /tmp/user2/f1
 $ ls -l /tmp/user2/f1
 -rw-r----- 1 user1 group1 3967 Jan 24 13:13 f1
 $ chown user2 /tmp/user2/f1
 $ ls -l /tmp/user2/f1
 -rw-r----- 1 user2 class 3967 Jan 24 13:13 f1

Only the owner of a file (or root) can change the ownership of the file.
                                                                                 19
The chgrp Command
Syntax:
 chgrp newgroup filename ...

Example:
 $ id
 uid=303 (user3), gid=300 (class)
 $ ls -l f3
 -rw-r----- 1 user3 class 3967 Jan 24 13:13 f3
 $ chgrp class2 f3
 $ ls -l f3
 -rw-r----- 1 user3 class2 3967 Jan 24 13:13 f3
 $ chown user2 f3
 $ ls -l f3
 -rw-r----- 1 user2 class2 3967 Jan 24 13:13 f3   20
su - Switch User Id
Syntax:
 su [user_name]
               Change your effective user ID and group ID

Example:
 $ ls -l f1
 -rwxr-x--- 1 user1 group1 3967 Jan 24 23:13 class_setup
 $ id
 uid=303 (user1), gid=300 (group1)

 $ su – user2
 Password:
 $ id
 uid=400 (user2), gid=300 (group1)

                                                            21
Special File Permissions – setuid, setgid,
sticky bit
   setuid – changes the effective user id of the user to the owner of
    the program
     chmod u+s f1               or
     – chmod 4744 f1

   setgid – changes the effective group id of the user to the group
    of the program
     chmod g+s f1               or
     chmod 2744 f1



   sticky bit – ensures the deletion of files by only file owner in a
    public writable directory
     chmod +t f1                or
     Chmod 1744 f1

                                                                         22
What Is vi?

•   A screen-oriented text editor
•   Included with most UNIX system distributions
•   Command driven
•   Categories of commands include
     – General administration
     – Cursor movement
     – Insert text
     – Delete text
     – Paste text
     – Modify text




                                                   23
Starting and Ending a vi
                     Session
vi [filename] Start a vi edit session of file
Example:
$ vi testfile
- If the file doesn’t exist, it will be created
- Otherwise vi will open the existing file


All modifications are made to the copy of the file brought into
memory.
:wq or :x or <shift-zz>                write and quit
:w                                     write
:q                                     quit
:q!                                    Quit without saving
                                                                  24
Cursor Control Commands
                         1G
                        <ctrl-b>
                          H
                          k
                       <up-arrow>


         0                          $
      b,B                           w,W
        h                           l
<left-arrow>                        <right-arrow>




                     <down-arrow>
                          j
                          L
                       <ctrl-f>
                         G
                                                    25
Input Mode: i, a, O, o


i will insert character at the present cursor position
I will insert character at the beginning of the line
a will append character at the present cursor position
A will append character at the end of the line

o will insert a blank line below
O will insert a blank line above




                                                         26
Deleting Text: x, dw, dd, dG

x      deletes the current character
dw     deletes the current word
dd     deletes the current line
dG     delete all lines to end of file, including current line.
With any of these you can prefix a number
Example: 3dd will delete 3 lines
d$     to delete to the end of the line
d0     to delete to the start of the line


                                                                  27
Copying, moving and
               changing Text
yy   copy the line
yw   copy the word     p will paste the yanked lines below
dw   cut the word      P will paste the yanked lines above
dd   cut the line
r    will overwrite the current character
R    will replace all text on the right of the cursor position
cw   will replace only the current word


                                                                 28
Searching for Text: /, n, N

/director will locate for the first occurrence of the
pattern ‘director’


n to locate the next occurrence
N to locate the previous occurence




                                                        29
Monitoring Process


The ps command dislays process status information

$ ps -f

UID       PID   PPID   ...   TTY    ...   COMMAND
john      202   1      ...   tty0   ...   -ksh
john      204   202    ...   tty0   ...   ksh
john      210   204    ...   yyu0   ...   ls -R /
john      212   204    ...   tty0   ...   ps -f


                                                    30
Shell Scripting

   Shell scripting skills have many applications, including:
   Ability to automate tasks, such as
     Backups

     Administration tasks

     Periodic operations on a database via cron

     Any repetitive operations on files

   Increase your general knowledge of UNIX
     Use of environment

     Use of UNIX utilities

     Use of features such as pipes and I/O redirection
Examples of Shell Scripting
   Store the following in a file named simple.sh and execute it
      #!/bin/sh
      # Show some useful info at the start of the day
      date
      echo Good morning $USER
      cal
      last | head -6

   Shows current date, calendar, and a six of previous logins
   Notice that the commands themselves are not displayed, only
    the results

More Related Content

What's hot

A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unixzafarali1981
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Wave Digitech
 
Unix files
Unix filesUnix files
Unix filesSunil Rm
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating Systemsubhsikha
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & CommandsMohit Belwal
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumarymentorsnet
 
Unix
UnixUnix
UnixErm78
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)anandvaidya
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure amol_chavan
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1Lilesh Pathe
 
A Quick Introduction to Linux
A Quick Introduction to LinuxA Quick Introduction to Linux
A Quick Introduction to LinuxTusharadri Sarkar
 
Linux Administration
Linux AdministrationLinux Administration
Linux AdministrationHarish1983
 
Unix files
Unix filesUnix files
Unix filesSunil Rm
 
Linux presentation
Linux presentationLinux presentation
Linux presentationNikhil Jain
 

What's hot (20)

A beginners introduction to unix
A beginners introduction to unixA beginners introduction to unix
A beginners introduction to unix
 
Linux: Basics OF Linux
Linux: Basics OF LinuxLinux: Basics OF Linux
Linux: Basics OF Linux
 
Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013Unix Linux Commands Presentation 2013
Unix Linux Commands Presentation 2013
 
Unix files
Unix filesUnix files
Unix files
 
Unix Operating System
Unix Operating SystemUnix Operating System
Unix Operating System
 
Unix OS & Commands
Unix OS & CommandsUnix OS & Commands
Unix OS & Commands
 
Linux Command Suumary
Linux Command SuumaryLinux Command Suumary
Linux Command Suumary
 
Unix
UnixUnix
Unix
 
Linux lecture6
Linux lecture6Linux lecture6
Linux lecture6
 
Linux Introduction (Commands)
Linux Introduction (Commands)Linux Introduction (Commands)
Linux Introduction (Commands)
 
Unix operating system architecture with file structure
Unix operating system architecture with file structure Unix operating system architecture with file structure
Unix operating system architecture with file structure
 
Linux basics part 1
Linux basics part 1Linux basics part 1
Linux basics part 1
 
Linux commands
Linux commandsLinux commands
Linux commands
 
A Quick Introduction to Linux
A Quick Introduction to LinuxA Quick Introduction to Linux
A Quick Introduction to Linux
 
Linux Commands
Linux CommandsLinux Commands
Linux Commands
 
Linux Administration
Linux AdministrationLinux Administration
Linux Administration
 
Unix files
Unix filesUnix files
Unix files
 
Linux presentation
Linux presentationLinux presentation
Linux presentation
 
Linux
Linux Linux
Linux
 
Basics of Linux
Basics of LinuxBasics of Linux
Basics of Linux
 

Viewers also liked

The Data Journalism Handbook (poster)
The Data Journalism Handbook (poster)The Data Journalism Handbook (poster)
The Data Journalism Handbook (poster)Liliana Bounegru
 
DMI Workshop: Data visualization. Analytical clouding.
DMI Workshop: Data visualization. Analytical clouding.DMI Workshop: Data visualization. Analytical clouding.
DMI Workshop: Data visualization. Analytical clouding.Digital Methods Initiative
 
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...Liliana Bounegru
 
Solved problem binomial probability distribution
Solved problem binomial probability distributionSolved problem binomial probability distribution
Solved problem binomial probability distributionEdgar Mata
 
California love tupac
California love   tupacCalifornia love   tupac
California love tupacPedsldn
 
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...Siete herramientas basicas y siete nuevas herrramientas de administracion de ...
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...Anna Escamilla
 
Ppt for solar fencing
Ppt for solar fencingPpt for solar fencing
Ppt for solar fencingnarayanamsai
 
Ra solar power generators presentation
Ra solar power generators presentationRa solar power generators presentation
Ra solar power generators presentationKATU ISAAC
 

Viewers also liked (10)

my resume
my resumemy resume
my resume
 
DMI Workshop: Crawling and Scraping
DMI Workshop: Crawling and Scraping DMI Workshop: Crawling and Scraping
DMI Workshop: Crawling and Scraping
 
The Data Journalism Handbook (poster)
The Data Journalism Handbook (poster)The Data Journalism Handbook (poster)
The Data Journalism Handbook (poster)
 
DMI Workshop: Data visualization. Analytical clouding.
DMI Workshop: Data visualization. Analytical clouding.DMI Workshop: Data visualization. Analytical clouding.
DMI Workshop: Data visualization. Analytical clouding.
 
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...
Data Infrastructure Literacy: Reshaping Practices of Measurement, Monitoring ...
 
Solved problem binomial probability distribution
Solved problem binomial probability distributionSolved problem binomial probability distribution
Solved problem binomial probability distribution
 
California love tupac
California love   tupacCalifornia love   tupac
California love tupac
 
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...Siete herramientas basicas y siete nuevas herrramientas de administracion de ...
Siete herramientas basicas y siete nuevas herrramientas de administracion de ...
 
Ppt for solar fencing
Ppt for solar fencingPpt for solar fencing
Ppt for solar fencing
 
Ra solar power generators presentation
Ra solar power generators presentationRa solar power generators presentation
Ra solar power generators presentation
 

Similar to Unix fundamentals

Similar to Unix fundamentals (20)

Linux ppt
Linux pptLinux ppt
Linux ppt
 
Basic Linux
Basic LinuxBasic Linux
Basic Linux
 
Lession1 Linux Preview
Lession1 Linux PreviewLession1 Linux Preview
Lession1 Linux Preview
 
8.1.intro unix
8.1.intro unix8.1.intro unix
8.1.intro unix
 
Linux Shell Basics
Linux Shell BasicsLinux Shell Basics
Linux Shell Basics
 
Unix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptxUnix Shell Script - 2 Days Session.pptx
Unix Shell Script - 2 Days Session.pptx
 
An Introduction to Linux
An Introduction to LinuxAn Introduction to Linux
An Introduction to Linux
 
Linux basic commands
Linux basic commandsLinux basic commands
Linux basic commands
 
Linux ppt
Linux pptLinux ppt
Linux ppt
 
Unix Basics Commands
Unix Basics CommandsUnix Basics Commands
Unix Basics Commands
 
Rhel1
Rhel1Rhel1
Rhel1
 
basic-unix.pdf
basic-unix.pdfbasic-unix.pdf
basic-unix.pdf
 
Bootcamp linux commands
Bootcamp linux commandsBootcamp linux commands
Bootcamp linux commands
 
Linux file system nevigation
Linux file system nevigationLinux file system nevigation
Linux file system nevigation
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
Linux commands and file structure
Linux commands and file structureLinux commands and file structure
Linux commands and file structure
 
UNIX.pptx
UNIX.pptxUNIX.pptx
UNIX.pptx
 
linux-lecture4.ppt
linux-lecture4.pptlinux-lecture4.ppt
linux-lecture4.ppt
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
04-1-Linux.ppt
04-1-Linux.ppt04-1-Linux.ppt
04-1-Linux.ppt
 

Recently uploaded

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Recently uploaded (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Unix fundamentals

  • 1. Unix Basics Prepared by Dima Gomaa
  • 2. What Is an Operating System? • Interface between Users and the Hardware • Take care of Storage Management • Take care of I/O device management
  • 3. History of the UNIX Operating System 1969 AT&T Bell Labs UNICS system -designed by Ken Thompson & Dennis Ritchie 1970 UNICS finally became UNIX 1973 UNIX rewritten in C, making it portable to different hardware Mid 1970s University of California at Berkeley (BSD) contributed many important features like vi, C shell etc. 1982 AT & T came back and started commercial production- Editions ->Systems Late 1980s AT & T released SVR4 unification of SV3.2,BSD,SunOs & XENIX 1991 Linux from Linus Torvalds 1990s POSIX Standard, MIT introduced X-Windows 3
  • 4. UNIX Architecture – Kernel & Shell User Shell Kernel Hardware 4
  • 5. More Features of UNIX • Hierarchical file system • Multi tasking • Multi user • Pattern matching (wildcard characters) • Programming facility • Documentation 5
  • 6. Command Line Format Syntax: $ command [-options] [arguments] 1. Separation 2. Order 3. Multiple options 4. Multiple arguments 6
  • 7. Basic Commands(1)  ls list files and directories  ls -a list all files and directories  mkdir make a directory  cd directory change to named directory  cd change to home-directory  cd ~ change to home-directory  cd .. change to parent directory  pwd display current dir path  useradd add new user in the system  usermod modify user  userdel delete user  groupadd add new group in the system
  • 8. Basic Commands(2)  cp file1 file2 copy file1 and call it file2  mv file1 file2 move or rename file1 to file2  rm file remove a file  rmdir directory remove a directory  cat file display a file  more file display a file a page at a time  who list users currently logged in  lpr -Pprinter psfile print postscript file to named printer  * match any number of characters  ? match one character  man command read the online manual page for a command
  • 9. Basic Commands(3)  command > file redirect standard output to a file  command >> file append standard output to a file  command < file redirect standard input from a file  grep 'keyword' file search a file for keywords % grep science science.txt  wc file count number of lines/words/characters in file % wc -w science.txt  sort sort data (numerically or alphabetically) Ex: to sort the list of object, type % sort < biglist and the sorted list will be output to the screen.
  • 10. The File System Hierarchy / usr etc home dev var tmp bin sbin dsk rdsk adm sadm ls who 10
  • 11. File Path name A sequence of file names, separated by slashes (/), that describes the path, the system must follow to locate a file in the file system Absolute pathname (start from the /-directory): Eg: /export/home/user1/file1 Relative pathname (start from the current directory) ./test1 (. = current directory) ../team03/.profile (.. = parent directory) 11
  • 12. File Characteristics $ ls -l -rw-r--r-- 1 user3 class 37 Jul 24 11:06 f1 -rwxr-xr-x 1 user3 class 52 Jul 24 11:08 f2 drwxr-xr-x 2 user3 class 1024 Jul 24 12:03 memo File Links Group Name Type Timestamp Owner Size Permissions 12
  • 13. Who can access a File? The UNIX system incorporates a three-tier structure to define who has access to each file and directory: user The owner of the file group A group that may have access to the file other Everyone else • The ls -l command displays the owner and group who has access to the file. $ ls -l -rw-r--r-- 1 user3 class 37 Jul 24 11:06 f1 -rwxr-xr-x 1 user3 class 37 Jul 24 11:08 f2 drwxr-xr-x 2 user3 class 1024 Jul 24 12:03 memo | | owner group 13
  • 14. File system security (access rights) -rwxrwxrwx a file that everyone can read, write and execute (and delete). -rw------- a file that only the owner can read and write - no- one else can read or write and no-one has execution rights (e.g. your mailbox file).
  • 15. Unix File Permissions  File type, owner, group, others drwx------ 2 jjoshi isfac 512 Aug 20 2003 risk management lrwxrwxrwx 1 jjoshi isfac 15 Apr 7 09:11 risk_m->risk management -rw-r--r-- 1 jjoshi isfac 1754 Mar 8 18:11 words05.ps -r-sr-xr-x 1 root bin 9176 Apr 6 2002 /usr/bin/rs -r-sr-sr-x 1 root sys 2196 Apr 6 2002 /usr/bin/passwd  File type: regular -, directory d, symlink l, device b/c, socket s, fifo f/p  Permission: r, w, x, s or S (set.id), t (sticky)
  • 16. chmod [options] file change access rights for named file For example, to remove read write and execute permissions on the file biglist for the group and others, type % chmod go-rwx biglist This will leave the other permissions unaffected. To give read and write permissions on the file biglist to all, % chmod a+rw biglist
  • 17. Default Permissions The default protections for newly created files and directories are: File -rw-r—r-- 644 Directory drwxr-xr-x 755 These default settings may be modified by changing the umask value. 17
  • 18. umask - Permission Mask Umask specifies what permission bits will be set on a new file or directory when created. New Directory: 777 – 022 755  rwxr-xr-x New File : 666 – 022 644 rw-r—r— The default value of umask is set in /etc/profile. This can be changed for all the users or a particular user 18
  • 19. chown - Change File Ownership Syntax: chown owner [:group] filename ... Changes owner of a file(s) and, optionally, the Example: group ID $ id uid=101 (user1), gid=101 (group1) $ cp f1 /tmp/user2/f1 $ ls -l /tmp/user2/f1 -rw-r----- 1 user1 group1 3967 Jan 24 13:13 f1 $ chown user2 /tmp/user2/f1 $ ls -l /tmp/user2/f1 -rw-r----- 1 user2 class 3967 Jan 24 13:13 f1 Only the owner of a file (or root) can change the ownership of the file. 19
  • 20. The chgrp Command Syntax: chgrp newgroup filename ... Example: $ id uid=303 (user3), gid=300 (class) $ ls -l f3 -rw-r----- 1 user3 class 3967 Jan 24 13:13 f3 $ chgrp class2 f3 $ ls -l f3 -rw-r----- 1 user3 class2 3967 Jan 24 13:13 f3 $ chown user2 f3 $ ls -l f3 -rw-r----- 1 user2 class2 3967 Jan 24 13:13 f3 20
  • 21. su - Switch User Id Syntax: su [user_name] Change your effective user ID and group ID Example: $ ls -l f1 -rwxr-x--- 1 user1 group1 3967 Jan 24 23:13 class_setup $ id uid=303 (user1), gid=300 (group1) $ su – user2 Password: $ id uid=400 (user2), gid=300 (group1) 21
  • 22. Special File Permissions – setuid, setgid, sticky bit  setuid – changes the effective user id of the user to the owner of the program  chmod u+s f1 or – chmod 4744 f1  setgid – changes the effective group id of the user to the group of the program  chmod g+s f1 or  chmod 2744 f1  sticky bit – ensures the deletion of files by only file owner in a public writable directory  chmod +t f1 or  Chmod 1744 f1 22
  • 23. What Is vi? • A screen-oriented text editor • Included with most UNIX system distributions • Command driven • Categories of commands include – General administration – Cursor movement – Insert text – Delete text – Paste text – Modify text 23
  • 24. Starting and Ending a vi Session vi [filename] Start a vi edit session of file Example: $ vi testfile - If the file doesn’t exist, it will be created - Otherwise vi will open the existing file All modifications are made to the copy of the file brought into memory. :wq or :x or <shift-zz> write and quit :w write :q quit :q! Quit without saving 24
  • 25. Cursor Control Commands 1G <ctrl-b> H k <up-arrow> 0 $ b,B w,W h l <left-arrow> <right-arrow> <down-arrow> j L <ctrl-f> G 25
  • 26. Input Mode: i, a, O, o i will insert character at the present cursor position I will insert character at the beginning of the line a will append character at the present cursor position A will append character at the end of the line o will insert a blank line below O will insert a blank line above 26
  • 27. Deleting Text: x, dw, dd, dG x deletes the current character dw deletes the current word dd deletes the current line dG delete all lines to end of file, including current line. With any of these you can prefix a number Example: 3dd will delete 3 lines d$ to delete to the end of the line d0 to delete to the start of the line 27
  • 28. Copying, moving and changing Text yy copy the line yw copy the word p will paste the yanked lines below dw cut the word P will paste the yanked lines above dd cut the line r will overwrite the current character R will replace all text on the right of the cursor position cw will replace only the current word 28
  • 29. Searching for Text: /, n, N /director will locate for the first occurrence of the pattern ‘director’ n to locate the next occurrence N to locate the previous occurence 29
  • 30. Monitoring Process The ps command dislays process status information $ ps -f UID PID PPID ... TTY ... COMMAND john 202 1 ... tty0 ... -ksh john 204 202 ... tty0 ... ksh john 210 204 ... yyu0 ... ls -R / john 212 204 ... tty0 ... ps -f 30
  • 31. Shell Scripting  Shell scripting skills have many applications, including:  Ability to automate tasks, such as  Backups  Administration tasks  Periodic operations on a database via cron  Any repetitive operations on files  Increase your general knowledge of UNIX  Use of environment  Use of UNIX utilities  Use of features such as pipes and I/O redirection
  • 32. Examples of Shell Scripting  Store the following in a file named simple.sh and execute it #!/bin/sh # Show some useful info at the start of the day date echo Good morning $USER cal last | head -6  Shows current date, calendar, and a six of previous logins  Notice that the commands themselves are not displayed, only the results

Editor's Notes

  1. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  2. Shell is a Command Intrepreter www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  3. Hierarchical File System Information is stored on the disk in containers known as files. Every file is assigned a name, and user accesses a file by referencing its name. Files normally contain data, text, programs, and so on. In the UNIX system, a directory can be used to store files or other directories. Multi-tasking In the Unix system several tasks can be performed at the same time. From a single terminal, a single user can execute several programs that all seem to be running simultaneously. Programming facility The UNIX shell is also a programming language; it was designed for a programmer, not casual end user. It has all the necessary ingredients like control structures, loops and variables that establish it as a powerful programming language on its own right. These features are used to design shell scripts- programs that also include UNIX commands in their syntax. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  4. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  5. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  6. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  7. A file has several characteristics associated with it. They can be displayed using the ls –l command. Type regular file or special file. Permission or mode access definition for the file. Links number of file names associated with a single collection of data. Owner user identification of file owner Group group identification for file access Size number of bytes file contains Timestamp date file last modified Name maximum of 14 characters www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  8. Who Has Access The three classes of users are: • Owner — Usually the person who created the file. • Group — Several users that have been grouped together by the system administrator. For example, the members of a department might belong to the same group. • Other — All other users on the system. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  9. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  10. You should also be aware of the default permissions assigned to all of your files and directories at the time you create them. You can list or change the default permission settings by using the umask command. Default file permissions are assigned by the system whenever you create a new file or directory, and these are governed by your umask setting. To restrict these default permissions for newly-created files and directories, use the umask command. When a new file is created, each bit in the file mode creation mask that is set causes the corresponding permission bit in the file mode to be cleared (disabled); hence the term mask. Conversely, bits that are cleared in the mask allow the corresponding file mode bits to be enabled in newly created files. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  11. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  12. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  13. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  14. setuid: When set-user identification (setuid) permission is set on anexecutable file, a user or process that runs this executable file is granted access based on the owner of the file (usually root) instead of the user who started the executable. For eg. the executable file /usr/bin/passwd is set with setuid so that when any nonprivileged user runs the command the effective user id is not of the user but that of root. Because of that the password is updated in the file /etc/shadow though the normal user dont have any write permission on this file. -r-sr-xr-x 1 root sys 17156 Jan 5 17:03 /usr/bin/su setgid: The set-group identification (setgid) permission is similar to setuid,except that the effective group ID of the user or the process is changed to the group owner of the file. Also, access is granted based on the permissions assigned to that group. For example, the mail program has a setgid permission used to read mail, or send mail to other users. -r-x--s--x 1 root mail 61288 Jan 5 16:57 /usr/bin/mail The setgid permission is a useful feature for creating shared directories. When a setgid permission is applied to a directory, files created in the directory belong to the group to which the directory belongs. Sticky Bit: If the directory has the Sticky Bit set, a file can be deleted only by the owner of the file, the owner of the directory, or by root. This prevents a user from deleting other users’ files from publicly writable directories. For example: # ls -ld /tmp drwxrwxrwt 6 root sys 719 May 31 03:30 /tmp www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  15. The vi editor is a powerful, versatile editing tool. The vi editor is included with every versions of UNIX. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  16. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  17. l or -&gt; will move the cursor right by one character h or &lt;- will move the cursor left by one character j or down arrow will move the cursor one line down k or up arrow will move the cursor up by one line up w or W will move cursor to the next word b or B will move cursor to the previous word 0 will move cursor to the beginning of the line $ will move cursor to the end of the line 1G will move cursor to the first line of the file G will move cursor to the last line of the file &lt;ctrl-f&gt; will move cursor down by a page &lt;ctrl-b&gt; will move cursor up by a page H will move cursor to the top of the current page M will move cursor to the Middle of the current page L will move cursor to the bottom of the current page www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  18. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  19. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  20. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  21. www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar
  22. PID: Process ID PPID: Parent Process ID UID: User ID ps command will only show the processes started by the current user. ps -af will display all the processes started by all users ps -ef will display all the processes including the system processed www.scmGalaxy.com, Author - Rajesh Kumar www.scmGalaxy.com, Author - Rajesh Kumar