ITEC 274: Linux 2 – Linux Command Line (Instructions) [70 pts]
[Name, course and section go here…]
Instructions
To get started, download and open the word document (274_Practice2_Linux_CommandLine.docx) attached to this exercise in BlackBoard / Assignments. You will submit your answers for this part of the practicum via this
word document
. No other documents or formats will be accepted. Submit via BlackBoard / Assignments.
Assignments without names will not be accepted/graded.
By now you should be familiar with our Linux VM and its GUI. We will explore the Linux command line. We will be running CentOS Linux within a virtual machine on your Windows (or Mac) computer. So, you will be running two operating systems (Linux and Windows or Mac) on your computer at the same time. You will need VMWare installed on your computer and you will need to download the CentOS Linux Virtual Machine. See Practicum 1, for more information about running the CentOS Linux virtual machine.
We will explore Linux using the command line. We will work thru file and directory management and look at system memory, cpu and process information.
Remember, unlike Windows, Linux is case-sensitive, meaning upper and lower case in filenames and commands is significant!
The commands you will work with include:
man |
rm |
cat /proc/meminfo |
ls |
cp |
cat /proc/cpuinfo |
cd |
mv |
df |
mkdir |
touch |
du |
pwd |
ps |
|
date |
cat |
*, ? wildcards |
1. Start your CentOS Linux VM (same one that you used for Linux 1 – refer to it for the login procedure).
· Start the CentOS Linux VM
· Log in to CentOS and get to the Linux Desktop
· Start Linux terminal (command line) by clicking on Terminal shortcut on Linux Desktop (if you do not see the Terminal shortcut on your Linux Desktop you can locate it in Applications / System Tools)
2. Using manual for Help with Linux Commands
· The man[ual] command with –k option allows you to search the Linux manual
· Use the man -k command to search the Linux manual and find the command to clear the screen (hint: man -k clear)
a. What command clears the terminal screen? Answer: ________________________
b. What does the ls command do? Explain what each of the following options of the ls command mean: -l, -a, -d
· Practice using the man -k command to search the Linux manual for other common commands/functions such as copying/renaming/deleting files
· Once you locate the specific command use the man command to get more specific information about that command
c. What command is used to copy a file? Answer: ________________________
a. What command is used to delete a file? Answer: ________________________
b. What command is used to delete a directory? Answer: ________________________
d. What does the command cp –n do? (what does the –n do?) Answer: ________________________
· Use the man command to explore the following commands: pwd, wc, cat, touch, df, du, find, sort, ps, kill, date
e. What does each of the above commands do?
pwd =
wc =
cat =
touch =
df =
du =
ps =
kill =
find =
sort =
date =
f. What is the current system date and time? Answer: ________________________
g. What command did you use to show the current system date and time? Answer: ________________________
· End the Linux command line session and return to the Linux Desktop
h. What command did you use to exit? Answer: ________________________
3. Working with files, directories and sub directories in Linux command line
· Start another Linux command line session – you will be placed in your home (~) directory
· Determine the actual path of your home (~) directory
a. What is the actual path of your home (~) directory? Answer: ________________________
b. What command did you use to find your home directory? Answer: ________________________
c. Show the contents of your home directory? (include permissions, file / directory names, size, date and time stamps) Answer: ________________________
Hint: use long option
[Paste a screen shot showing the contents of your home directory…] [2 pts]
d. What command did you use to show the contents of your home directory? Answer: ________________________
· Use a text editor (in Applications / Accessories) to create a text file containing
your name on line 1 and your course.section on line 2
· Name the file mytextfile.txt and be sure to put it in your home (~) directory
· Be sure to close the file you just created (and exit from the editor)
e. Show the contents of your home (~) directory now? (include the same detail as above)
[Paste a screen shot showing the new contents of your home directory…] [2 pts]
· Note that the d in the first character of each directory listing line indicates that the entry is a directory
If there is no d, then the entry is a file (such as mytextfile.txt)
f. What size (in bytes) is your mytextfile.txt? Answer: ________________________
g. What is the date/time stamp of your mytextfile.txt? Answer: ________________________
· Use wildcards to be more selective when working with files
* – represents zero or more characters
? – represents a single character
[ ] – represents a range of characters
For example
: ls –l *.txt lists all file with an extension of txt
ls –l MyFile?.txt lists all .txt files beginning with MyFile regardless of the 7th character in file name
…MyFile1.txt, MyFile2.txt, MyFileA.txt, etc.
h. Show the listing of all items in your home (~) directory that begin with Do
Note use –d option of ls command to show directory listing rather than directory contents
[Paste a screen shot showing the results…] [2 pts]
i. What command did you use to show the listing above? Answer: ________________________
j. Show the listing of all items in your home (~) directory in which the second letter of the name contains an i (lower case i)
[Paste a screen shot showing the results…] [2 pts]
k. What command did you use to show the listing above? Answer: ________________________
· Use the touch command to update date/time stamp of your mytextfile.txt
l. What command did you use to update the date/time stamp? Answer: ________________________
m. Show the directory listing with the updated date/time stamp on your listing of your mytextfile.txt
[Paste a screen shot showing the results…] [2 pts]
4. More with files and directories
Remember, unlike Windows, Linux is case-sensitive, meaning upper and lower case in filenames and commands is significant!
· Create a directory called ITEC274 in in your home (~) directory
a. What command(s) did you use to create the directory? Answer: ________________________
· Create a subdirectory called My274Files in the ITEC274 directory created above.
b. What command(s) did you use to create the directory? Answer: ________________________
· Copy the file mytextfile.txt (created earlier) to the ~/ITEC274/My274Files directory (use same file name)
c. What command(s) did you use to copy mytextfile.txt to ITEC274/My274Files? Answer: ________________________
· Use a text editor (in Applications / Accessories) to create a text file containing the following 2 lines of text:
This is line 1 of my text file called mytextfileA.txt
This is line 2 of my text file called myfiletextA.txt
· Name the file mytextfileA.txt and be sure to put it in the ~/ITEC274/My274Files directory (created above)
· Use a text editor (in Applications / Accessories) to create another text file containing the following 3 lines of text:
This is line 1 of my text file called mytextfileB.txt
This is line 2 of my text file called mytextfileB.txt
This is line 3 of my text file called mytextfileB.txt
· Name the file mytextfileB.txt and be sure to put it in the ~/ITEC274/My274Files directory (created above)
· Be sure to close the file(s) you just created (and exit from the editor)
d. Show the contents (files and contents) of your ~/ITEC274/My274Files directory
[Paste a screen shot showing the results…] [2 pts]
e. What size (in bytes) is your mytextfileA.txt and mytextfileB.txt? Answer: ________________________
f. What is the date/time stamp of your mytextfile.txt? Answer: ________________________
g. Who is the owner and what are the permissions for your mytextfile.txt? Answer: ________________________
· Display the contents of your mytextfile.txt file (created above)
h. What command(s) did you use to display contents of mytextfile.txt? Answer: ________________________
i. Show the results of displaying the contents of mytextfile.txt
[Paste a screen shot showing the results…] [2 pts]
· Concatenate mytextileA.txt & mytextfileB.txt and redirect output to a new file called mytextfileC.txt
j. What command(s) did you use to concatenate and create the new file? Answer: ________________________
k. Show the results of displaying the contents of mytextfileC.txt
[Paste a screen shot showing the results…] [2 pts]
· Create a subdirectory called My274Files2 in the ITEC274 directory
l. What command(s) did you use to create the directory? Answer: ________________________
· Copy the all files from your My274Files directory to the My274Files2 directory (use wildcards)
m. What command(s) did you use to copy the files? Answer: ________________________
n. Show the results of displaying the contents of your My274Files2 directory
[Paste a screen shot showing the results…] [2 pts]
· Rename the file ITEC274/My274Files/mytextfile.txt to mytextfile (without .txt)
o. What command(s) did you use to rename mytextfile.txt to mytextfile? Answer: ________________________
· Delete the file ITEC274/My274Files/mytextfileA.txt
p. What command(s) did you use to delete mytextfileA.txt? Answer: ________________________
q. Show the results of displaying the contents of your My274Files directory now
[Paste a screen shot showing the results…] [2 pts]
· Remove the My274Files directory
r. What command(s) did you use to remove the directory/subdirectories? Answer: ________________________
5. System CPU, memory, disk and process information
· Change to your home (~) directory
· Use the cat /proc/meminfo command to determine memory information about your Linux virtual machine
a. How much total memory does your virtual machine contain? Answer: ________________________
b. How free memory does your virtual machine contain? Answer: ________________________
· Use the cat /proc/cpuinfo command to determine CPU information about your Linux virtual machine
c. What is the model name of the processor in your Linux virtual machine? Answer: ________________________
d. What is the processor speed (MHz)? Answer: ________________________
e. How cache much memory does your virtual machine contain? Answer: ________________________
· Change to your home (~) directory
· Use the df command to determine the currently mounted file systems and their disk usage in your Linux virtual machine
f. How many files systems are currently mounted and what are their names? Answer: ________________________
g. What is the use percentage (%) for each file system in your virtual machine contain? Answer: ________________________
· Use the ps command to determine the current processes in your Linux virtual machine
h. How many processes are listed and what are their names? Answer: ________________________
6. Working with the system date/time
· Change to your home (~) directory
· Display the current system date and time
a. What is the current system date and time in your Linux virtual machine? Answer: ________________________
b. What command(s) did you use to display the current system date and time? Answer: ________________________
· Change the current system date to the date and time to 3:00pm on August 15th, 2023
(note use the – – set option)
c. Were you able to change the current system date? Answer: ________________________
a. If not, why? Answer: ________________________
· You should not have been able to change the system date because you are not a system administrator / root user! You wouldn’t want everyone on the system to be able to change the system date and time! To change the system date, you must be logged in as root user (sys admin).
· Log out and log back in as root user. Root username = root Password = york7800
|
|
|
|
· Start Linux Terminal (command line) as root user ((if you do not see the Terminal shortcut on your Linux Desktop you can locate it in Applications / System Tools)
|
|
|
|
|
|