Description
The Command Line
File Packaging
There are many times that you will find yourself needing to package or compress (or unpackage and uncompress) files while working on projects. TAR (originally Tape Archive – packs / creates an archive) and Gzip (GNU zip) are two commonly used tools in Unix based operating systems. To familiarize yourself with these commands and how they work, complete the following and take a screenshot:
- Create a file (e.g., “somefile.txt”) using a text editor (e.g. nano)
- Use gzip to compress the file, yielding a gzipped file (“somefile.txt.gz”)
- Use gunzip to decompress the file, yielding the original file (“somefile.txt”)
- Create a second file (“other.txt”)
- Create an archive from both files (“somefile.txt” & “other.txt”), yielding “myfiles.tar” (tar -cvf)
- Extract the files from the archive (tar -xvf)
- Create a new file (“somefile2.txt”)
- Create an archive file from all three text files piped through gzip to create a “.tar.gz” (tar -zcvf)
- Type “ls” to view the current directory and your “.tar.gz”
- Unzip and Extract the “.tar.gz” (tar -xzvf)
- Type “ls” to view the current directory and your extracted file.
- Take a screenshot of the commands run in steps 7) through 11).
Terminal Navigation
The navigation exercise can be completed by following these steps, including taking two screenshots (see step 4):
- Create a folder with the name format last_first (e.g., “sanchez_richard”) in /home/reptilian.
- Issue a command to find files that contain the phrase “android_dev” from the kernel source directory.
- Reissue the command from (2); this time, pipe the output of the command to a text file named “txt”. 4) Take a screenshot of the command in 3) and another with a listing of the directory of the first file from 2). 5) Move or copy “ex1.txt” into the directory created in (1).
- From /home/reptilian, create a tar file named tar of the directory from (1) (including contents).
- Use gzip to compress tar (yielding ex1.tar.gz).
- Create “7”, describing steps 1-7, using a text editor (e.g. nano). (See https://liw.fi/manpages/) 9) From your local command line, use sftp to transfer the files created in (7) and (8) back to your local host.
Package Installation
Sometimes you’ll need to install new packages from within a Linux system. On Debian-derived distributions, you can use the apt command for this. Here an example to install the man utility:
$ sudo apt install man
Once installed, you can use man to view manual pages.
File Transfer
You will need to use the local Unix shell (on Windows, via WSL or MSYS) to execute the sftp command in order to transfer files from the virtual machine to the local host:
$ sftp [email protected] Replace with VM IP address
Once connected, you can issue the “help” command from wi
Command Line Cheat Sheet
Shell Specific cd DIRECTORY changes to specified directory
Examples (from /home/)
cd reptilian changes to /home/reptilian cd .. changes to parent directory (/) cd ~ changes to user’s home directory (/home/reptilian/)
There is no man page for cd because it is built into the command shell.
General Commands
If you are confused about how a command works, you can view the manual page with the man command:
man COMMAND display the manual for the specified command
Example
man man displays the manual for the man command
The following commands have man pages that will provide more information and correct syntax:
ls Lists all of the files located in the current directory. clear Clears the terminal. Use this if your terminal becomes cluttered.
mv Move a file or folder from one location to another. Can also be used to rename files cp Copy a file or folder to a different location. mkdir Creates directory. rmdir Removes directory. rm Removes file(s). locate Find a file within your OS. tar Zip or unzip files via command line.
grep Searches files in plain-text for a matching expression. gzip Compress a file using the gzip compression routine find Locates files. pwd Prints the absolute location of the current directory. nano Brings up text editor for file creation or file editing.





