ADVANCED LINUX SYSTEM ADMINISTRATION

Similar documents
Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

5/20/2007. Touring Essential Programs

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

M.C.A. (Sem.-lll) (CBCS) Examination November CCA-3003 Operating System and LinuxlUnix programming

Commands are in black

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

Linux & Shell Programming 2014

The Unix Shell & Shell Scripts

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

CST Lab 2 Review #1

Introduction to the UNIX command line

Module 8 Pipes, Redirection and REGEX

Linux Shell Script. J. K. Mandal

Perl and R Scripting for Biologists

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

Introduction to remote command line Linux. Research Computing Team University of Birmingham

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

Unix Introduction to UNIX

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

ITST Searching, Extracting & Archiving Data

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

Computer Systems and Architecture

Computer Systems and Architecture

Command Line Interface The basics

A shell can be used in one of two ways:

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Exam Linux-Praxis - 1 ( From )

bash startup files Linux/Unix files stty Todd Kelley CST8207 Todd Kelley 1

Exercise Sheet 2. (Classifications of Operating Systems)

Introduction: What is Unix?

CSE II-Sem)

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

CSCI 2132 Software Development. Lecture 4: Files and Directories

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

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]

EECS2301. Lab 1 Winter 2016

Introduction to UNIX Shell Exercises

Linux Essentials Objectives Topics:

Basics. I think that the later is better.

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

Introduction to Linux Workshop 1

When talking about how to launch commands and other things that is to be typed into the terminal, the following syntax is used:

CENG393 Computer Networks Labwork 1

Appendix B WORKSHOP. SYS-ED/ Computer Education Techniques, Inc.

Lec 1 add-on: Linux Intro

CENG 334 Computer Networks. Laboratory I Linux Tutorial

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

CSE 390a Lecture 2. Exploring Shell Commands, Streams, Redirection, and Processes

A Big Step. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

Chapter 1 - Introduction. September 8, 2016

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

A Brief Introduction to the Linux Shell for Data Science

CISC 220 fall 2011, set 1: Linux basics

Part 1: Basic Commands/U3li3es

Lab 2: Linux/Unix shell

File permission u owner of file/directory (user) g group of the file/directory o other a all

C Shell Tutorial. Section 1

Scripting. Shell Scripts, I/O Redirection, Ownership and Permission Concepts, and Binary Numbers

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

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

Basic Unix Command. It is used to see the manual of the various command. It helps in selecting the correct options

Open up a terminal, make sure you are in your home directory, and run the command.

Getting your department account

CS 460 Linux Tutorial

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Files and Directories

Files (review) and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

Linux Interview Questions and Answers

CST Lab #5. Student Name: Student Number: Lab section:

CS160A EXERCISES-FILTERS2 Boyd

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

find starting-directory -name filename -user username

LOG ON TO LINUX AND LOG OFF

Essentials for Scientific Computing: Bash Shell Scripting Day 3

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

Unix/Linux Primer. Taras V. Pogorelov and Mike Hallock School of Chemical Sciences, University of Illinois

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

The UNIX Shells. Computer Center, CS, NCTU. How shell works. Unix shells. Fetch command Analyze Execute

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

Lecture # 2 Introduction to UNIX (Part 2)

Bioinformatics? Reads, assembly, annotation, comparative genomics and a bit of phylogeny.

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

2) clear :- It clears the terminal screen. Syntax :- clear

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

commandname flags arguments

Lab #2 Physics 91SI Spring 2013

Course 144 Supplementary Materials. UNIX Fundamentals

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

PESIT Bangalore South Campus

Practical 02. Bash & shell scripting

CSC209H Lecture 1. Dan Zingaro. January 7, 2015

Useful Unix Commands Cheat Sheet

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

UNIX and Linux Essentials Student Guide

unix intro Documentation

UNIX Essentials Featuring Solaris 10 Op System

UNIX files searching, and other interrogation techniques

UNIX ASSIGNMENT 1 TYBCA (Sem:V)

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

Transcription:

Lab Assignment 1 Corresponding to Topic 2, The Command Line L1 Main goals To get used to the command line. To gain basic skills with the system shell. To understand some of the basic tools of system administration. To start using Shell scripts for task automation. To keep a record of all the steps followed for solving these practical activities. Part 1: Command line 1) Using the system manual ($ man): a) Log in the system guest as user test. b) Write man man to obtain the help page of man. c) Press h to obtain the less pager help. 1 d) Exit the manual. e) Enter the manual again and try: I) Go to the beginning/end of the page. II) Move up and down one line and one screen. III) Look for a string, for example word. Search next and previous appearances. IV) Go to some specific line of the manual. 1 Must install less if not in the system (*). 1

2) Inside the user directory, create one directory named SI. Go inside it and check the absolute PATH of where it is (there is a correct command for this). Use the command cal (calendar) and redirect its standard output to a text file. Check if that file has been created: a) Check the content of the new file with the corresponding command. Copy that file to the personal user directory ($HOME). Remember that in the shell these commands can be edited. b) Once copied, delete original file and the directory previously created. Remember that the command line can be autocompleted with the appropriate key. c) Go to the user directory ($HOME) and list (in extended format, l) the directories and files included. Pipe the output to the cat and tee commands finding their differences (if they exist). d) List the 5 newest files (recently modified) in the /etc directory. e) Find which file is the most recent one of the system. f) Change the permission of the previously created file so that only you can access it in read and write mode. g) Avoid any other user accessing our personal directory. h) See how many users are in the system and check which one is yours. i) Check when and from where you last accessed the system. j) Analyze finger command using it with the test user. k) Create a.plan file ($HOME/.plan), indicating some kind of personal information. Check this information with the finger command. l) Check if the root user has unread mail and when he/she last accessed the system. Repeat with the test user. m) Execute the VI editor. Practice with it. Create a new file and write in it the following lines: echo -n Date:\ `date` cut -f1,3,2,6 -d" " echo -n I am:" " whoami cut -f1 -d " " This file will be a shell script and it might be executed in two ways: either through a Shell or directory (./) changing its execution permissions. 2

3) Open VI with no file. What does it show?: a) Exit. Copy /etc/passwd file in $HOME. b) Edit $HOME/passwd file. c) Use this file to practice the main basic and advanced commands to move around a file. (hjkl and others). d) Start with a file named vi_test. It must be created again. e) Write your name in the file. Save and exit. f) Open the file again and check its content. g) Add more names to the file. Move to the middle of the file and add a name upper line and another one in the lower line. h) Check combined movement (combined prefix): I) Move 3 lines down in a single movement. i) Try to delete a character, a line and a word of the file. j) Repeat the previous step with numerical prefixes: I) Delete until the end of a line. II) Delete from the beginning of a line. III) Delete two lines at a time. IV) Delete two words at a time. k) Repeat the previous step but change instead of delete. l) Cut the first line of the file and paste it at the end of the file. 3

4) Applications and commands in text mode: a) Compress in a.tar.gz file the /var. file. Place the created file in your $HOME. Check that this was done correctly uncompressing it in /tmp. b) As root, look for all the files that are property of the test user in the system (/) and list them in extended way. Do all this in the same command. c) As root again, show the last 30 lines of the /var/log/syslog file. 5) Download the file: www.ce.unican.es/ocw/si/grepdata.txt: a) Once you have the file, write a series of grep statements that do the following: I) Print all lines that contain a phone number with an extension (the letter x or X followed by four digits). II) Print all lines that begin with three digits followed by a blank. III) Print all lines that contain a date. Hint: this is a very simple pattern. It does not have to work for any year before 2000. IV) Print all lines containing a vowel (a, e, i, o, or u) followed by a single character followed by the same vowel again. Thus, it will find eve or adam but not vera. Hint: \( and \). V) Print all lines that do not begin with a capital S. b) Write grep statements that use command-line options along with the pattern to do the following: I) Print all lines that contain CA in either uppercase or lowercase. II) Print all lines that contain an email address (they have an @ in them), preceded by the line number. III) Print all lines that do not contain the word Sep. (including the period). 4

6) Execute in background the command that allows seeing all the files inside a directory recursively. Do it for the root directory / and its output will be redirected to a file name temp. If you need any help, remember to use the man command: a) Check if the process really exists. If it does kill it. b) Repeat the previous steps, but executing in the foreground. Stop the process. Then move the job to foreground again. Suspend it. Move it to the background. Finally kill it. c) Try to kill the INIT process. d) Look for all the processes in the system for which we are owners. e) Look for all the processes in the system for which neither us nor root are the owners. 7) Advanced commands: a) List the content of /etc/ directory and redirect stdout to a file called contetc.txt. b) Perform the following tasks: I) Create a reduced version of contetc.txt file, containing the following info for each line: [file/dir name] [size] [owner]. II) Sort the contents of the new file according to the field [name] and write result to file alphasorted.txt. Repeat the process in reverse order (antialphasorted.txt). III) Now sort contents according to the field [size] (numsorted.txt). IV) Finally, create a new file containing the first three characters of each file/directory name. c) Download the text file: www.ce.unican.es/ocw/si/aboutweb.txt. d) Perform the following modifications (through command line, do not use VI): I) Lines with <article> and </article> should be deleted. II) Replace <title> with Title:, and replace </title> with nothing. III) Replace all <para> and </para> tags with the null string. If the resulting line is empty, delete the line. (You may need to use curly braces to make this happen). IV) Replace all <emphasis> and </emphasis> tags with asterisks. V) Replace the word web with Web everywhere. VI) Replace lines starting with <listing> by ---begin listing. VII) Replace lines starting with </listing> by ---end listing. 5

Part 2: Shell Scripting 1) Write a Shell script called lsdirs.sh, which lists just the directories in the current directory. 2) Write a Shell script called see.sh taking a filename name as argument which uses ls if the file is a directory and more if not. 3) Write a script that asks the user to type a Word and then tells the user how long that Word is. 4) Write a script that asks the user to type a Word and checks if that is an available user command or not. 5) We will start this section creating a Shell script able to create a directory named trial, cd into it and then create 100 files named fich<num>.txt (where num is a number between 0 and 99). 6) Extend your script, so that the content of each file created corresponds to the n- th line of ls command manual (fich57.txt has the 57th line of man ls ). 7) Create a script able to change the extension of all.txt files to.t. 8) Create a script which takes an undefined number of parameters [0-9] and removes the file corresponding to the sum of all parameters. Example: borra.sh 1 3 5 6 2 removes the file fich17.txt (1 + 3 + 5 + 6 + 2 = 17). 9) Write a Shell script called sorter.sh that sorts the /etc/passwd file content using one of the following id as the key; Username, UID or GID. The identifier must be passed by command line. 10) Suppose that you want to write the same letter to many people (but personalized addressing). Write a file with all the desired recipients (one per line). Create a template textfile which has NAME wherever you want the person s name to appear. Create a mailmerge script that produces a personalized letter for each person in the list. 6