UNIX/LINUX OPERATING SYSTEM

Slides:



Advertisements
Similar presentations
Learning Unix/Linux Bioinformatics Orientation 2008 Eric Bishop.
Advertisements

1 Introduction to UNIX Ke Liu
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Lesson 22 – Introduction to Linux Systems Administration.
Linux+ Guide to Linux Certification, Second Edition
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
Guide To UNIX Using Linux Third Edition
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Linux+ Guide to Linux Certification, Second Edition
Linux Commands LINUX COMMANDS.
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Linux System Administration LINUX SYSTEM ADMINISTRATION.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
Linux Filesystem Management
Booting and boot levels
Help session: Unix basics Keith 9/9/2011. Login in Unix lab  User name: ug0xx Password: ece321 (initial)  The password will not be displayed on the.
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
Chapter 9 Part II Linux Command Line Access to Linux Authenticated login using a Linux account is required to access a Linux system. The Linux prompt will.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
Managing User Accounts. Module 2 – Creating and Managing Users ♦ Overview ► One should log into a Linux system with a valid user name and password granted.
Guide To UNIX Using Linux Fourth Edition
Linux+ Guide to Linux Certification, Second Edition
ITI-481: Unix Administration Meeting 3. Today’s Agenda Hands-on exercises with booting and software installation. Account Management Basic Network Configuration.
Linux+ Guide to Linux Certification, Third Edition
System Administration Introduction to Unix Session 2 – Fri 02 Nov 2007 Reference:  chapter 1, The Unix Programming Environment, Kernighan & Pike, ISBN.
Linux Network Configuration Linux System Administration /etc/resolv.conf Tells the kernel which name server should be queried when a program asks to "resolve"
Session 2 Wharton Summer Tech Camp Basic Unix. Agenda Cover basic UNIX commands and useful functions.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Users Greg Porter V1.0, 26 Jan 09. What is a user? Users “own” files and directories Permission based on “ownership” Every user has a User ID (UID) 
Lesson 2-Touring Essential Programs. Overview Development of UNIX and Linux. Commands to execute utilities. Communicating instructions to the shell. Navigating.
Chapter 3 & 6 Root Status and users File Ownership Every file has a owner and group –These give read,write, and execute priv’s to the owner, group, and.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Introduction to Programming Using C An Introduction to Operating Systems.
CSC414 “Introduction to UNIX/ Linux” Lecture 5. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Basic of UNIX For fresh members of SPARCS
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands: which, passwd, date, ps / kill Working with Files: file, touch, cat, more, less, grep,
1 Begin to use Linux. 2 Background  Linux is an operating system similar to UNIX. It runs on many different computers and was first released in 1991.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
CSE 374 Programming Concepts & Tools Hal Perkins Fall 2015 Lecture 2a – A Unix Command Sampler (Courtesy of David Notkin, CSE 303)
Linux Commands C151 Multi-User Operating Systems.
ITI-481: Unix Administration Meeting 3 Christopher Uriarte, Instructor Rutgers University Center for Applied Computing Technologies.
System Administration. Logging in as System Administrator System Admin login (aka superuser, aka root) –login id: root –Default PS1 prompt: # –Home directory:
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
1 CS3695 – Network Vulnerability Assessment & Risk Mitigation – Introduction to Unix & Linux.
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
Learning Unix/Linux Based on slides from: Eric Bishop.
INTRODUCTION TO SHELL SCRIPTING By Byamukama Frank
LINUX SYSTEM ADMINISTRATION
Tutorial of Unix Command & shell scriptS 5027
Linux Commands Help HANDS ON TRAINING Author: Muhammad Laique
System Programming and administration CS 308
System Programming and administration CS 308
FTP Lecture supp.
Some Linux Commands.
Agenda Basic Unix Commands (Chapters 2 & 3) Miscellaneous Commands:
CSE 374 Programming Concepts & Tools
Linux Network Configuration
Tutorial of Unix Command & shell scriptS 5027
Introduction to UNIX.
Tutorial of Unix Command & shell scriptS 5027
Unix : Introduction and Commands
Tutorial of Unix Command & shell scriptS 5027
LINUX SYSTEM ADMINISTRATION
Tutorial Unix Command & Makefile CIS 5027
Linux Filesystem Management
Linux Commands LINUX COMMANDS.
Presentation transcript:

UNIX/LINUX OPERATING SYSTEM

UNIX/LINUX Commands Linux Commands A command is a program which interacts with the kernel to provide the environment and perform the functions called for by the user. A command can be: a built-in shell command; an executable shell file, known as a shell script; or a source compiled, object code file. The shell is a command line interpreter. The user interacts with the kernel through the shell. You can write ASCII (text) scripts to be acted upon by a shell. It reads the terminal input and translates the commands into actions taken by the system. The shell is analogous to command.com in DOS.

UNIX Shell Linux Commands The original shell was the Bourne shell, sh. Every Unix platform will either have the Bourne shell, or a Bourne compatible shell available. The default prompt for the Bourne shell is $ (or #, for the root user). Another popular shell is C Shell. The default prompt for the C shell is %.

Shell Programming Linux Commands You can write shell programs by creating scripts containing a series of shell commands. The first line of the script should start with #! which indicates to the kernel that the script is directly executable. You immediately follow this with the name of the shell, or program (spaces are allowed), to execute, using the full path name. So to set up a Bourne shell script the first line would be: #! /bin/sh The first line is followed by commands #!/bin/bash cd /tmp mkdir t You also need to specify that the script is executable by setting the proper bits on the file with chmod, e.g.: $ chmod +x shell_script

LINUX COMMANDS Linux Commands File Management and Viewing Help, Job and Process Management Network Management System Management User Management Miscellaneous

Command Structure Linux Commands Command <Options> <Arguments> Multiple commands separated by ; can be executed one after the other

Help Facilities for Commands Linux Commands Help Facilities for Commands To understand the working of the command and possible options use (man command) Using the GNU Info System (info, info command) Many tools have a long−style option, `−−help', that outputs usage information about the tool, including the options and arguments the tool takes. Ex: whoami --help

Linux Commands Pipes An important early development in Unix was the invention of "pipes," a way to pass the output of one tool to the input of another. eg. $ who | wc −l By combining these two tools, giving the wc command the output of who, you can build a new command to list the number of users currently on the system

QUESTIONS?

Listing the Content of a Directory Introduction to Linux Listing the Content of a Directory ls is used to list the contents of a directory. If the command ls is written with parameter –l then the command lists contents of the working directory with details. Example: $ ls –l

Moving in Directories Introduction to Linux cd try_it Changes the directory to try_it pwd Prints present working directory (e.g. /home/smith/try_it) cd .. Move to superior directory pwd : Prints /home/smith cd /home The absolute path pwd : Prints /home cd The system is returned to the user home directory pwd : Print /home/smith

Make Directory Introduction to Linux The command mkdir test makes new directory test (the path is given relative) as a subdirectory of the current directory.

Remove Directory Introduction to Linux The command rmdir your_dir removes directory your_dir if it is empty. The command rm –rf is used to delete a non empty directory

Copy File Introduction to Linux The command cp file_1 file_2 copies file_1 to file_2. The both files must be in the same working directory. If they are in various directories, the path must be given.

Rename and/or Move the File Introduction to Linux Rename and/or Move the File The command mv file_1 file_2 moves file_1 to file_2 The both files must be in the same working directory. If they are in different directories, the path must be given. The file_1 is removed from the disk.

Remove File Introduction to Linux The command rm file_a removes the file_a from the system If you use wildcard. For example rm h*c you will remove all files beginning with h and ending with c which are in working directory. If you write rm * you will erase all files from your working directory.

Access Permission of File/Directory Introduction to Linux Access Permission of File/Directory The ownership of the file or directory can be changed using the command chown <owner> <file/directory name> The group of the file or directory can be changed using the command chgrp <group> <file/directory name> The permissions of the file can be changed using chmod command chmod -R ### <filename or directory> -R is optional and when used with directories will traverse all the sub-directories of the target directory changing ALL the permissions to ###.

Access Permission of File/Directory Introduction to Linux Access Permission of File/Directory The #'s can be: 0 = Nothing 1 = Execute 2 = Write 3 = Execute & Write  (2 + 1) 4 = Read 5 = Execute & Read (4 + 1) 6 = Read & Write (4 + 2) 7 = Execute & Read & Write (4 + 2 + 1)

QUESTIONS?

Linux File Management and Viewing Linux Commands Linux File Management and Viewing find Find files (find <start directory> -name <file name> -print) Ex: find /home –name readme -print (Search for readme starting at home and output full path.) “/home" = Search starting at the home directory and proceed through all its subdirectories "-name readme" = Search for a file named readme "-print" = Output the full path to that file locate File locating program that uses the slocate database. Ex: locate –u to create the database, locate <file/directory> to find file/directory

Linux File Management and Viewing Linux Commands Linux File Management and Viewing File viewing and editing vi Editor with a command mode and text mode. Starts in command mode. gedit GUI Text Editor tail Look at the last 10 lines of a file. Ex: tail -100 <filename> (looks at last 100 lines) head Look at the first 10 lines of a file. (head <filename>)

Linux File Management and Viewing Linux Commands Linux File Management and Viewing cat View a file Ex: cat filename grep List all files with the specified expression. (grep pattern <filename/directorypath>) Ex: ls –l |grep sidbi : List all lines with a sidbi in them. Ex: grep " R " : Search for R with a space on each side sleep Delay for a specified amount of time. sort Sort a file alphabetically. uniq Remove duplicate lines from a sorted file. wc Count characters, words and lines in a file. (wc –c/w/l <filename>).

Network Management Commands Linux Commands Network Management Commands ping Send ICMP ECHO_REQUEST packets to network hosts. (ping <remote-host-name/ip>) ssh Secure Login (ssh <remote system name/ip>) telnet User interface to the TELNET protocol, setting up a remote console session. (telnet <remote system name/ip>) tcpdump Dump traffic on a network. Prints out headers of packets that match the boolean expression. (tcpdump eth0) traceroute Print the route that packets take to the specified network host. (traceroute <remote system name/ip>)

System Management Commands Linux Commands System Management Commands shutdown If your system has many users, use the command shutdown -h +time ‘<message>`, where time is the time in minutes until the system is halted, and message is a short explanation of why the system is shutting down. Ex: # shutdown -h +10 'We will install a new disk. System should be back on-line in three hours’. passwd Set a user's pass word. (passwd, passwd <username>)

System Management Commands Linux Commands System Management Commands su Single user login. (su -) who Display the users logged in. whoami Print effective user id.

Linux Job & Process Management Linux Commands Linux Job & Process Management Linux Process Management ps Get the status of one or more processes. PPID-parent process ID ; PID-process ID Eg: ps ax |more to see all processes including daemons Eg : ps –ef | grep <process> top The top program provides a dynamic real-time view of a running system. It can display system summary information as well as a list of tasks currently being managed by the Linux kernel

Linux Job & Process Management Linux Commands Linux Job & Process Management Linux Process Management kill Ex: "kill 34" - Effect: Kill or stop the process with the process ID number 34. killall Kill processes by name. pid Find the process ID of a running program

QUESTIONS?

SYS ADMIN TASKS Linux System Administration Setting the Run Level System Services User Management Network Settings Scheduling Jobs Backup and Restore Adding and Removing software/packages Monitoring the system (general, logs)

Init Runlevels Linux System Administration The following runlevels are defined in Linux: 0 - halt (Do NOT set initdefault to this) 1 - Single user mode 2 - Multiuser, without Network (The same as 3, if you do not have networking) 3 – Text Mode 4 - unused 5 – Graphical Mode 6 - reboot (Do NOT set initdefault to this)

Init Runlevels Desktop Configuration The default runlevel for a system to boot to is configured in /etc/inittab. id:5:initdefault: In GUI: Applications  System Settings  Server Settings Services Generally, Linux operates in runlevel 3 or 5.

Linux Services Linux System Administration There are 113 deamons, each for a service or application. Some examples are: httpd : Apache Web server mysqld : MySQL server named : DNS server network : Networking nfs : Network File Share ntpd : NTP (Network Time Protocol) server

Linux Services Linux System Administration Start/Stop boot time services in /etc/rc.d/rc3.d or /etc/rc.d/rc5.d All services startup scripts which start with S will start at boot time and all startup scripts which start with K will not start at boot time. The number after S or K is the priority. K95kudzu K96pcmcia S56xinetd S60vsftpd Use service <service name> start/stop/restart to start, stop or restart a service from command line

Creating a new User Account Linux System Administration Creating a new User Account Add an entry in /etc/passwd and /etc/shadow file (use next uid and suitable gid). You will have to create the user directory and assign a password to the user Use useradd or adduser command to create a new user (useradd –g <group> -d <home directory> -c <comment> -s <shell> login-name) and groupadd to create a new group (groupadd group-name). You will have to assign a password (passwd login-name) In GUI: Applications  System Settings  Users and Groups

/etc/passwd and /etc/shadow File Linux System Administration /etc/passwd and /etc/shadow File /etc/passwd Holds user account info Included fields are: Login name User Id (uid) Group Id (gid) General Comment about the user Home Directory Shell /etc/shadow Contains the encrypted password information for users' accounts and optionally the password aging information.

Removing a User Account Linux System Administration Removing a User Account userdel –r <username> Remove login id from /etc/passwd & /etc/shadow file and delete home directory Use GUI to Delete the user

QUESTIONS?

Linux Network Configuration Linux System Administration Linux Network Configuration /etc/resolv.conf Tells the kernel which name server should be queried when a program asks to "resolve" an IP Address. nameserver 172.31.1.1 search cc.iitk.ac.in iitk.ac.in /etc/sysconfig/network Indicates networking is enabled (NETWORKING=yes) and provides information on hostname, gateway and nis domain. NETWORKING=yes HOSTNAME=webhome.cc.iitk.ac.in GATEWAY=172.31.1.250

Linux Network Configuration Linux System Administration Linux Network Configuration /etc/sysconfig/network-scripts/ifcfg-eth0 Network configurations like boot protocol (static/dhcp), ip address, netmask, network address, broadcast address etc. DEVICE=eth0 ONBOOT=yes BOOTPROTO=static IPADDR=172.31.1.40 NETMASK=255.255.0.0 BROADCAST=172.31.255.255 NETWORK=172.31.0.0 GATEWAY=172.31.1.250

Scheduling Jobs: Cron Linux System Administration Cron is a program that enables you to execute a command, or a script with a sequence of commands, at a specified date, time or at set intervals. Add the job script in /etc/cron.hourly or /etc/cron.daily or /etc/cron.weekly or /etc/cron.monthly to schedule a job

Backup & Restore Linux System Administration Backup the user area or configuration file Use tar to take backup on a different disk or tape Backup can be scheduled using cron Backup: tar –zcvf <tar filename> <Directory Tree to be backedup> Restore: tar –zxvf <tar filename> <file to be recovered> Backup should be occasionally checked by restoring it Backup Policy: Full Backup every weekly/fortnightly and incremental backup every day

Adding & Removing Software Linux System Administration Adding & Removing Software Download a binary Download the source code and compile on the system (download, untar, configure, make, make install, make uninstall) Use RPM - Redhat Package Manager and install rpms www.rpmseek.com & www.rpmfind.net can be used to search and download rpms (i386 Binary RPMs or SRC RPMs) For Binary rpms: rpm [options] rpm-file (rpm –qa, rpm –ivh, rpm –Uvh, rpm -e) Where -q= query, -a= all, -i=install, -v=verbrose, -U= upgrade, -h= hash, -e= erase For Source rpms: rpmbuild –rebuild rpm-source-file Compiled binary rpms will be available at /usr/src/redhat/RPMS/i386 which can be installed

Monitoring the System Linux System Administration Monitor Disk Usage (df) Monitor CPU and Memory utilization (top) Monitor process/services (ps, pgrep) Monitor logs (/var/log/messages) GUI Tool (Applications System Tools System Performance)

QUESTIONS?