Unix/Linux basics 0100 - user management Operating systems lab Gergely Windisch room 4.12

Slides:



Advertisements
Similar presentations
CST8177 awk. The awk program is not named after the sea-bird (that's auk), nor is it a cry from a parrot (awwwk!). It's the initials of the authors, Aho,
Advertisements

Linux commands exercise 1. What do you need, if you try to these at home? You need to download and install Ubuntu Linux from the Internet – DVD is need.
Unit 5 – User Administration Randy Marchany VA Tech Computing Center.
Linux Users and Groups Management
NETW-240 Shells Last Update Copyright Kenneth M. Chipps Ph.D. 1.
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.
User Accounts and Permissions Chapter IV / Part II.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Lecture 02CS311 – Operating Systems 1 1 CS311 – Lecture 02 Outline UNIX/Linux features – Redirection – pipes – Terminating a command – Running program.
Linux+ Guide to Linux Certification, Second Edition
L INUX C OMMAND L INE I NTERFACE G UNAANBAN.G
Linux Installation and Administration Lesson 2 Tutor: George Papamarkos.
1. This presentation covers :  User Interface Administration  Files System and Services Management 2.
Unix/Linux basics 0011 Operating systems lab Gergely Windisch room 4.12
MCB Lecture #3 Sept 2/14 Intro to UNIX terminal.
Advanced File Processing
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
Va-scanCopyright 2002, Marchany Unit 6 – Solaris File Security Randy Marchany VA Tech Computing Center.
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.
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.
Agenda User Profile File (.profile) –Keyword Shell Variables Linux (Unix) filters –Purpose –Commands: grep, sort, awk cut, tr, wc, spell.
Unix Talk #2 (sed). 2 You have learned…  Regular expressions, grep, & egrep  grep & egrep are tools used to search for text in a file  AWK -- powerful.
IT2204: Systems Administration I 1 6b). Introduction to Linux.
Module 4 - File Security. Security Overview File Ownership Access to Files and Dircetories Changing File and Directory Ownership Changing File and Directory.
INTRODUCTION TO LINUX Jacob Chan. GNU/Linux Consists of Linux kernel, GNU utilities, and open source and commercial applications Works like Unix –Multi-user.
Managing Users Objectives Contents Practicals Summary
Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command to search for.
Introduction to Bash Programming Ellen Zhang. Previous three classes What have we learnt so far ?
Chapter Five Advanced File Processing Guide To UNIX Using Linux Fourth Edition Chapter 5 Unix (34 slides)1 CTEC 110.
Chapter Five Advanced File Processing. 2 Objectives Use the pipe operator to redirect the output of one command to another command Use the grep command.
ITI-481: Unix Administration Meeting 3 Christopher Uriarte, Instructor Rutgers University Center for Applied Computing Technologies.
Agenda Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Review next lab assignments Break Out Problems.
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) 
There are three types of users in linux  System users: ?  Super user: ?  Normal users: ?
Managing Users  Each system has two kinds of users:  Superuser (root)  Regular user  Each user has his own username, password, and permissions that.
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.
Introduction to System Admin Sirak Kaewjamnong. 2 The system administration’s job  Adding a new user  Doing backup and restoring files from backups.
Chapter Five Advanced File Processing. 2 Lesson A Selecting, Manipulating, and Formatting Information.
Searching and Sorting. Why Use Data Files? There are many cases where the input to the program may come from a data file.Using data files in your programs.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification, Third Edition
Fall 2011 Nassau Community College ITE153 – Operating Systems Session 21 Administering User Accounts and Groups 1.
Week Two Agenda Announcements Link of the week Use of Virtual Machine Review week one lab assignment This week’s expected outcomes Next lab assignments.
Lesson 3-Touring Utilities and System Features. Overview Employing fundamental utilities. Linux terminal sessions. Managing input and output. Using special.
The Saigon CTT Chapter 10 Managing Users. The Saigon CTT  Objectives  Define the requirements for user accounts  Explain group and group accounts 
Manually Creating a New User Account Presented by Carl South.
© 2006 ITT Educational Services Inc. Linux Operating System :: Unit 3 :: Slide 1 Downloading and Installing Software yum pirut Bit Torrent rmp.
ITI-481: Unix Administration Meeting 3 Christopher Uriarte, Instructor Rutgers University Center for Applied Computing Technologies.
SCSC 455 Computer Security Chapter 3 User Security.
Lecture – Users and groups
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
SUSE Linux Enterprise Desktop Administration Chapter 9 Manage Users, Groups, and Permissions.
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.
Experiment No 4 Prepared by, Mr. Satish Pise. Objectives View the /etc/passwd file and describe its syntax. View the /etc/shadow file and describe its.
Tutorial of Unix Command & shell scriptS 5027
Linux 101 Training Module Linux Basics.
Chapter 11: Managing Users
Ubuntu Working in Terminal
Chapter 2 User Management
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Adding New Users, Storage, File System
Guide To UNIX Using Linux Third Edition
Tutorial of Unix Command & shell scriptS 5027
Tutorial Unix Command & Makefile CIS 5027
System & Network Administration (MCSA & RHCSA)
Module 13 System and User Security
Administering Users and Groups
Adding New Users.
Presentation transcript:

Unix/Linux basics user management Operating systems lab Gergely Windisch room

grep Do some basic pattern maching - search Search in files: grep 'string' filename cat filename | grep 'string' Will print only the lines where the given expression is found for example: list all the mp3 files in the current dir  ls -l | grep 'mp3' grep -v : negate the function - print when not present

grep useful switches:  v : negative search  h : when grepping multiple files, return the name of the actual file  i : case insensitive  w : look only for whole words  n : add the line number to the hit

Practice grep list all the mp3 files why does it list those files? – try ls -l | grep 'rw'

Regular expressions advanced pattern maching – looks ugly, but is useful – can find for example phone numbers in many formats: , , , (3630) , (06 30) (30) etc. – regexp can find all of these with one search we are not going into more details here. if interested: –

Regular expression and grep.. | grep 'mp3' - will list all lines containing mp3.. | grep '^mp3' - lists all lines starting with mp3.. | grep 'mp3$' - lists all lines ending with mp3.: could mean any character.. | grep 'm.3' []: one of the character inside.. | grep 'mp[34]' [-]: interval:.. | grep 'mp[g1-4]': mpg,mp1,mp2,mp3,mp4

Regexp practice List all the files in the current directory that start with a capital letter hint: ls -1 lists files in a column

grep exercise list only the directories and the symbolic links in the current directory

grep exercise solution ls -l. | grep '^[dl]'

grep exercise (2) There is a config file called /etc/debconf. It has settings and comments (which start with #). Get rid of all the comments, and save the rest in a new file.

grep exercise 2 solution cat /etc/debconf.conf | egrep -v '^#' > newfile

sed sed is an automated text processor will modify text files using pre-definied programs – takes one line at a time, and does everything we have told it to do with that line sed 'program ' inputfile > outputfile cat inputfile | sed 'program' How should we proceed if the input file is the same as the output?

sed (2) sed 'program' inputfile > inputfile (why not?) what is the output of ls -l? now type: ls -l > something – what goes into something? what is the output of ls -l now? what if we run ls -l > something again? what do we see? according to this, why shouldn't we use sed 'program' inputfile > inputfile?

sed commands man sed to get all the different commands tutorial está aquí: p: print current line – ls -l | sed 'p' - what happens? -n: no printing – ls -l | sed -n '4' - only print line 4 – ls -l | sed -n '1,5 p' - only print those lines

sed commands (2) d: delete lines. Works just like p – ls -l | sed '1,6 d' - print lines 7,8,9 etc. – One can use this to delete the lines from an file s: substitute – ls -l | sed s/hallgato/otheruser/ - first in line – ls -l | sed s/hallgato/otheruser/g - all of them – Separator can be other character as well sed s/ sed s!

sed exercise download the accountrc file from the website wget trc trc Write a shell script (one command) that changes the smtp server address from smtp.datanet.hu to sendmail.bmf.hu and back The result should go in the same file

sed exercise solution #!/bin/bash cat accountrc | sed s/” smtp.datanet.hu”/”sendmail.bmf.hu”/g > tempfile mv tempfile accountrc

Other commands cut: cut the output into columns – for example: list only the names of the groups in the system: cat /etc/group | cut -d: -f1 wc: word count. wc -l: number of lines – count the users: cat /etc/passwd | wc -l head, tail: print only the first (last) few lines – cat messages.log | tail tac: print contents of file backwards

excercise print the number of the users in the system

excercise print the number of the users in the system what about the inactive users? – (inactive users: who's line starts with #)

exercise 2 create a shell script that takes a file as an input parameter and returns the name of the owner.

exercise 3 create a shell script that takes a filename as an input parameter, and if the owner of this file is the hallgato user, then give the file to the root user (chown)

exercise 4 change the previous script so that it only gives the file to the root if the owner is the current user

exercise 5 modify the previous script so that it takes a second parameter which is the name of the user the file should be given to, but only give that user the file if the user exists on the system

Today's agenda - user management Users in the system Important files Adding users Role management

Users in unix (like operating systems) User name / User ID / Group ID Users are identified by the UID – Name is just for the humans UID 0 is the root - users with that number have the permissions Real users start at 1000 (on most systems) Pseudo users exist (1-999) Users can be part of multiple groups (primary and secondary groups)

Where are they stored? /etc/passwd - holds the users user-name:x:user-number:group-number:comment section:/home-directory:default-shell

Where are they stored? (2) /etc/group - holds the groups

Where are they stored? (3) /etc/shadow - holds the passwords – Used to be in /etc/passwd, but it is not secure – One line / user Login name:Encrypted password:Days since Jan 1, 1970 since password was last changed:Days before password can be changed:Days after it must be changed:Days before the expiration that the user is warned:Days after password expires and the user is disabled:Days since the password has been disabled

Important files and commands /etc/login.defs - default login options /etc/skel - default directory for new users

Modifying user accounts Modifying user accounts is simple - just modify the contents of /etc/passwd

Important commands Adding users – useradd, adduser, GUI tools, edit the passwd Passwords – passwd Deleting, modifying – userdel, usermod

Adding users with useradd (1) useradd is a command line tool to add users -mCreate a home directory in /home/ -MNo home directory created. -gSpecify the initial group for the user. -GSpecify the initial group for the user by using the group number. -sSpecify the default shell for the user. If not specified set to /bin/bash -eSpecify the expiration date. Format YYY-MM-DD -fNumber of days after a password expires that an account is disabled. By default this feature is disabled (-1) -uSpecify the user id number to be used.

Adding users with useradd (2) useradd user1 – create user (without settings) – check out what happens useradd -D – do not create, just print the defaults useradd -g group1 user3 – create user3, add it to group1 useradd -g group1 -G group2,group3 user4 – create user4, assign it to group1 and 2,3 as secondary

Running commands as others su - Start root shell (dangerous) sudo command visudo - edit the file pfexec in Solaris

Exercise 1 Create four users: alice, bob, cecilia and lajos (it is a fine hungarian name) The users should have full access to their home directories, and they should not have any access to each others' home dir, except for lajos who needs read permission for bob's home directory. Create a shared directory under /var/share. Make it accessible from each of the users' home directories. Set it up in a way so that only the owners of the files are able to delete the files inside the shared directory. Make this dir appear in the newly created accounts as well automatically.

Exercise 2 Write a shell script that can add users to the system. It should ask questions like "Username: ", "Group"… etc. The responses to the questions should be used to parametrize the commands necessary to create the new user. It needs to be foolproof - it should check if the username and the group name already exists, whehter the shell specified exists etc. Our good friend Bob has just gotten promoted to Enterprise Wide User Administrator (or EWUA). Your task is to create a new group for Bob called EWUA, set the system up so that he (and the members of that group) can use your previous script to add users to the system. He should not be able to run any other commands as root, just those that are necessary for being EUWA.

User management in Solaris Role based access control same files as in linux /etc/security holds roles

Exercise in solaris Create a new user, check his rights, assign a role to it and see it now