Nohup Sort Emp.Lst &

Total Page:16

File Type:pdf, Size:1020Kb

Nohup Sort Emp.Lst & Overview of Permission As Unix/linux is a multiuser operating system, every files is associated with permission. The permission determines whether a particular user or group have read, write or execute permissions or not. mywbut.com 1 Permission Types Four symbols are used when displaying permissions: r : permission to read a file or list a directory's contents w : permission to write to a file or create and remove files from a directory x : permission to execute a program or change into a directory and do a long listing of the directory - : no permission (in place of the r, w, or x) mywbut.com 2 Examining Permissions File permissions may be viewed using ls -l $ ls -l /bin/login -rwxr-xr-x 1 root root 19080 Apr 1 18:26 /bin/login File type and permissions represented by a 10- character string mywbut.com 3 Interpreting Permissions -rwxr-x--- 1 andersen trusted 2948 Oct 11 14:07 myscript Read, Write and Execute for the owner, andersen Read and Execute for members of the trusted group No access for all others mywbut.com 4 Changing File Ownership Only root can change a file's owner Only root or the owner can change a file's group Ownership is changed with chown: chown [-R] user_name file|directory Group-Ownership is changed with chgrp: chgrp [-R] group_name file|directory mywbut.com 5 Changing Permissions – Symbolic Method To change access modes: chmod [-R] mode file Where mode is: u,g or o for user, group and other + or - for grant or deny r, w or x for read, write and execute Examples: ugo+r: Grant read access to all o-wx: Deny write and execute to others mywbut.com 6 Changing Permissions – Numeric Method Uses a three-digit mode number first digit specifies owner's permissions second digit specifies group permissions third digit represents others' permissions Permissions are calculated by adding: 4 (for read) 2 (for write) 1 (for execute) Example: chmod 640 myfile mywbut.com 7 What is a Process? A process is a set of instructions loaded into memory Numeric Process ID (PID) used for identification UID, GID and SELinux context determines filesystem access Normally inherited from the executing user There are three distinct phases in the creation of a process using three important system calls. fork() exec() wait() mywbut.com 8 Listing Processes View Process information with ps Shows processes from the current terminal by default -a includes processes on all terminals -x includes processes not attached to terminals -u prints process owner information -f prints process parentage -o PROPERTY,... prints custom information: pid, comm, %cpu, %mem, state, tty, euser, ruser $ ps f : visual representation of process tree mywbut.com 9 init process and the login shell init is the system process which have a pid=1. init is the parent of almost all the processes in your unix or linux system. According to the classical theory , when the system startsup and moves to multiuser mode, init forks and execs a getty process at every port connected to a terminal. When a user attempts to login getty wakes up and execs a the login process to verify the login name and the password. Generally on successful login login fork and execs shell process, and getty and login have now extinguished them selves by overlaying mywbut.com 10 Sequence of process leading to shell init getty login shell The pid of the login shell is stored in a special variable $$ . To know the pid of the current login shell : $ echo $$ • The pid of your login shell does not change as long as you are logged in. When you log out and login again your login shell will be assigned a different pid. mywbut.com 11 Running jobs in background The & is the shells operator used to run a process in the background $ sort –o emp.lst emp.lst & The nohup (no hangup) command when prefixed to a command , permits the execution of the process even after the user has logged out. $ nohup sort emp.lst & mywbut.com 12 Job Control Run a process in the background Append an ampersand to the command line: firefox & Temporarily halt a running program Use Ctrl-z or send signal 17 (STOP) mywbut.com 13 Job Control To push a current foreground job to run in background First suspend the foreground job by pressing ctrl+z. Then use the bg command. To view list of jobs running in background use $ jobs To bring the most recent background jobs to the foreground use fg command fg %1 First job brought to foreground fg %sort Brings sort job to foreground bg %2 Sends second job to background mywbut.com 14 Finding Processes Most flexible: ps options | other commands ps axo comm,tty | grep ttyS0 By predefined patterns: pgrep $ pgrep -U root $ pgrep -G student By exact program name: pidof $ pidof bash mywbut.com 15 Signals A signal is an interrupt generated by the shell or even the another process in response to some error condition. This error condition can be a floating point exception, illegal instruction, memory violation or even the press of an interrupt key. A signal is represented by an integer that represents a particular event. The complete list of signals applicable to your machine can be found in the file /usr/include/sys/signal.h Sent directly to processes, no user-interface required Programs associate actions with each signal Signals are specified by name or number when sent mywbut.com 16 List of commonly used signal Signal Signal Function Number Name 1 SIGHUP Hangup- Modem connection is broken 2 SIGINT Terminal interrupt- user hits the interrupt key 3 SIGQUIT Quit from terminal 9 SIGKILL Surest kill – Can not be trapped 15 SIGTERM Default termination signal used by kill 17 SIGTSTP Suspend Process- User hits(ctrl+z) mywbut.com 17 Sending Signals to Processes By PID: kill [signal] pid ... By Name: killall [signal] comm … mywbut.com 18 Scheduling Priority Scheduling priority determines access to the CPU Priority is affected by a process‘s nice value Values range from -20 to 19 but default to 0 Lower nice value means higher CPU priority Viewed with ps -o comm,nice mywbut.com 19 Altering Scheduling Priority Nice values may be altered... When starting a process: $ nice -n 5 command After starting: $ renice 5 PID Only root may decrease nice values mywbut.com 20 Interactive Process Management Tools CLI: top GUI: gnome-system-monitor Capabilities Display real-time process information Allow sorting, killing and re-nicing mywbut.com 21 Scheduling a Process to Execute Later One-time jobs use at, recurring jobs use crontab mywbut.com 22 At and batch Command The at and batch command provides a mechanism to schedule less urgent jobs at a time when the system overheads are low. The at command takes its argument the time the job is to be executed. $ at 14:02 abc.sh [ctrl-D] The batch command also schedules jobs for latter execution, but unlike at jobs are executed as soon as the system load permits $ batch < abc.sh mywbut.com 23 Scheduling System Tasks using at The at facility is designed to run jobs at specific times. Jobs you submit are spooled in the directory /var/spool/at, awaiting execution by the at daemon atd. The file /etc/at.allow contains a list of users who are granted access, and the file /etc/at.deny contains a similar list of those who may not submit at jobs mywbut.com 24 Viewing scheduled jobs You can use the atq command (effectively the same as at -l) to view a list of your pending jobs in the at queue, showing each job’s sequence number, the date and time the job is scheduled to run, and the queue in which the job is being run. mywbut.com 25 Deleting scheduled jobs If you decide that you’d like to cancel a particular job, you can use the atrm command (equivalent to at -d) with the job number (or more than one) as reported by the atq command. mywbut.com 26 Cron Running jobs periodically Another way to run commands unattended is via the cron facility The file /etc/cron.allow contains a list of users who are granted access, and the file /etc/cron.deny contains a similar list of those who may not submit cron jobs. If neither file exists (or if cron.deny is empty), all users are granted access to cron. mywbut.com 27 Cron Running jobs periodically There are four places where a job can be submitted for execution by the cron daemon crond: The /var/spool/cron/username file — This method, where each individual user (indicated by username) controls his or her own separate file, is the method used on UNIX System V systems. The /etc/crontab file — This is referred to as the system crontab file, and was the original crontab file from BSD UNIX and its derivatives. Only root has permission to modify this file. The /etc/cron.d directory — Files placed in this directory have the same format as the /etc/crontab file. Only root is permitted to create or modify files in this directory. The /etc/cron.hourly, /etc/cron.daily, /etc/cron.weekly, and /etc/cron.monthly directories — Each file in these directories is a shell script that runs at the times specified in the /etc/crontab file (by default, at one minute after the hour every hour; at 4:02 a.m. every day; Sunday at 4:22 a.m.; and 4:42 a.m. on the first day of the month, respectively).
Recommended publications
  • Systems Programming II
    Systems Programming II Iqbal Mohomed CSC 209 – Summer 2004 Week 7 Motivation for Signals • When a program forks into 2 or more processes, rarely do they execute independently of each other • The processes usually require some form of synchronization, and this is typically handled using signals. Job control is another important use • Data usually needs to be passed between processes also, and this is typically handled using pipes and sockets, which we will discuss shortly • Signals are usually generated by – Machine interrupts – The program itself, other programs, or the user (i.e. from the keyboard) Introduction to Signals • When a C program receives a signal, control is immediately passed to a function called a signal handler • The signal handler function can execute some C statements and exit in three different ways: – Return control to the place in the program which was executing when the signal occurred – Return control to some other point in the program – Terminate the program by calling the exit (or _exit) function signal() • A default action is provided for each kind of signal, such as terminate, stop or ignore • For nearly all signal types, the default action can be changed using the signal() function. The exceptions are SIGKILL and SIGSTOP. The handler is defined as follows: – typedef void (*sighandler_t)(int); • To change the handler: – sighandler_t signal(int signum, sighandler_t handler); More on signal() • For each process, the OS maintains a table of actions that should be performed for each kind of signal. The signal() function changes the table entry for the signal named as the first argument to the value provided as the second argument.
    [Show full text]
  • Job Scheduling for SAP® Contents at a Glance
    Kees Verruijt, Arnoud Roebers, Anjo de Heus Job Scheduling for SAP® Contents at a Glance Foreword ............................................................................ 13 Preface ............................................................................... 15 1 General Job Scheduling ...................................................... 19 2 Decentralized SAP Job Scheduling .................................... 61 3 SAP Job Scheduling Interfaces .......................................... 111 4 Centralized SAP Job Scheduling ........................................ 125 5 Introduction to SAP Central Job Scheduling by Redwood ... 163 6Installation......................................................................... 183 7 Principles and Processes .................................................... 199 8Operation........................................................................... 237 9Customer Cases................................................................. 281 The Authors ........................................................................ 295 Index .................................................................................. 297 Contents Foreword ............................................................................................... 13 Preface ................................................................................................... 15 1 General Job Scheduling ...................................................... 19 1.1 Organizational Uses of Job Scheduling ..................................
    [Show full text]
  • Unix System Programming Overview Outline What Is a Signal? Signal
    Overview Last Week: ● How to program UNIX processes (Chapters 7-9) ● fork() and exec() Unix System Programming This Week, and next week: ● UNIX inter-process communication mechanisms: signals, Signals » (next week) pipes and FIFOs. ● How to program with UNIX signals (Chapter 10) » http://en.wikipedia.org/wiki/Unix_signal ● Non-local jumps (Chapter 7) ● Focus on the sigaction() function Maria Hybinette, UGA 1 Maria Hybinette, UGA 2 Outline What is a Signal? ● A signal is an asynchronous event which is ● What is a UNIX signal? delivered to a process (instantiated by a small message) ● Signal types ● Asynchronous means that the event can occur ● Generating signals at any time (e.g., posting at a bulletin board ) ● Responding to a signal » may be unrelated to the execution of the process ● Common uses of a signal – e.g., user types Ctrl-C, or the modem hangs (SIGINT) ● Implementing a read() time-out – e.g,, user types Ctrl-Z (SIGTSTP) ● Sent from kernel (e.g. detects divide by zero ● Non-local jumps setjmp()/longjmp() (SIGFPE) or could be at the request of another ● POSIX signals process to send to another) ● Interrupted system calls ● Only information that a signal carries is its ● System calls inside handlers unique ID and that it arrived Maria Hybinette, UGA 3 Maria Hybinette, UGA 4 Signal Types (31 in POSIX) Signal Sources terminal memory ID Name Description Default Action driver management shell command 2 SIGINT Interrupt from keyboard (^C) terminate Ctr-C SIGINT SIGHUP 3 SIGQUIT Quit from keyboard (^\) terminate & core SIGSEGV 9 SIGKILL
    [Show full text]
  • POSIX Signals
    CSE 410: Systems Programming POSIX Signals Ethan Blanton Department of Computer Science and Engineering University at Buffalo Introduction Signals Blocking Concurrency Sending Signals Summary References POSIX Signals POSIX signals are another form of interprocess communication. They are also a way to create concurrency in programs. For these two reasons, they are rather complicated and subtle! Signals provide a simple message passing mechanism. © 2018 Ethan Blanton / CSE 410: Systems Programming Introduction Signals Blocking Concurrency Sending Signals Summary References Signals as Messages POSIX signals are asynchronous messages. Asynchronous means that their reception can occur at any time.1 The message is the reception of the signal itself. Each signal has a number, which is a small integer. POSIX signals carry no other data. 1Almost. We’ll see how to control it later. © 2018 Ethan Blanton / CSE 410: Systems Programming Introduction Signals Blocking Concurrency Sending Signals Summary References Signal Types There are two basic types of POSIX signals: Reliable signals Real-time signals Real-time signals are much more complicated. In particular, they can carry data. We will discuss only reliable signals in this lecture. © 2018 Ethan Blanton / CSE 410: Systems Programming Introduction Signals Blocking Concurrency Sending Signals Summary References Asynchronous Reception From the point of view of the application: Signals can be blocked or ignored Enabled signals may be received between any two processor instructions A received signal can run a user-defined function called a signal handler This means that enabled signals and program code must very carefully manipulate shared or global data! © 2018 Ethan Blanton / CSE 410: Systems Programming Introduction Signals Blocking Concurrency Sending Signals Summary References Signals POSIX defines a number of signals by name and number.
    [Show full text]
  • Linux Hardening Techniques Vasudev Baldwa Ubnetdef, Spring 2021 Agenda
    Linux Hardening Techniques Vasudev Baldwa UBNetDef, Spring 2021 Agenda 1. What is Systems Hardening? 2. Basic Principles 3. Updates & Encryption 4. Monitoring 5. Services 6. Firewalls 7. Logging What is System Hardening? ⬡ A collection of tools, techniques, and best practices to reduce vulnerability in technology applications, systems, infrastructure, firmware, and other areas ⬡ 3 major areas: OS vs Software vs Network ⬠ When have we done hardening in this class before? ⬠ This lecture is focusing mostly on OS and software level Why Harden? ⬡ Firewalls can only get us so far, what happens when at attack is inside the network? ⬠ If you have nothing protecting your systems you are in trouble ⬡ We want some kind of secondary protection A Few Cybersecurity Principles ⬡ Zero Trust Security ⬠ Instead of assuming everything behind the firewall is safe, Zero Trust verifies each request as though it originates from an unsecure network ⬡ Principle of Least Privilege ⬠ Only privileges needed to complete a task should be allowed ⬠ Users should not have domain administrator/root privileges ⬡ Principle of Least Common Mechanism ⬠ Mechanisms used to access resources should not be shared in order to avoid the transmission of data. ⬠ Shared resources should not be used to access resources The Threat Model ⬡ A process by which potential threats can be identified and prioritized. ⬠ If you have a web server that feeds input to a mysql database, then protecting against mysql injections would be prioritized in your model. 2 considerations ⬡ *nix like is a very
    [Show full text]
  • Programming with POSIX Threads II
    Programming with POSIX Threads II CS 167 IV–1 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Global Variables int IOfunc( ) { extern int errno; ... if (write(fd, buffer, size) == –1) { if (errno == EIO) fprintf(stderr, "IO problems ...\n"); ... return(0); } ... } CS 167 IV–2 Copyright © 2008 Thomas W. Doeppner. All rights reserved. Unix was not designed with multithreaded programming in mind. A good example of the implications of this is the manner in which error codes for failed system calls are made available to a program: if a system call fails, it returns –1 and the error code is stored in the global variable errno. Though this is not all that bad for single-threaded programs, it is plain wrong for multithreaded programs. Coping • Fix Unix’s C/system-call interface • Make errno refer to a different location in each thread – e.g. #define errno __errno(thread_ID) CS 167 IV–3 Copyright © 2008 Thomas W. Doeppner. All rights reserved. The ideal way to solve the “errno problem” would be to redesign the C/system-call interface: system calls should return only an error code. Anything else to be returned should be returned via result parameters. (This is how things are done in Windows NT.) Unfortunately, this is not possible (it would break pretty much every Unix program in existence). So we are stuck with errno. What can we do to make errno coexist with multithreaded programming? What would help would be to arrange, somehow, that each thread has its own private copy of errno. I.e., whenever a thread refers to errno, it refers to a different location from any other thread when it refers to errno.
    [Show full text]
  • POSIX Signal Handling in Java
    Technical Document Series POSIX Signal Handling in Java POSIX Signal Handling In Java Introduction POSIX signals inform a running process of external events, such as the user wishing to kill the process, or the operating system signaling an impending shutdown, or the process being suspended or reinstated; or the process may have violated a resource constraint, such as excessive CPU usage or attempts to access areas outside its permitted memory space, and is asked to shutdown. In short, POSIX signals serve many different purposes. Some are even up to interpretation, such as the HUP (HangUP) signal, which is commonly used to inform a process that something about its environment has changed and the process should adjust accordingly. Some programs may interpret this to mean that the configuration has changed and needs to be reloaded; or the log file has been moved for archiving purposes and a new one should be started. The use of signals is widespread, especially on Unix-based operating systems, but Java provides no standard interface for a Java application to hear and react to them. This document shows you how to get around this limitation. The Good, the Bad, and the Ugly The good news is that there is a way to intercept POSIX signals and react to them in Java. This would allow your Java program to avoid being killable with ^C (SIGINT), for example, even ignore termination requests from the operating system (SIGTERM). Neither of these is necessarily a good idea, of course, unless you know exactly why you would want to catch these signals and either handle them yourself or ignore them altogether.
    [Show full text]
  • Processes and Job Control
    Processes and Job Control Hour 17 PObjectives < Definitions: process, orphan, and zombie < System processes < Process creation < Examining processes: the ps command < Job control: &, nohup, fg, bg, jobs, ( ), and kill < Exit status Copyright © 1998-2002 Delroy A. Brinkerhoff. All Rights Reserved. Hour 17 Unix Slide 1 of 12 Process Also called a job by C and Korn shells PWhen a program or executable file is loaded from disk and started running (i.e., when a command is run), it is called a process vi pid 641 < identified by a unique process ID (PID) number < has an owner vi < private data vi PA program can be loaded more than once pid 895 < creates multiple processes vi < each process has a different PID < each process may have a different owner PPIDs are unique, nonnegative integers < numbers recycle without collisions Hour 17 Unix Slide 2 of 12 System Processes Processes created during system boot P0System kernel < “hand crafted” at boot < called swap in older versions (swaps the CPU between processes) < called sched in newer versions (schedules processes) < creates process 1 P1 init (the parent of all processes except process 0) < general process spawner < begins building locale-related environment < sets or changes the system run-level P2 page daemon (pageout on most systems) P3 file system flusher (fsflush) Hour 17 Unix Slide 3 of 12 Process Life Cycle Overview of creating new processes fork init init pid 467 Pfork creates two identical pid 1 exec processes (parent and child) getty pid 467 Pexec < replaces the process’s instructions
    [Show full text]
  • Installation Guide
    Installation Guide Installation Guide Schrödinger Suite 2011 Schrödinger Press Installation Guide Copyright © 2011 Schrödinger, LLC. All rights reserved. While care has been taken in the preparation of this publication, Schrödinger assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Canvas, CombiGlide, ConfGen, Epik, Glide, Impact, Jaguar, Liaison, LigPrep, Maestro, Phase, Prime, PrimeX, QikProp, QikFit, QikSim, QSite, SiteMap, Strike, and WaterMap are trademarks of Schrödinger, LLC. Schrödinger and MacroModel are registered trademarks of Schrödinger, LLC. MCPRO is a trademark of William L. Jorgensen. Desmond is a trademark of D. E. Shaw Research. Desmond is used with the permission of D. E. Shaw Research. All rights reserved. This publication may contain the trademarks of other companies. Schrödinger software includes software and libraries provided by third parties. For details of the copyrights, and terms and conditions associated with such included third party software, see the Legal Notices, or use your browser to open $SCHRODINGER/docs/html/third_party_legal.html (Linux OS) or %SCHRODINGER%\docs\html\third_party_legal.html (Windows OS). This publication may refer to other third party software not included in or with Schrödinger software ("such other third party software"), and provide links to third party Web sites ("linked sites"). References to such other third party software or linked sites do not constitute an endorsement by Schrödinger, LLC. Use of such other third party software and linked sites may be subject to third party license agreements and fees. Schrödinger, LLC and its affiliates have no responsibility or liability, directly or indirectly, for such other third party software and linked sites, or for damage resulting from the use thereof.
    [Show full text]
  • CA Workload Automation Ixp Admin Guide
    CA Workload Automation iXp Administration Guide Release 7.1 SP1 This Documentation, which includes embedded help systems and electronically distributed materials, (hereinafter referred to as the “Documentation”) is for your informational purposes only and is subject to change or withdrawal by CA at any time. This Documentation may not be copied, transferred, reproduced, disclosed, modified or duplicated, in whole or in part, without the prior written consent of CA. This Documentation is confidential and proprietary information of CA and may not be disclosed by you or used for any purpose other than as may be permitted in (i) a separate agreement between you and CA governing your use of the CA software to which the Documentation relates; or (ii) a separate confidentiality agreement between you and CA. Notwithstanding the foregoing, if you are a licensed user of the software product(s) addressed in the Documentation, you may print or otherwise make available a reasonable number of copies of the Documentation for internal use by you and your employees in connection with that software, provided that all CA copyright notices and legends are affixed to each reproduced copy. The right to print or otherwise make available copies of the Documentation is limited to the period during which the applicable license for such software remains in full force and effect. Should the license terminate for any reason, it is your responsibility to certify in writing to CA that all copies and partial copies of the Documentation have been returned to CA or destroyed. TO THE EXTENT PERMITTED BY APPLICABLE LAW, CA PROVIDES THIS DOCUMENTATION “AS IS” WITHOUT WARRANTY OF ANY KIND, INCLUDING WITHOUT LIMITATION, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT.
    [Show full text]
  • HP-UX Fundamentals
    Contact Us: (616) 875-4060 HP-UX Essentials Course Summary Length: 3 Days Prerequisite: Basic computer skills Recommendation Statement: Student should be able to use a computer monitor, keyboard, mouse. Student needs to be able to input commands and control characters from a keyboard. Course Description: For those new to HP-UX, this is the first course you will take. The course starts at the beginner level and works into intermediate and advanced HP-UX commands and utilities. The student is introduced to the HP-UX Korn shell, the command line and command syntax. Although you will be exposed to the various windowing platforms available in HP-UX, this course teaches UNIX at “the command line level” to develop a thorough understanding of the HP-UX operating environment. The student learns how to navigate the HP-UX file systems and how to work with files, directories and permissions. The student will learn how to use the HP-UX editors “ex” and “vi. “ Once the student is comfortable with basic HP-UX commands, they’ll move onto advanced power tools as well as how to customize the POSIX Korn shell. The classroom labs are run in a real-world UNIX environment, are structured to allow you to learn by doing, and are developed to simulate “real world” situations. The hands-on labs progressively build your HP-UX knowledge and command skills in a clear and concise manner. Working in a controlled UNIX classroom environment with an expert instructor, you will learn HP-UX concepts and commands. You will receive professional tips and techniques that will help you build your HP-UX confidence and skills.
    [Show full text]
  • Full Workload
    Command Line: Process Control C@ELOLJ<I GifZ\jjXe[afYZfekifc =LCCNFIBCF8; !Qn\`Ycld#g_fkfZXj\%Zfd What is happening on your Linux machine? Various shell commands All of these parameters can be com- bined – for example, pstree -apu. give you details about system processes and help you control them. C`jk`e^GifZ\jj\jn`k_gj BY HEIKE JURZIK The ps command gives you a list of the processes currently running on your sys- henever you or an application ing. All other processes share this com- tem. If you do not specify any command- launch a program, the operat- mon “ancestor” – init starts the operat- line parameters, the tool will restrict the Ning system starts one or multi- ing system’s basic programs. pstree list to the current shell. If you are inter- ple processes. These processes can enter shows the relationship between “parent” ested in all of your processes, call ps various states: They can be processed, and “child” processes. This tree struc- with the x option (Listing 1). stopped, restarted, and – under normal ture shows you at a glance who is de- The tabular output in the shell tells circumstances – stopped again. Linux scended from whom (Figure 1). you the following characteristics: has something similar to access controls ฀ PID: The process identifier, a unique for processes: Only the user that started 8[[`k`feXcFlkglk number that you can use to reference a process can stop, restart, or terminate The tool gives you more detailed output a process individually. the process. if you set the -a flag. This tells pstree to ฀ TTY: The terminal or console on The only exception to this rule is the show you, in addition, the parameters which the process was started.
    [Show full text]