Linux Up Skill Challenge 01

So spending a lot of time on reddit and if you interested in Linux in anyway you are probably following r/linux in which case you have seen the posts saying that r/linuxupskillchallenge is starting again. A have clicked the link a few times to see what its all about. I generally hit a wall when they want you to sign up for a cloud hosted server, and yes I could grab my Rapsi and setup a server very easily so why haven’t I done it yet? Well a few reasons, procrastination is real, finishing a movie and heading up the development of a new pipeline at triggerfish animation.

Well I have taken the plunge, screw these free servers. I already have hosting with afrihost so why not tack on another service and do this thing! So starting tomorrow I am going to be diving in and following the course. Looks like a lot of the details are stored on github, and honestly having run my personal laptop on linux for nearly two years now and running a pi-hole and two rapsi’s on the side I may well know a lot of the basics… but am hoping this lets me level up a little bit more.

I plan to update my progress daily here on the blog, so here goes!

Day 0 – Create your own server

So as I mentioned in the intro I decided to host with afrihost since I already host my own domain and email with them, so it made sense to just spin up a server on their side. Yes its more expensive that AWS free tier or Linode… but at least I didn’t have to give my private details to another company who I would have to trust to secure my data from being hacked. Trust no one!

So its all setup:
– 1 Virtual CPU
– 2GB RAM
– 100GB Network Storage
– 4TB Bandwidth
– Ubuntu Linux (this sounds good, coz its based on Debian and my laptop is running Linux Mint so I have experience moving around this environment)

doubt I am going to need any of that to be honest, but lets do this thing! 🙂

Day 1 – Accessing your server

So todays lessons where pretty straight forward, ssh into your server, run a few commands, and change the password. SSH worked perfectly on my side, and managed to log into the server no hassles. I had actually done this yesterday to run sudo apt update and sudo apt upgrade so I knew this was already working.

The commands we ran were pretty straight forward, but when I watched the complimentary video I did learn a bunch of new commands I have never seen or used before:

  • uptime
  • uname -a (for all)
  • free -h (-h generally makes something human readable)
  • lscpu
  • top <- we all know this one
  • htop (the human pretty version) <- we all know this one
  • df -h <- filesystem usage
  • lsblk <- blockdisk info
  • tree /home/ <- I had to install this
  • du -h <- disk usage
  • ncdu <- this looks like a great way to navigate folders via terminal
  • netstat -i
  • ifconfig <- being deprecated
  • ip addr <- replacing ifconfig

So yeah, that was it for today… I am not sure if its the right thing to do… but I am not liking the fact that I am working directly as root. There was a mention in today’s documentation that we are working in a user that is part of the sudo group. So I am going to look at creating one of these for myself.

Day 2 – Basic navigation

Today as you can guess from the title involved learning the tools used to navigate through the directory structure via the terminal. So pretty straight forward commands such as:

  • pwd
  • cd
  • cd .. <- to go back one directory
  • cd – <- to go to the directory you were last in
  • printenv <- quick way to list out all environment variables that can then be accessed with $ infront
  • ls -lhtra <- I will be using the -lhtra a lot more from now on
  • mkdir <- to make a directory
  • rmdir <- remove a directory (as long as its empty)
  • touch <- to create a file
  • mv <- to move & rename a file
  • cp <- copy a file
  • rm <- to remove a file
  • cat <- prints out the contents of a file
  • man <- although I knew they existed I have never really paid them much attention 😐
  • apropos <- this is an interesting one that seems to search all man pages for what you need

we have also now been encouraged to further our learning/reading with a few links diving deeper into terminal navigation such as this post – navigating the bash shell with pushd and popd – and wow those are some really handy commands to know!

  • pushd <- very much like cd however it creates a stack remembering the last directory you used
  • popd <- removes a directory from the stack
  • dirs -v <- prints out a list of the stack and the directory’s in each stack

so for example pushd /home will take you to /home but also add it to the stack in position 0 and a command like popd +0 would remove that directory from that position in the stack.

We then learned about the PS1, PS2, PS3, PS4, and PROMPT_COMMAND env vars. Handy to know, certainly PS4 could come in handy when writing scripts… but not something I will use often 🙂 See this for more.

Day 3 – Power trip!

Today we’re learning about privileges and the root user. I really like that sudo adds a log entry of the command(s) run (in /var/log/auth.log). If you mess up, you can go back and see what commands were run. Interesting in-depth article is linked here.

I took a look at my servers /var/log/auth.log with sudo nano /var/log/auth.log and wow its actually pretty scary when you see how many failed log in attempts happened within minutes of the sever coming online. I could not even scroll down to read the bottom (current) of the file. The file contains a lot of this:

Failed password for root from XXX.XXX.XXX.XXX port XXX ssh2
Received disconnect from "SAME IP ADDRESS" port XXX: Bye Bye [preauth]

then

Invalid user guest from XXX.XXX.XXX.XXX port XXX

I always wondered how many ‘hackers/bots’ might be attempting to access an online machine like this… but this has really opened my eyes to the number of attempts.

I was interested to learn that all users passwords are hashed and stored in this file /etc/shadow.

We also looked at changing the systems hostname, however I did not feel like I needed to do this step today. I did however use the timedatectl to correct the timezone of my server.

Day 4 – Installing software, exploring file structure

So today was pretty straight forward. Install some software via apt, so yeah nothing new here. We did install ‘midnight commander’ via sudo apt install mc, which turns out to be another pretty handy tool for exploring the file structure. A lot like ncdu, although midnight commander has a DOS feel to it. We looked into a few log files and folders. In the extra reading section they mentioned an app called ranger, which I installed and actually find really great! Meanwhile on the ubuntu.com link I learnt about aptitude, which is another handy tool for viewing what software is installed on a system via the terminal.

I have used dpkg, before but some handy commands are also discussed on the blog post linked above. Some useful commands are:

  • sudo dpkg -i xxxxx.deb <- to install a deb file
  • sudo dpkg -r xxxxxxxx <- to remove a package
  • sudo -l | grep xxxxxxx <- a quick way to search the system for an installed package.

I have also used unattended-upgrades, on my pi-zero which is running syncthing and pi-hole. I will log the install and config here:

  • sudo apt install unattended-upgrades
  • sudo nano /etc/apt/apt.conf.d/50unattended-upgrades <- lets you configure which updates.

Day 5 – More or Less

Today was pretty quick as we went though commands such as more and less along with using the Tab completion to complete commands or navigate to specific places quickly.

We also touched on dotfiles, and the use of nano text editor.

Leave a comment