0% found this document useful (0 votes)
36 views

CS5531 Virtual Lab 2 Fall 2023

This document outlines the objectives and steps for Virtual Lab #2. The objectives are to review accessing a Linux server, basic Linux commands, script command for recording user activity, file manipulation, and frequently used Linux/UNIX commands. Students are instructed to perform and record a series of Linux/UNIX operations using the script command, including logging in remotely, job control, environment variables, pipes, redirection, multiple commands, documentation tools, changing file modes, file management commands, processes commands, and miscellaneous useful commands. Students must save the script file as lab2_theirNETID.log, keep it under 5 pages, make sure it is pure text, and submit it before the due date and time. The

Uploaded by

chandra sekhar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

CS5531 Virtual Lab 2 Fall 2023

This document outlines the objectives and steps for Virtual Lab #2. The objectives are to review accessing a Linux server, basic Linux commands, script command for recording user activity, file manipulation, and frequently used Linux/UNIX commands. Students are instructed to perform and record a series of Linux/UNIX operations using the script command, including logging in remotely, job control, environment variables, pipes, redirection, multiple commands, documentation tools, changing file modes, file management commands, processes commands, and miscellaneous useful commands. Students must save the script file as lab2_theirNETID.log, keep it under 5 pages, make sure it is pure text, and submit it before the due date and time. The

Uploaded by

chandra sekhar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

CS5531: Advanced Operating Systems

Fall 2023
Virtual Lab #2
Max Points: 100

Name:

You may consult www.ss64.com/bash


(An A-Z Index of the Linux command line: bash + utilities)
UNIX AND LINUX COMMANDS REVISITED
OBJECTIVES:
The objectives of this laboratory exercise are to:
 Review the process of accessing a Linux server and working on a Linux-based virtual machine
 Review some basic Linux command
 Explore script command for recording user activity
 Review file manipulation
 Gain familiarity with most frequently used Linux/UNIX commands
 Explore BASH (Bourne Again Shell) environment
PRELIMINARIES
Perform and record the following Linux/UNIX operations, in the given order, in a log file using Linux
“script” command. (The script file need to be saved with .log file name extension)

STEP 1: INTRODUCTION TO BASH SHELL SCRIPTS COMMAND


This Lab is continued from Virtual Lab1. In the Lab work, we will be exploring a handful of tools we
believe to be the most critical for day-to-day work as Linux Systems Administrator (or regular user).
Specifically, we will be using BASH (Bourne Again Shell), which is a command line-only interface
containing a handful of built-in commands. For complete reference of BASH, please consult
www.ss64.com/bash.

1.1 Remote Login:


You may use ssh command to login Remote server
(practice this 1.1 section only if you have a valid username and password for a remote server)

1.2 Job Control


When working in the BASH environment, you can start multiple programs from the same prompt. For the
purpose of the Lab, you have to experiment with the following commands: nano & (for backgrounding a
job); jobs (to see how many jobs BASH is tracking); fg and bg command.

1.3 Environment Variables


If you are familiar with the concept of environment variables in Windows, you will find that many of the
things that you know about them will apply to Linux as well; the only difference is how they are set,
viewed, and removed.
Printing Environment Variables: printenv
Setting Environment Variables: variable = value
Then use export to pass the value to other processes
Unsetting Environment Variables: unset variable

1.4 Pipes
Pipes are mechanism by which the output of one program can be sent as the input to another program.
The vertical bar (|) character represents the pipe command. (ps –fe | less)

Page 1 of 3
1.5 Redirection
Through redirection (>), you can take the output of a program and have it automatically sent to a file.

Example: ls –lsa > dump.txt

To append additional data to an existing file use two > symbols (>>).

1.6 Multiple Commands


Under BASH, multiple commands can be executed on the same line by separating the commands with
semicolons (;). Since the shell is also a programming language, you can run command serially only if the
first command succeeds. Try && command to experiment with two commands by switching their position.

1.7 Documentation Tools


man
info

1.8 Files Change Mode: chmod


Letter Permission Value
r Read 4
w Write 2
x Execute 1

The following list shows the most common combinations of the three permissions:
Letter Permission Value
--- No permission 0
r-- Read only 4
rw- Read and write 6
rwx Read, write, and execute 7
r-x Read and execute 5
--x Execute only 1

1.9 File Management


Copy Files: cp
Remote copy: scp (secure copy)
The syntax for scp is: scp <SourceFile> <DestinationFile>

Note: Use of File Transfer Software like WinSCP, CyberDuck, FileZilla will maker the scp easier simply
by drag and drop to/from remote/local machine.

Move Files: mv (moving a file from one directory to another or changing name of a file. Unlike
copy (cp), move (mv) command removes the original file)

Link Files: ln
Find a File: find
Locate a File: locate
Concatenate Files: cat
Display a File One Screen at a Time: more
Disk Free: df; df -kh
Disk Utilization: du
Show the Directory Location of a File: which
Locate a Command: whereis

Page 2 of 3
1.10 PROCESSES

List Processes: ps; ps –fe; top


ps aux | sort –nrk 3,3 | head –n 5

Send a Signal to a Process: kill; kill -9

Show System Name: uname –r;


uname –rs (this command will let you know what is the OS Name and Kernel Version)

Who Is Logged In: who, logname


A Variation to who: w

1.11 Misc. Useful commands:


which sh
echo
sort –r
wc; wc -l
su
uptime
diff
lsusb
lsmod

STEP 2: ONCE YOU ARE SURE THAT ALL THE COMMANDS ARE OK

Perform and record the above Linux operations, in the given order (steps 1.1 … 1.11), in a log file using
Linux “script” command.

Directions
 No late assignments will be accepted!
 This work is to be done individually
 The script file will have to be saved with the name lab2_yourNETID.log
 You may at times use the editor gedit/emacs/vim/nano/pico etc.
 Make sure that the log file content is no more than 4-5 pages (by issuing the command wc -l and
check the number of lines, typically 50 lines are there in a page)
 Please make sure that the log file is pure text, there should NOT be any weird characters
 In case the output of a command will be very lengthy, you may use output redirection > to temp
text file so that the log file content will be less
 Assignment is due before Wednesday, September 6, 2023 by 11:59pm
 On or before the due time, drop the electronic copy of your work in the Canvas

Don’t forget to Turn in the file! Lab2_yourNETID.log

INTEGRITY CHECK
 Make sure the name of the script file conforms to the naming convention as mentioned in the Lab,
i.e., it should be Lab2YourNetID.log
 Make sure the log file content is NOT more than say 300 lines, i.e., 4~5 pages

Page 3 of 3

You might also like