OPERATING SYSTEMS LINUX

Similar documents
OPERATING SYSTEMS. Božo Krstajić, PhD, University of Montenegro Podgorica.

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

MANAGING THE NONUNIFORM BEHAVIOUR OF TERMINALS AND KEYBOARDS. : WHEN THINGS GO WRONG

Lab 2A> ADDING USERS in Linux

Introduction. What is Linux? What is the difference between a client and a server?

Linux Kung Fu. Ross Ventresca UBNetDef, Fall 2017

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

Course 144 Supplementary Materials. UNIX Fundamentals

CSE 265: System and Network Administration

CSE 265: System and Network Administration

The kernel is the low-level software that manages hardware, multitasks programs, etc.

CSE 265: System and Network Administration

Linux System Administration

User Accounts. The Passwd, Group, and Shadow Files

Stop all processes and then reboot - same as above startx. Log in as superuser from current login exit

CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

Basic Linux Security. Roman Bohuk University of Virginia

User & Group Administration

NETW 110 Lab 5 Creating and Assigning Users and Groups Page 1

UNIT V. Dr.T.Logeswari. Unix Shell Programming - Forouzan

CL030 is a csage Certification Preparatory Course!

Advanced Unix System Administration

Exam Linux-Praxis - 1 ( From )

Introduction to Linux

Certification. System Initialization and Services

Study Guide Processes & Job Control

Basic UNIX system administration

INTRODUCTION TO LINUX

Redhat Basic. Need. Your. What. Operation G U I D E. Technical Hand Note template version

The table below lists the domains measured by this examination and the extent to which they are represented in the examination.

System Administration. Startup Process

Booting up and Shutting down A primer for troubleshooting

Process Management forks, bombs, zombies, and daemons! Lecture 5, Hands-On Unix System Administration DeCal

Project #3: Implementing NIS

Everything about Linux User- and Filemanagement

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

More Raspian. An editor Configuration files Shell scripts Shell variables System admin

CST8207: GNU/Linux Operating Systems I Lab Seven Linux User and Group Management. Linux User and Group Management

Q) Q) What is Linux and why is it so popular? Answer - Linux is an operating system that uses UNIX like Operating system...

Presented by Bill Genske Gary Jackson

Linux Essentials Objectives Topics:

Installing Altiris Agent on Ubuntu

Exercise Sheet 2. (Classifications of Operating Systems)

Linux Kung-Fu. James Droste UBNetDef Fall 2016

User accounts and authorization

UNIX System Administration

14. Configuring Telnet in Knoppix

LAB #7 Linux Tutorial

TELE 301 Lecture 8: Post

Linux Systems Administration Getting Started with Linux

Answers to Even- Numbered Exercises

[ Terminal ] [ Users management ] Alt +F6 = Terminal switcher. useradd [option] JohnG

Install the Marionnet network simulator on Kali Linux Light vbox-i686

Chapter 5: User Management. Chapter 5 User Management

Authored by: Brian E. Brzezicki Copyright 2013, Paladin Group LLC Reuse without permission is strictly prohibited

CTEC1863/2018F Bonus Lab Page 1 of 5

Unit 2 System startup and shutdown

The Unix Shell & Shell Scripts

StormTracker EMS 2.3 Installation Instructions. Contents. Document Number EMS-A2-GN10-00 July 2002

CRUK cluster practical sessions (SLURM) Part I processes & scripts

Freescale FAE75 Training Genesi Pegasos II LinuxTraining. Maurie Ommerman June 10, 2004

GNU/Linux: An Essential Guide for Students Undertaking BLOSSOM

Programs. Program: Set of commands stored in a file Stored on disk Starting a program creates a process static Process: Program loaded in RAM dynamic

Linux Tutorial #6. -rw-r csce_user csce_user 20 Jan 4 09:15 list1.txt -rw-r csce_user csce_user 26 Jan 4 09:16 list2.

Linux Interview Questions and Answers

File System Hierarchy Standard (FHS)

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

Perl and R Scripting for Biologists

Commands are in black

Using grub to Boot various Operating Systems

RHCE BOOT CAMP. The Boot Process. Wednesday, November 28, 12

G54ADM Sample Exam Questions and Answers

CompTIA Exam LX0-102 Linux Part 2 Version: 10.0 [ Total Questions: 177 ]

More on file systems, Booting Todd Kelley CST8177 Todd Kelley 1

System Programming. Introduction to Unix

Bamuengine.com. Chapter 7. The Process

Contents in Detail. Acknowledgments

The Linux IPL Procedure

22-Sep CSCI 2132 Software Development Lecture 8: Shells, Processes, and Job Control. Faculty of Computer Science, Dalhousie University

HOW LINUX BOOTS. As it turns out, there isn t much to the boot process:

Some Ubuntu Practice...

Lab Authentication, Authorization, and Accounting

Users and Groups. his chapter is devoted to the Users and Groups module, which allows you to create and manage UNIX user accounts and UNIX groups.

List of Linux Commands in an IPm

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

HANDS UP IF YOU DON T HAVE A VM OR IF YOU DON T REMEMBER YOUR PASSWORDS. Or something broke

elinks, mail processes nice ps, pstree, top job control, jobs, fg, bg signals, kill, killall crontab, anacron, at

Start Up and Shutdown Procedures (Unix)

Ubuntu Practice and Configuration Post Installation Exercises interlab at AIT Bangkok, Thailand

Processes are subjects.

Runlevels, System Shutdown and Reboot

CSE 391 Lecture 3. bash shell continued: processes; multi-user systems; remote login; editors

10 userdel: deleting a user account 9. 1 Context Tune the user environment and system environment variables [3]

Using LINUX a BCMB/CHEM 8190 Tutorial Updated (1/17/12)

Adding users actions/mechanics

My Own Help On Unix Environment

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

HP-UX System Administration Course Overview. Skills Gained. Who will the Course Benefit?

Lab on User administration

Linux Reference Card - Command Summary

Transcription:

OPERATING SYSTEMS LINUX Božo Krstajić, PhD, University of Montenegro Podgorica bozok@cg.ac.yu

Process management Linux operating systems work with processes. Basically a process consists of program code (named text), data (used by a program) and a stack. The stack is used by the program to store variables. Programs are at least one process. You have control over all the processes that you start. A user can control a process by sending signals to the process.

Process management ps The ps command is used to report which processes are currently active. The ps without any parameters shows which processes are active in the current user session. $ ps PID TTY TIME CMD 1191 pts/2 00:00:00 bash 1216 pts/2 00:00:00 ps

Process management As you can see each process has a process ID (PID). All running processes are given a unique identifier (PID). On 2.2.x kernels, this process ID can be anywhere between 1 and 32767. You will need the process number if you want to send a signal to a process, for example a kill signal (for stopping process execution). The TTY column indicated which terminal the process is running on. The TIME column indicated how much CPU time the process has been running. Finally, the CMD column shows what the program actually is. It only lists the base name of the program, not any command line options.

Process management The ps has many parameters to modify the output. Have a look at the ps manual pages. You can get a complete listing of the processes running on your system using the right combination of options: ps ax There is a new column: STAT. It shows the status of the process. S stands for sleeping (the process is waiting for something to happen); R stands for running process. For example type and explain: ps aux

Process management kill The kill sends a signal to a process. If no signal is specified the TERM signal is send, which asks a process to exit gracefully. kill [ sig_numb] PID Example 1: Kill process which started with command mc ps x grep mc kill 1024 ps x grep mc

Process management The kill -l displays a list of signals that can be sent. The SIGKILL signal is often used to kill processes that refuse to terminate with the default SIGTERM signal. The signal can be specified by using the number as a parameter: kill -9 PID

Background processes Normally a process takes control over the screen and keyboard after it is started. Programs started from the command line start up in the foreground. It is also possible to start processes as a background process, this means that the shell starts the process, but keeps control over the terminal. In most shells a process can be started as a background process by placing an ampersand (&) after the command: command arguments &

Example 1 Create script file named EHO.sc which will: - Say : Hi, my friend. Type your name, surname and your personal ID, please: - Assign input values to the property variables. - Show on the screen entered data. - Reenter same data if they are wrong. - Say : Thanks. have nice day if they are correct. Start this script as background process.

function inp { Example 1 echo Type Your NAME, SURENAME nad pid read N S P echo Hi $N $S with your pid $P! } function qu { echo Is these date correct? [no/yes or Enter] read answer } inp qu if [ $answer = 'no' ];then inp else echo Thank, have nice day fi

Background processes A process that runs in the background can be brought to the foreground using the command: fg %<job ID> You can see which jobs are running, with their job numbers, using the jobs command. For example:./eho.sc & jobs fg %1

Stopping processes A process that is running can be stopped by pressing the <Control> and <z> keys simultaneously. Stopped processes can be moved to the foreground with the fg command. Running fg without any parameters moves the last process that was stopped to the foreground. Other processes can be moved to the foreground by specifying the job ID as a parameter to fg. A stopped process can also be told to continue as a background process, by executing bg <job ID>. Executing bg without any parameter will move the last stopped process to the background.

Process management Finally, there's a command you can use to display updating information about the processes running on the system. This command is called top, and is started like so: $ top This will display a full screen of information about the processes running on the system, as well as some overall information about the system.

Process management This includes: load average, number of processes, the CPU status, free memory information, and details about processes including PID, user, priority, CPU and memory usage information, running time, and program name. It's called top because the most CPU intensive programs will be listed at the top.

Essential System Administration -User management You are the administrator of any computers that you have root on. GNU/Linux is a multi-user operating system. This means that multiple users can use the system, and they can use the system simultaneously. First of all, there are several user accounts on each system. Users can be members of groups.

User management There are a few reserved users and groups on each system. The most important of these is the root account. The root user is the system administrator. The available user accounts are specified in the file: /etc/passwd. There are no passwords in this file. Passwords are kept in the separate /etc/shadow, as an encrypted string.

Default System User Names root The superuser account (UID=0) with unrestricted access. daemon Used for system processes. bin Owns executable sys Owns executable adm Owns accounting and log files uucp Used for UNIX to UNIX copy communication access and files

User management Information about groups is stored in /etc/group and /etc/gshadow. It is generally speaking not a good idea to edit these files directly. There are some excellent tools that can help you with user and group administration: adduser, userdel, passwd, groupadd, groupdel, groupmod,

adduser Adding and removing users The adduser command combines useradd and passwd in an interactive script. It will ask you to fill in information about the account to-be created. The screen listing below shows a sample session. # adduser

Adding and removing users Login name for new user []: john User ID ( UID ) [ defaults to next available ]: <Enter> Initial group [ users ]: <Enter> Additional groups (comma separated) []: <Enter> Home directory [ /home/john ] <Enter> Shell [ /bin/bash ] <Enter> Expiry date (YYYY-MM-DD) []: <Enter> New account will be created as follows: ---------------------------------------

Adding and removing users Login name...: john UID...: [ Next available ] Initial group...: users Additional groups: [ None ] Home directory...: /home/john Shell...: /bin/bash Expiry date...: [ Never ] This is it... if you want to bail out, hit Control-C. Otherwise, press ENTER to go ahead and make the account. <Enter>

Adding and removing users Creating new account... Changing the user information for john Enter the new value, or press ENTER for the default Full Name []: John Doe Room Number []: <Enter> Work Phone []: <Enter> Home Phone []: <Enter> Other []: <Enter>

Adding and removing users Changing password for john Enter the new password (minimum of 5, maximum of 127 characters) Please use a combination of upper and lower case letters and numbers. New password: password Re-enter new password: password

Change a password passwd The passwd command is used to set a password for a user. Running this command as a user without a parameter will change the password for this user. The password command will ask for the old password, once and twice for the new password: $ passwd The root user can set passwords for all users. The passwd command will only ask for the new password. # passwd username

userdel Remove a user account Linux offers the userdel tool to remove a user account. Just specify the username as a parameter to remove that user from the system. # userdel bob This will only remove the user account, not the user s home directory and mail spool. Just add the -r parameter to delete the user s home directory and mail spool too. # userdel -r bob

SU command It is a good idea to avoid logging in as root. There are many reasons for not doing this. Fortunately the su can give you temporal root privileges. Example: $ whoami bob $ su Password: # whoami root # exit $ whoami bob

Adding and removing groups The programs to add and remove groups are very simple: groupadd will just add another entry to the /etc/group file with a unique group ID, while groupdel will remove the specified group. You create a group like so: # groupadd cvs And remove it like so: # groupdel cvs

By hand Of course, it is possible to add, modify, and remove users and groups by hand. First, we'll add a new user to the /etc/passwd, /etc/shadow, and /etc/group files. After that use the passwd command to create a new password for the user. Finally, use mkdir to create the new user's home directory (/home/username or in the location you entered into the /etc/passwd file).

Example Find and show files:/etc/passwd, /etc/shadow, and /etc/group files. Check content of /home directory Add new user (stud1, users group) Again find and show files:/etc/passwd, /etc/shadow, and /etc/group files and notice diference. Check again content of /home directory. Change the new user password. Remove the new user account and home directory

Shutting Down Properly It is very important that the system is shut down properly. Simply turning the power off can cause serious filesystem damage. While the system is on, files are in use even if you aren't doing anything. Remember that there are many processes running in the background all the time. So, when you go to reboot or power down your computer, it is important to do so the right way.

Shutting Down Properly The first method is through the shutdown program, and it is probably the most popular. Basic usage of shutdown to turn off the computer is: # shutdown -h now (-h +60) Rebooting the system uses the same command, but substitutes -r for -h : # shutdown -r now The second way of shutting down or powering off the computer is to use the halt and reboot commands.

The /etc/rc.d directory The system initialization files are stored in the /etc/rc.d directory. Each task or runlevel is given its own rc file. There are several categories of initialization files: - system startup, - runlevels, - network initilization, - and System V compatibility.

System Startup The first program to run under Slackware besides the Linux kernel is init. This program reads the /etc/inittab file to see how to run the system. It runs the /etc/rc.d/rc.s script to prepare the system before going into your desired runlevel. The rc.s file enables your virtual memory, mounts your filesystems, cleans up certain log directories, initializes Plug and Play devices, loads kernel modules, configures PCMCIA devices, sets up serial ports, and runs System V init scripts (if found).

Runlevel Initialization Scripts After system initialization is complete, init moves on to runlevel initialization. A runlevel describes the state that your machine will be running in (the runlevel tells init if you will be accepting multiuser logins or just a single user, whether or not you want network services, and if you will be using the X Window, ). The files below define the different runlevels in Slackware Linux: rc.0 - Halt the system (runlevel 0). By default, this is symlinked to rc.6. rc.4 - Multiuser startup (runlevel 4), but in X11 with KDM, GDM, or XDM as the login manager.

Runlevel Initialization Scripts rc.6 - Reboot the system (runlevel 6). rc.k - Startup in single user mode (runlevel 1). rc.m - Multiuser mode (runlevels 2 and 3), but with the standard text-based login. This is the default runlevel in Slackware.

Network Initialization Runlevels 2, 3, and 4 will start up the network services. The following files are responsible for the network initialization: rc.inet1- Created by netconfig, this file is responsible for configuring the actual network interface. rc.inet2- Runs after rc.inet1 and starts up basic network services. rc.httpd- Starts up the Apache web server. rc.samba- Starts up Windows file and print sharing services. rc.news - Starts up the news server.

Other Files rc.cdrom - If enabled, this script will scan for a CD- ROM in a drive and mount it under /cdrom if it finds one. rc.gpm - Starts up general purpose mouse services. Allows you to copy and paste at the Linux console. rc.font - Loads the custom screen font for the console. rc.local - Contains any specific startup commands for your system. This is empty after a fresh install, as it is reserved for local administrators. This script is run after all other initialization has taken place.

Automatic: Enabling/disabling scripts To enable a script, all you need to do is add the execute permissions to it. To disable a script, remove the execute permissions from it. Manual: rc.name start rc.name stop

Networking configuration Drivers for NICs are installed as kernel modules. The module for your NIC has to be loaded during the initialization of Slackware Linux. On most systems the NIC is automatically detected and configured during the installation of Slackware Linux. You can reconfigure your NIC with the netconfig command. The netconfig adds the driver (module) for the detected card to /etc/rc.d/rc.netdevice. netconfig

Configuration of interfaces Network cards are available under Linux through socalled interfaces. The ifconfig command can be used to display the available interfaces details: # ifconfig a Network cards get the name ethn, in which n is a number, starting with 0. Interfaces can be configured in the /etc/rc.d/rc.inet1.conf file. You can simply read the comments, and fill in the required information.

Resolving Each computer on the internet has a hostname and IP address-. /etc/hosts is a table of IP addresses with associated hostnames. This file can be used to name computers in a small network. An example of the /etc/hosts file: 127.0.0.1 localhost 192.168.1.1 tazzy.slackfans.org tazzy 192.168.1.2 gideon.slackfans.org

Resolving The /etc/resolv.conf file is used to specify which nameservers the system should use. A nameserver converts hostnames to IP addresses. Your provider should have given you at least two nameserver addresses (DNS servers). You can add these nameservers to /etc/resolv.conf by adding the line nameserver ipaddress for each nameserver. For example: nameserver 192.168.1.1 nameserver 192.168.1.69

The internet super server There are two ways to offer TCP/IP services: by running server applications standalone as a daemon or by using the internet super server, inetd. The inetd is a daemon which monitors a range of ports. If a client attempts to connect to a port inetd handles the connection and forwards the connection to the server software which handles that kind of connection. The inetd can be configured using the /etc/inetd.conf file.

The internet super server For example: How loaded FTP server? Let s have a look at an example line (for FTP) from inetd.conf: # File Transfer Protocol (FTP) server: # ftp stream tcp nowait root /usr/sbin/tcpd proftpd This line specifies that inetd should accept FTP connections and pass them to tcpd. So, just remove # and reenable initd or reboot host!

Apache web server Apache is the most popular web server since 1996. Apache can be installed automatically by adding the apache package from the n disk set. After installing Apache it can be started automatically while booting the system by making the /etc/rc.d/rc.httpd file executable. The Apache configuration can be changed in the /etc/apache/httpd.conf file. Apache can be stopped/started/restarted every moment with the apachectl command, and the stop, start and restart parameters. For example, the command to restart Apache: # rc.httpd start/stop/restart # apachectl restart