Ngkenzi 202367 Lab2oslinux
Ngkenzi 202367 Lab2oslinux
1. Task : Open a command line shell’s window in Linux GUI (KDE) interface:
Find the ‘terminal emulator’ (computer monitor) icon and double-click. The terminal emulator
(command prompt window) will appear. Type the command in the provided prompt (something
like ~$).
2. Task : Working with files touch command allows creating an empty file without editing.
Create two files named ‘a.txt’ and ‘b.txt’ in the current directory.
Use echo “sometext”. Print out the text ‘this is a text’ to the computer screen.
• type: echo “this is a text” echo command can be used to send (print) a text to file using
redirection operator (>). Send the text ‘this is a text’ to the file a.txt
• type: echo “this is a text” > a.txt.
You can add more content to the file using echo with redirection operator (>>)
Why don’t we use ‘>’ to add content to the non-empty file? Try it and observe. What happened
to the content of the file?
Because the > is used to send (print) a text to file using redirection operator but not to add
content
more and less command can be used to view the content of a file. View the content of the file
a.txt using more or less
How to copy the content of a.txt into b.txt using more command?
cp a.txt b.txt
(Tips: use ls –l to show attributes. Entries with directory types are specified with ‘d’ in the
beginning of a line e.g. ‘drwxr-x--- …’. The command displays the related information for the files
and directories, such as the permission, owner, timestamp of the file/directory created etc.)
• type: ls -a
• type: ls -l
To create directories, use the mkdir command. To change directories, use the cd command. To
move up one level in the directory structure, use the command cd ..
You can use the cp command to make a copy of a file, with a new name.
How to verify the new backup file and the original file are there?
To rename a file, you can use the mv command. Rename lab.doc to labfile.doc
• type: mv lab.doc labfile.doc
(Tips: The deletion process will skip the question if using –f switch (force) e.g. rm IT -fr )
Verify directory removal. Is the directory still exists? How do you know? No IT directory existing
A current process can be suspended by pressing Ctrl+Z (e.g. open an application and then
pressing Ctrl+Z will cause the application to stop and display the shell).
• type: vim this will run the vim text editor. Press Ctrl+Z.
8. Task : Exploring other commands Students are encouraged to search and practice other
commands that are provided by the command prompt shell to have more exposure to the shell
(search from the documentation, Internet, book etc), or study further the commands already
learned. Use man to get help about a specific command e.g. man ls or use -- help switch e.g. ls –
help , and answer the following question (answer either one):
Explain two new options/switches for any two commands that you have learned by showing
examples how you used the commands with the switches.
Su -h is a command used to display a lists of the commands.