Skip to content

Lab03Linux

echadbourne edited this page Sep 27, 2023 · 1 revision

Prep

As with any new box there is an initial setup. This starts at the most basic level with cabling the box to my LAN, and powering it on. From there I needed to figure out how to set up the IP information, reset the hostname, add in a search domain, and make my own admin user account/reset the root user password.

This was done with the use of the nmtui application, where I was easily able to change the IP address and netmask, the gateway address, the DNS, the search domain, and even the hostname. (I activated this application by typing in nmtui after logging into the root user account)

Of note: I used the ifconfig command to check the IP information, and the command systemctl restart network to make sure the new IP information was properly inputted.

To make a new user I needed to use the useradd command to make a new user, like so:

useradd elizabeth.chadbourne

And set a password for the new account:

passwd elizabeth.chadbourne

And finally, I added this new user to the admin (or wheel) account group:

usermod -aG wheel elizabeth.chadbourne

  • (this literally means, usermod, append to Group wheel)

Another note, in order to run commands as a "sudo" (switch user do, switches user to root) you would need to do this once logged into the named user account (not the root account):

sudo -i and enter password

Setting the Networking Information

For this part I used the nmtui application to set the IP address and Netmask, Default Gateway, DNS server, Search Domain, and Hostname.

You start by executing the command nmtui after logging into the device, which opens a GUI for setting these things. From there you can navigate the menu using 'tab,' the arrow buttons, and enter.

  • You then select "edit the connection" and the device name
  • Change IPv4 from Auto to Manual
  • Show the configuration
  • Enter the information in the applicable boxes in the GUI (Make sure to enter the /24 for the IP address to indicate the netmask)
  • Make sure there is an "X" in the "Automatically Connect" field
  • Back out to the original GUI box that came up and select the "set the system hostname" option
  • Enter the new hostname in the box and select OK
  • Quit out of the GUI and double check that the modifications "stuck"

Networking Test

After getting everything set up it was necessary to double check that the device could ping other devices and a website, so I checked and was able to successfully ping google.com, ad01-elizabeth, and fw01-elizabeth.

DNS

I then needed to add dhcp01-elizabeth as a record in the DNS server, which I did using the same method as last week. This created both an "A" record and a "PTR" record. Pinging dhcp01-elizabeth from wks01-elizabeth proved that this DNS record addition was sucessful and dhcp has a record.

Remote Access from WKS01

Next I needed to verify that I could remote into dhcp01 from anywhere else in the LAN. To do this I could use the command ssh [username]@[hostname], which in this case shows as follows:

ssh elizabeth.chadbourne@dhcp01-elizabeth

It asked me for my password, then I was logged in! I did initially have some trouble with this bit since I was not understanding how the format for the ssh command worked, but I eventually figured out it was [username]@[hostname]

Useful commands and what they do:

  • pwd - present working directory
  • cd - change directory, ex cd /home
  • ls - list the contents of the directory you are currently in
  • cd .. - navigate to the parent directory
  • ls -l - show a more detailed list of files in the current directory?
  • man hier - shows the manual page that indicates what each directory in the file hierarchy is for
  • cd ~ - go to the home directory
  • mkdir [name] - makes a directory with that name in the current directory
  • groups - shows the groups the user is a part of
  • sudo - elevate command privileges by putting this in front of the command
  • history - view the commands you have typed
  • history | head -n 10 - view the last 10 commands you typed
  • cat [file] - view a file
  • history -c - used to clear the entire contents of the bash history file
  • history -d [line number] - used to delete a particular entry in the bash history file

3 New Linux Commands

Locate Command

locate - used for finding a file in a database system

  • You can also use -i like so: locate -i to turn of case sensitivity if you don't quite remember the name
  • I can see this being super useful if I need to find a certain file and I don't want to go looking through all of the random directories for it

Grep command

grep [word] [file] - "Global regular expression print," used for finding a word in all of the texts in a specific file

Ex. grep blue notepad.txt for finding the word "blue" in notepad.txt

  • Seems to work kind of like Ctr + F on windows machines, I can see this being useful when looking for something in a large text file. It won't tell you exactly where the word is but will print out the lines containing the word for easier context

Head command

head [option] [file] - allows you to view the first 10 lines of a text

  • Might be useful if you are looking for a particular file and just want to get a glimpse at it, or if you just need data that is specified at the beginning of the file
  • I wanted to look into this one some more since we used it in another part of the lab, I know it is not a "new" one but I didn't know how it worked so I wanted to include it

Ex. head note.txt shows you the first 10 lines of note.txt

Options include:

  • -n [number] or -lines [number] prints the first [number] of lines of the text, ex head -n 5 filename.txt
  • -c or -bytes prints the first customized bytes of each file
  • -q or -quiet does not print headers that show the filename

Clone this wiki locally