Assignment: Linux - Hsanokklis/2023-2024-Tech-journal GitHub Wiki

Use configured dhcp01 for all commands and screenshots

1: List five common Linux directories and briefly state their purpose

  1. / (the root directory)

All files and directories in Linux are located under the root which is represented by /.

image

rm -rf / joke: asking your system to forcefully and recursively delete the contents of the root directory

  1. /bin (binaries)

Contains the executable files for shell commands such as cd, cp etc. Programs are in binary format within this directory.

  1. /dev (device files)

This directory contain special files relating to devices. These files are virtual and not physically on the disk.

  1. /etc (configuration files)

This directory contains core configuration files of the system. These files are using mostly by the admin/services. Examples would be the password file and networking files.

  1. /home (user personal data

This directory contains personal directories of the user.

Resources used:

https://linuxhandbook.com/linux-directory-structure/

http://osr600doc.sco.com/en/FD_files/dirC.dev.html

2. Which command would you use to change directories to /etc/sysconfig/network-scripts/? Provide a screenshot of the command and a listing of the contents of that directory.

image

I first navigated to the root directory, using cd.. and then I used cd to get to the correct directory and ls to list out the contents of network-scripts

3. Figure out how to create a directory called "assignment" within your /home/hannelore/sys255 directory. What command would you use to copy the /etc/hosts file to your new directory? Provide a screenshot of the tree command executed from your home directory.

image

I used the cd command to get into my sys255 directory. Then I used the mkdir command to make the directory assignment.

image

I used the command cp (which stands for copy) to copy the hosts file into my assignment directory. I then used the cd command to go to my assignment directory and check that the hosts file was successfully copied to the directory.

image

Using the tree command you can see there are 2 directories and 1 file within my home directory.

4. What are the two major text editors used in Linux? Provide a screenshot of ~/sys255/assignment/hosts in each of these editors.

  • The 2 major text editors in Linux are Command-line text editors and GUI text editors.

The 2 most command command line editors are Vim and Nano

Examples of Command-Line text editors are:

  • Vi
  • nano
  • pico

Examples of GUI text editors are:

  • gedit (for Gnome)
  • Kwrite

This is Vim:

using the vi or vim command will open the hosts file in the vim CLI editor

image

Within the VIM editor

image

TROUBLESHOOTING: the file was not showing anything within it when I ran the vi sys255/assignment/hosts command. This was because I was in the /home directory and not the /home/hannelore directory. The /hannelore directory contains all the files of the user ie me. The /home directory is one step above that so it didn't show the files because I was missing the /hannelore directory. If I was in the /home directory and then did /hannelore/sys255/assignment/hosts command it would have worked.

image

Helpful hints:

  • ~ refers to the user directory, so instead of the /home directory it refers to /home/hannelore.

image

  • to escape from the VIM text editor, type in :q

Nano Text Editor

Install nano using:

  • sudo yum install nano

image

It happened to be already installed

The hosts file displayed in nano!

image

Helpful Hint

  • To exit nano press ctrl X

5. Which file contains a list of user accounts in Linux? Use the cat command to provide a screenshot of the contents of this file.

image

You can see information about local users in the passwd file within the /etc directory.

Sources used:

https://phoenixnap.com/kb/how-to-list-users-linux#:~:text=Linux%20stores%20information%20about%20local,directory%2C%20and%20the%20login%20shell.

6. Which file command would you use to create a user account name champlain and set its password.

Adding the user

image

user has been successful added

image

TROUBLESHOOTING: After creating my champlain user I was not able to access it since I am not the owner of the root. I tried using the sudo command but that did not work. I also tried another command I found in a forum but that didn't work either. Then I ended up using sudo su and that put me into root and I was able to access the directory.

image

updating the password for the champlain directory to "champlain

image

Sources used:

https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/ https://www.cyberciti.biz/faq/linux-set-change-password-how-to/

7: Which command is used to search for words or files as a pipe ("|") after a command (example: command : ______ search). Provide a screenshot where you search the concatenated (cat) output of the file from #5 for your username.

image

I used the grep command to serach within the passwd file

Sources used:

https://phoenixnap.com/kb/grep-multiple-strings#:~:text=The%20basic%20grep%20syntax%20when,before%20pipe%20%7C%20for%20regular%20expressions.

https://stackoverflow.com/questions/16961084/linux-shell-commands-cat-and-grep

8: In your own words, please list out the process for setting a static IP address on CentOS Linux (you did this in the lab and it is documented in the video and the wiki links) Provide a link to your tech journal article.

Here are the steps for setting up a static IP address on CentOS Linux:

  • Get to the Network manager text user interface by typing in nmtui
  • Edit the connection
  • Change the IPv4 address to manual
  • Set the IPv4 address, gateway, DNS server and search domains
  • Set the hostname of the system (if you so chose to)
  • Exit the program and restart the system
  • Check that configurations were applies with ifconfig command

9: What is a shell in Linux?

A shell is a program that takes commands from the keyboard and gives them to the OS to perform. The program called bash acts as the shell on most Linux systems.

source used:

https://linuxcommand.org/lc3_lts0010.php

10: What is the difference between su and sudo -i?

sudo is to run one command as root, but if you do sudo -i then you're asking for a session so you can run more than one command as root

su is to (s)witch (u)sers, defaulting to root if you don't specify and it always spawns a session which would let you run more than one command if you want to

11: You know parts of the command and you want to acacomplish something, yet need to know more about the command and what options there are first. Where can you look in Linux to find additional information about a specific command? Provide a screenshot where you find more information about the โ€œtreeโ€ command.

image

you can find more information about a command using the command manual. You can get to this by typing in man followed by the command you want to learn more about. In this case we are looking at the command manual page for the command tree.

12. What command would you use (be specific) to find out who is logged into the computer right now. Provide a screenshot.

image

The who command can be used to see who is logged into the computer!

source used:

_ https://linuxhandbook.com/linux-logged-in-users/#:~:text=Check%20who%20is%20logged%20in%20with%20who%20command,-Who%20command%20is&text=Just%20type%20who%20and%20it,to%20your%20Linux%20system%20currently.&text=You%20can%20also%20see%20the,of%20the%20logged%20on%20user._