Lab 5

For each of the following commands write a description of what it does and provide a screenshot with an example of its usage.


apt–get update — command used to update the system packages from the repository.

If you just enter ‘apt-get updates’ the terminal will state that you do not have permission. Before you do an update, you must have superuser permission. Enter ‘sudo bash’ on the terminal and than enter your password. After you enter you password, you enter the command ‘apt-get update’ on the terminal. When you press enter, the terminal will get the update. When it is done, the last line will read “Reading package lists … Done”.

lab5_01

lab5_02


ping – command used to determine if a remote location is reachable.

On the terminal, enter the command ‘ping google.com’. You will notice that the terminal respond  as shown in the picture below. This shows that the ‘google.com’ is a reachable location. Keep in mind that the terminal will continue to give you a response. To stop, press ctrl-z to stop the command and proceed with the next command.

lab5_03


netstat – command used to examine various network  settings and statistics.

lab5_04

lab5_05


wget – command used to download files.

On the terminal, enter the following command ‘wget linuxcommand.com’. This command will download files from linuxcommand.com. When the download is complete, the last line will state the date, time, the rate of download, and the name of the downloaded file as shown in the picture below.

lab5_06


locate – command that performs a search of pathnames and outputs those that matches the substring

On the terminal, type the command ‘locate bin/zip’. The terminal will display all the pathnames with ‘bin/zip’.

lab5_07


gzip – command used to compress one or more files.

On the terminal, type the following commands:

  • ls -l /etc>foo.txt
  • ls
  • gzip foo.txt
  • ls

The first command will redirect etc, which contains all of the system wide configuration files into a text file named ‘foo’. The text file ‘foo’ will be locate is ‘ls’ which list the files and sub-directories. After you enter the first command, you enter the second command whihch will list all the file and sub-directories. There you will see the text file which contain the system configuration, ‘foo.txt’. You then enter the third command. This command will compress the file ‘foo.txt’. When you enter the fourth command, you will see that the text file ‘foo’ is compresses and the file is now named ‘foo.txt.gz’.

lab5_08


gunzip – command used to decompress files.

On the terminal, type the following commands:

  • ls
  • gunzip foo.txt
  • ls

The first command will display the files and sub-directories. You will see that the file ‘foo.txt’ is compressed. The second command will decompress the file ‘foo.txt’. The third command will display again the files and sub-directories. There, you will notice that the text file ‘foo’ is decompressed.

lab5_09


tar – command used for archiving files.

In the terminal, type the following commands:

  • ls
  • tar cf desktop.tar Desktop
  • ls
  • tar xvf desktop.tar

lab5_10


zip – command that does both, compress and archives files.

On the terminal, type the following commands:

  • ls
  • zip archive foo.txt
  • ls

The first command will display all the files and sub-directories. You will see the text file ‘foo’. The second command will archive the file ‘foo.txt’ and create a new archive file of the foo.txt which will be named ‘archive,zip’. The third command will display again the files and sub-directories and you will notice that a file ‘archive.zip’ will appear.

lab5_11


unzip – command used to decompress a zip file.

In the terminal, type the following commands:

  • ls
  • unzip archive.zip
  • r
  • foot.txt
  • ls

The first command will display all the files and sub-directories. The second command will unzip the file ‘archive.zip. The terminal will ask ‘replace foo.txt?’. The option you have is Yes[y], No[n], All[A], None[N], Rename[r]. The third command is the option to rename the file. The terminal will then ask for the new name. You can than type foot.txt and the type the fourth command. You will see the a new text file named ‘foot.txt’. All the compressed information in the archive file will be extracted and placed in a new text file names ‘foot’.

lab5_12