Presented by Bill Genske Gary Jackson

Similar documents
Introduction to Linux for QSS/OASIS System Administrators and System Operators

Migrating System Operations and Administration from Version H to Version L

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

GNU/Linux 101. Casey McLaughlin. Research Computing Center Spring Workshop Series 2018

Introduction to Linux

Unix Filesystem. January 26 th, 2004 Class Meeting 2

Linux Command Line Primer. By: Scott Marshall

Unix Introduction to UNIX

Lab 2A> ADDING USERS in Linux

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

SIEMENS UserAdmin Workshop TELEPERM XP Version 4 Chapter 1

Embedded Linux Systems. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

CS Fundamentals of Programming II Fall Very Basic UNIX

Unix File System. Class Meeting 2. * Notes adapted by Joy Mukherjee from previous work by other members of the CS faculty at Virginia Tech

h/w m/c Kernel shell Application s/w user

A Brief Introduction to Unix

Chapter-3. Introduction to Unix: Fundamental Commands

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Introduction to the Linux Command Line

Introduction to Linux Workshop 1

Perl and R Scripting for Biologists

INTRODUCTION TO LINUX

CS/CIS 249 SP18 - Intro to Information Security

Outline. Structure of a UNIX command

Unix File System. Learning command-line navigation of the file system is essential for efficient system usage

Hands-on Keyboard: Cyber Experiments for Strategists and Policy Makers

Introduction to the UNIX command line

Operating Systems Lab 1 (Users, Groups, and Security)

Computer Systems and Architecture

CS 215 Fundamentals of Programming II Spring 2019 Very Basic UNIX

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

UNIX File Hierarchy: Structure and Commands

CS4350 Unix Programming. Outline

Introduction to Linux Part 1. Anita Orendt and Wim Cardoen Center for High Performance Computing 24 May 2017

Week Overview. Unix file system File types and file naming Basic file system commands: pwd,cd,ls,mkdir,rmdir,mv,cp,rm man pages

Chapter 6. Linux File System

Working with Basic Linux. Daniel Balagué

Introduction to Linux

CS197U: A Hands on Introduction to Unix

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

Using the Zoo Workstations

Introduction to Linux

CSCI 2132 Software Development. Lecture 4: Files and Directories

Introduction to Linux

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Overview LEARN. History of Linux Linux Architecture Linux File System Linux Access Linux Commands File Permission Editors Conclusion and Questions

Linux Systems Administration Getting Started with Linux

CISC 220 fall 2011, set 1: Linux basics

Session 1: Accessing MUGrid and Command Line Basics

Contents. Note: pay attention to where you are. Note: Plaintext version. Note: pay attention to where you are... 1 Note: Plaintext version...

Please choose the best answer. More than one answer might be true, but choose the one that is best.

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Commands are in black

Introduction: What is Unix?

CSCE 212H, Spring 2008, Matthews Lab Assignment 1: Representation of Integers Assigned: January 17 Due: January 22

Mills HPC Tutorial Series. Linux Basics I

Course 144 Supplementary Materials. UNIX Fundamentals

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

CS370 Operating Systems

Overview of the UNIX File System

Manage Directories and Files in Linux. Objectives. Understand the Filesystem Hierarchy Standard (FHS)

Unix System Architecture, File System, and Shell Commands

Introduction to Linux. Fundamentals of Computer Science

This lab exercise is to be submitted at the end of the lab session! passwd [That is the command to change your current password to a new one]

LAB #7 Linux Tutorial

Linux Training. for New Users of Cluster. Georgia Advanced Computing Resource Center University of Georgia Suchitra Pakala

CENG 334 Computer Networks. Laboratory I Linux Tutorial

INF322 Operating Systems

CS246 Spring14 Programming Paradigm Notes on Linux

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

IBM AIX Basic Operations V5.

Computer Systems and Architecture

Introduction to Unix: Fundamental Commands

Std: XI CHAPTER-3 LINUX

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

CST8207: GNU/Linux Operating Systems I Lab Six Linux File System Permissions. Linux File System Permissions (modes) - Part 1

National University of Computer and Emerging Sciences Operating System Lab - 02 Lab Manual

Introduction to Linux

UNIX Quick Reference

Lab Working with Linux Command Line

EECS2301. Lab 1 Winter 2016

Exercise Sheet 2. (Classifications of Operating Systems)

Practical Session 0 Introduction to Linux

CHE3935. Lecture 1. Introduction to Linux

Introduction of Linux

Introduction to Linux. Roman Cheplyaka

Lab 3a Using the vi editor

Essential Unix and Linux! Perl for Bioinformatics, ! F. Pineda

Basic Survival UNIX.

Overview of the UNIX File System. Navigating and Viewing Directories

Linux Nuts and Bolts

Crash Course in Unix. For more info check out the Unix man pages -orhttp:// -or- Unix in a Nutshell (an O Reilly book).

List of Linux Commands in an IPm

Getting Started. Running Utilities. Shells. Special Characters. Special Characters. Chapter 2 Unix Utilities for non-programmers

Unix Handouts. Shantanu N Kulkarni

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Transcription:

Quintessential School Systems Session C Linux Presented by Bill Genske Gary Jackson Copyright Quintessential School Systems, 2009 All Rights Reserved 867 American Street --- Second Floor --- San Carlos, CA 94070 --- 650/372-0200 -- www.qss.com

Linux (Hands On) March 3, 2008 Session C Presented by Bill Genske (QSS) and Gary Jackson (QSS) Hands On Experience This session will combine lecture with individual hands on exercises as we go. Look for the symbol to indicate a hands on exercise. Feel free to ask questions or for additional explanation. 1

Starting Linux Just hit the power switch Power on your workstation. Allow it to boot uninterrupted. Boot loader starts first, then starts the kernel. kernel then starts init. Init will executed the startup scripts (rc files) based on the configured runlevel. Startup message appear on tty1 console Virtual Consoles Seven virtual consoles (f1 thru f7) Press alt plus a function key (alt-fkey) to switch Can be signed on to any of them using different users doing different tasks simultaneously Six (f1 thru f7) are text-based. Devices are tty1 thru tty6 The tty1 device is also used for system messages One (f7) is the X Windows System (Graphical Desktop) Must also press ctl key with alt-fkey to switch away from graphical desktop, ctl-alt-fkey Graphical desktop will usually be either GNOME or KDE. What you see on the logon screen is configurable. 2

Remote Access Text-based Using telnet, rlogin, or secure shell (ssh) Putty is a very common windows-based program Graphical Using VNC, or other X Windows client such as Reflection X X windows, a windows manager, VNC service, and graphical desktop package must be installed, configured, and enabled File transfers to/from server ftp, if configured and enabled WinSCP is a very common windows-based file transfer program which uses ssh s sftp instead of ftp. Logging on Text-based Type user and press enter after logon as: Type password and press enter after Password: 3

System Users root System administrator Best Practice is to use this user only when needed to prevent making a mistake while learning Most commands do not prompt for confirmation There is no undo! root can do anything! QSS Users qssmgr QSS System Administrator Used to install software and configure the system qssopr QSS System operator Used for accounts payable and payroll processing qssdba QSS Database administrator 4

Log on Switch to tty1 from graphical desktop using ctlalt-f1. You should see the tail end of the startup messages. Logon to the root user. Password for these servers is Root4qss Return to the graphical desktop using alt-f7. Logon to the train user. Password for these servers is qss. Find the terminal icon and open a terminal window so you can type commands Commands Case-sensitive Some commands are built into the shell bash Bourne Again Shell Interactive use sh Bourne Shell Scripts Commands consist of a name and optional flags and arguments flags (aka options, switches) can usually be in any order and combined. flags are preceded with a dash arguments must sometimes follow particular flags or be in a specific order 5

Paths Commands are found based on path Omitted path uses $PATH variable echo $PATH Relative path uses./ (current directory) or../ (parent directory) Absolute path is a fully qualified name The pwd command, print working directory, shows your current directory pwd hello_world script You should be in /home/train directory which contains the hello_world script. The following command uses the $PATH to find the command. Why does it fail? hello_world The following command uses a relative path for the current directory./hello_world The following command uses an absolute path. /home/train/hello_world 6

Help for Commands type command shows how a command will be interpreted help shows syntax of a shell built-in command man shows you man page for command info shows you info document for command type and help exercises type type type pwd help type type -a -t pwd In the previous example -a and -t are flags and pwd is an argument which must be last. The following are equivalent type -t -a pwd type -at pwd type -ta pwd The following is not equivalent and will fail. type pwd -a -t 7

man segments Man pages usually include a number of segments. NAME - brief description of the command SYNOPSIS - syntax DESCRIPTION - more detailed description OPTIONS - explains the flags and arguments shown in SYNOPSIS in detail EXAMPLES - examples ENVIRONMENT - shows what variables if any effect the command. FILES - shows related files if any SEE ALSO - lists similar or related man pages. man key commands Basic key commands in man (uses many of the same navigation key commands as vi) q - exit spacebar - page down 1 page at a time Enter - page 1 line at a time home, end, page up, page down, up arrow, down arrow - same as in windows (may not work in all distributions) /search-text - find a given text string n - find next man man man passwd man 5 passwd 8

Information about a file file shows you the file s type file hello_world file /bin/ls ls -l shows you a file s attributes ls -l hello_world -rwxr-xr-x 1 train users 28 2009-02-24 13:40 hello_world Permissions -rwxr-xr-x owner and group train users Size 28 Date and time file was modified 2009-02-24 13:40 Permissions -rwxr-x--- 1 st character is d if a directory Next 3 characters rwx show read, write, and execute permission for owner of file Next 3 characters r-x show read, write and execute permission for group Last 3 character --- show read, write and execute permission for everyone else. If a value is - instead of r, w, or x then that permission is not granted. 9

Commands to change file s security chmod changes permissions (must be owner or root) chown changes owner and group (must be root) chgrp change group (must be owner or root) User and Group commands useradd create a new user account usermod modify a user account userdel delete a user account passwd change user password groupadd create a new group groupmod modify a group groupdel delete a group su run a shell with a substitute user and group sudo execute commands as another user whoami - print effective user 10

User excercises try the following from the terminal window in the graphical desktop while logged on as the train user whoami su - Enter the password for root. If you don t specify a user then root is assumed. whoami su qssmgr You changed the effective user and group but do not have qssmgr s envirornment. You were not asked for qssmgr s password since root can do anything. exit su - qssmgr You changed the effective user and group AND have qssmgr s envirornment. exit exit 2 nd time to exit root Commands to view a file cat display a file more page forward through file less page forward and backward through file. head show the last n lines (default is 10) tail show the last n lines (default is 10) grep search a file for a string 11

Commands to manage files touch create a empty file or change timestamp on a file cp copy a file mv rename a file rm remove a file touch example-file cp example-file example-file.save mv example-file example.txt rm -i example-file.save rm example.txt Commands to manage files ls list files ls ls -l ls -al find find files Find stdlists larger than 100K (qssmgr) find $QSS_DATA/jobsched/stdlists -name stdlist.* -size +100k -exec ls -l {} \; Find stdlists older than 30 days (qssmgr) find $QSS_DATA/jobsched/stdlists -name stdlist.* -mtime +30 -exec ls -l {} \; Find and remove core dump files from the entire system (root) find / -name core -type f -exec rm -i {} \; vi edit a file 12

Using vi to edit files To edit a file with vi vi filename vi s modes Normal mode One or two keystroke commands to navigate and make changes Keystrokes are not echoed in most cases Insert mode Press i to enter insert mode Can use arrow keys, page up, page down, to move around, delete key to delete characters, what you type is inserted, etc. Much like Notepad. Press Esc to return to normal mode Replace mode, similar to Insert mode but overwrites existing text. Press R to enter replace mode To exit vi (must be in Normal mode) :wq to save file and exit :q to exit if you didn t make any change :q! to exit without saving vimtutor To learn vi use the command: vimtutor vimtutor Do lessons 1.1 thru 1.4 13

Commands for directories pwd print current working directory cd change directory mkdir create a directory mkdir example-dir touch example-dir/example-file ls -l example-dir ls -ld example-dir rmdir remove an empty directory mkdir empty-dir rmdir empty-dir rmdir example-dir the 2 nd rmdir should fail because example-dir is not empty Commands for directories cp -r copy a directory cp example-dir copy-of-example-dir cp example-dir/* copy1-of-example-dir cp -r example-dir copy2-of-example-dir ls -l *dir In the exercises above you should have seen the 1 st copy fails because cp doesn t not copy directories by default. the 2 nd copy worked but if you look closely at the ls output you see copy1-of-example-dir is not a directory but is the file that was in example-dir the 3 rd copy worked correctly to copy the files in a directory to another directory. If you wanted the files in your current directory use. as the target directory 14

Commands for directories mv rename a directory mv copy2-of-example-dir renamed-dir ls -ld *dir mv renamed-dir example-dir ls -ld *dir ls -l example-dir In the exercises above you should have seen the directory copy2-of-example-dir was renamed to renamed-dir the directory renamed-dir was moved into the example-dir directory rm -ir remove a directory and its files rm -i example-dir this rm will fail because example-dir is a directory rm -ir example-dir Top level directories /bin essential binaries used by all users /etc host specific configuration files /home home directories for users /lib essential shared libraries /media mount point for removable media /sbin system binaries used by root /tmp temporary files /usr secondary hierarchy for non-essential sw /var variable data files /opt optional add-on software ls -l / 15

QSS Directories /etc/opt/qss QSS configuration files /opt/qss QSS software /var/opt/qss QSS data files Switch to the qssmgr user. Password for these servers for qssmgr is qss su - qssmgr QSS Configuration files in /etc/opt/qss jobsched/ configuration directory for QSS Job System jobsched/datemask contains accepted date masks for submitting jobs with the -at option. jobsched/jobid Job number odometer. Modify to reset your job numbers. jobsched/jobsec.cfg lists users allowed to submit jobs. Maintain with JobSecCfg application. Jobsched/JobSvr.cfg configures port number, queues, limits, file locations, etc. cd /etc/opt/qss/jobsched ls -l more JobSvr.cfg cat jobid vi jobid change job number to 1000 (Hint: R to replace, 1000, esc, :wq to save) 16

QSS Configuration files in /etc/opt/qss login/ login directory login/copyright QSS copyright statement. login/message login message. login/netcobolrt.sh script to setup path to NetCOBOL runtime. login/path.qss Added to $PATH of QSS user. Modify this to change path for all QSS users as directed by QSS. login/qss_check this is hooked into system login file. login/qssenv.sh this sets the default environment variables. login/qsslocal.sh this sets customer specific variables and commands. Modify this file to set your values. login/qss_login this is the main login script. qssrun.sh this is the list of commands run when user logs in. user/ - directory for user specific settings. cd /etc/opt/qss/login grep CSSFDINO * more qsslocal.sh vi qsslocal.sh login excercises change QENV_CSSFDINO to be 001 ls -l user more user/qssmgr 17

QSS Configuration files in /etc/opt/qss qat.d/ QSS automated tasks directory (still in development) qat.d/stdlists configuration settings for how to archive and delete stdlists. cd /etc/opt/qss/qat.d more stdlists qcc_ctl.cfg configuration file for QCC servers cd../ more qcc_ctl.cfg cd ~ qdbi/ database configuration QSS Software directories in /opt/qss archive archived versions of files bin essential QSS binaries (utilities) DataDirect DataDirect libraries for accessing database finance Directory for QSS/OASIS software install skeleton and initial version of installation files jobsched/bin binaries for QSS Job System lib QSS libraries qat QSS Automated Tasks modules qcc/bin binaries for QCC servers sbin binaries for system tasks done by qssmgr 18

QSS Data Directories in /var/opt/qss cmd/ - command files and scripts for all users cmd/mgr/ - command files and scripts for qssmgr cmd/opr/ - command files and scripts for qssopr data/ data files data/qcc data files for QCC servers dist/### - district specific files. Each district has its own subdirectory. fmt/ printer format files history/apy/ - accounts payable history files history/pay/ - payroll history files jcl/ - site specific jcl files jobsched/ - QSS Job System files jobsched/queues - files for jobs waiting to run or running jobsched/stdlists - stdlists QSS Data Directories in /var/opt/qss log/ - log files parms/ - parameter files for various applications pdl/ - personnel downloader files pfiles/ - print file directory qcc/ - execution directory for QCC servers release/ - release directory tmp/ - QSS temporary files w21099/#### - W2 and 1099 files. Each year has its own subdirectory. web/ - web template files for QCC servers xfr/ - xfr directory used by QSSXFR 19

Filesystems File system is how an Operating System keeps track of files Linux uses a hierarchical filesystem Current Filesystem Hierarchy Standard (FHS) is 2.3 LVM Logical Volume Management All disks belong to one or more Volume Group Logical Volumes created in Volume Group File system built in logical volume Can be resized Filesystem Commands mount show mounted filesystems or mount a filesystem umount unmount a filesystem df report disk space df du disk space usage du -sk /var/opt/qss du -sk /var/opt/qss/* Use this to get a list of QSS data directories and their sizes. 20

Variables Shell variables are local to the shell Environment Variables are available to subsequent commands By convention shell variables are lowercase and Environment Variables are UPPERCASE Commands for Variables echo can show the value of a variable echo $PATH printenv prints all Environment Variables printenv sort more shellvarname=shellvarvalue sets a shell variable export ENVVARNAME=envvarvalue sets a environment variable 21

QSS Variables $QSS_ROOT set to main software directory, usually /opt/qss $QSS_CFG set to configuration directory, usually /etc/opt/qss $QSS_DATA set to data directory, usually /var/opt/qss Most other QSS variables can be found by printenv sort grep Q more Set by QSS login scripts qss_login, qssenv.sh, qsslocal.sh, and user specific login script Sourcing a file Sourcing a file executes the commands in that file in the current shell. Syntax source filename. filename Different than executing a script which cannot pass variables back to parent. Only method to export variables from a file. 22

Exporting a variable in script vs. source example Starting/Stopping QSS Job System Status (from qssmgr or root ) /etc/init.d/qss_jobsvr status Starting (from root user) /etc/init.d/qss_jobsvr start Starts every instance defined in /etc/sysconfig/qss_jobsvr Can be set to start automatically at boot Stopping (from root user) /etc/init.d/qss_jobsvr stop Stops every instance defined in /etc/sysconfig/qss_jobsvr may take a few moments to stop. Can be set to stop automatically at shutdown Stopping (from qssmgr user) /opt/qss/jobsched/bin/jobcli Use connect and stop commands Change to the root user using: su - Use /etc/init.d/qss_jobsvr to check the status, stop, and start the service. exit from root user 23

qss_jobsvr examples QSS Job System add-on Commands sj show job Use sj -h to see syntax dj <jobnum> delete job js job submit Use js -h to see syntax lsl [<user>] list stdlists use lsl -l for long version prjob <jobnum> - print stdlist dljob <jobnum> - delete stdlist (in development) 24

Job Exercises js printenvjob js sleepjob js -at 20:30 sleepjob sj dj 1002 (or whatever job # was the 1 st sleepjob) dj 1003 (or whatever job # was the 2nd sleepjob) prjob 1002 (or whatever job # was the 1 st sleepjob) prjob 1003 (or whatever job # was the 2nd sleepjob) Will not find stdlist since job was scheduled and never ran. lsl MGR lsl -l The exit status is 9 for the deleted job that started running indicating it was aborted. Other exit status values indicate other problems occurred in the job which caused the job to fail. Starting/Stopping QCC Servers from root QCC servers status /etc/init.d/qss_qcc_ctl status Status of servers for all instances Starting QCC servers /etc/init.d/qss_qcc_ctl start Starts servers for all instances Can be set to start automatically at boot Stopping QCC servers /etc/init.d/qss_qcc_ctl stop Stops servers for all instances Can be set to stop automatically at shutdown Change to the root user using: su - Use /etc/init.d/qss_qcc_ctl to check the status, stop, and start the QCC Servers. exit from root user 25

Starting/Stopping QCC Servers from qssmgr qcc_ctl manages servers for the current instance Status for all servers qcc_ctl status Status for a single server qcc_ctl status gl01 Start all servers qcc_ctl startall Start a single server qcc_ctl start gl01 Stop all servers qcc_ctl killall Stop a single server qcc_ctl kill gl01 Use qcc_ctl to check the status, stop, and start all QCC servers, stop and start a single server. qcc_ctl examples 26

sample setup of Accounts Payable Processing Logon as qssopr Scripts are in $QSS_DATA/cmd/opr apyextract extracts data to file in /home/qssopr apywarr prints warrants apyreport submits $QSS_DATA/jcl/apyrptst job to print reports apyupdate - updates database apysave saves production files from /home/qssopr to history directory $QSS_DATA/history/apy Process is customized for each client Runlevels Runlevels 0 halted system 1 single user mode 2 multi-user mode (not all processes running) 3 multi-user mode (full system) without X window system 4 multi-user mode (full system) with X windows system runnint 6 reboot 27

Runlevel Commands Use runlevel command to see current runlevel runlevel is configured in /etc/inittab by the id parm. Find the configured runlevel using the following command grep id: /etc/inittab Use init command to change runlevels Use Init 1 to perform some maintenance functions. (will be asked for the root password when runlevel 1 is reached) Stopping Linux Always use the shutdown command shutdown option when message shutdown h now shutdown r now turn server off reboot There is also a halt command If not shutdown correctly fschk will be run at next boot which may take additional time. Shutdown your workstation from tty1 while logged on as root after closing your terminal window and logging out the graphical desktop. 28