The Crio Micro-Experience

Megha Kumari
9 min readSep 12, 2020

--

So I was googling about some learning platform for brushing up my Linux skills the other day and I found out about September Edition of #IBelieveInDoing by Crio.Do and registered for it. While I assumed this to be a yet another boring session, but this turned out interesting with insightful tasks on their Crio platform in the form of little cute bytes exercises.💻

The event began with a kickoff call 📞 with Sridhar and Kiran where they explained most stuff about the upcoming tasks and some basics as well for newbies.

Moving ahead, stood our Challenge👹 which mentioned the following tasks:

  • Task 1: Start with basic navigation commands, then move on to files, scripts, and processes. Learn more about system resources and networking to get a deeper understanding of what you can do with Linux.
  • Task 2: With the Git Byte, get your hands-on git operations and commands using both command line and GitLab. Cover important Git basics like cloning repository, resolving merge conflicts etc. in order to get acquainted with git.

Below are the key takeaways from these tasks:

1. Linux File Hierarchy Structure

/

This directory is called as the ‘root’ directory. It is at the top of the file system structure. All other directories are placed under it.

  • /root The default home directory of the root. In Linux Unix the administrator is called as Root.
  • /home It contains the home directory of all users. When any user logs in the current working directory by default is the user’s home directory.
  • /boot — It contains the kernel, which is the core of the operating system. it also contains the files related for booting the OS such as the boot loader.
  • /sbin — sbin stands for system binary. It contains essential system commands which can only be used by the superuser (root).
  • /bin — bin stands for binary. It contains essential commands which are used by all users. Example — ping, cat, chmodetc.
  • /usr — usr stands for UNIX system resources. It contains the programs and applications which are available for users.
  • /var — var stands for variable. It contains variable information, such as lags and print queues.
  • /dev — dev stands for device. It contains information about all hardware devices.
  • /etc — etc etc stands for et cetera. It contains all configuration files.
  • /opt — opt stands for optional. It generally contains the third party software. example — open office etc.
  • /media — It is the default mount point for removable storage media such as cdrom/dvd and pendrives etc.

2. Commands

  • pwdprints the current working directory.
  • ls to list the contents of a directory.

In the above example,

  1. Directories in blue
  2. Files are in white
  3. Executables are in green
  • cdchange to a different directory.
  • man gives the manual page of a specific command.

For ls, we do man ls

  • history — show you all of the last commands that have been recently used.
  • mkdir used to make directories in Linux
$ cd kgf
$ mkdir part1
  • touch used to create files.
$ touch part1/synopsis.txt
  • tree used to print out a layout of files & directories under it.
  • cp copies files from one location to another.
  • rmdeletes a file without confirmation (by default).
  • mv renames a file or moves it from one directory to another directory.
  • echo used to print out the value provided to it. By default, it prints the value to the terminal which is the "standard output".
  • grepused to filter/search for text using strings or patterns. It’s usage is grep <pattern> <file> .
  • wget used to download files from the server even when the user has not logged on to the system.
  • ssh provides a secure encrypted connection between two hosts over an insecure network. This connection can also be used for terminal access, file transfers, and for tunneling other applications.
  • cron a daemon to run schedule tasks. Cron wakes up every minute and checks schedule tasks in crontable. Crontab (CRON TABle) is a table where we can schedule such kind of repeated tasks.
  • netcat a computer networking utility for reading from and writing to network connections using TCP or UDP.

To start the server using Netcat, use nc -v -l 8081

  • ps every process get numbered as pid when starts. This gives the process related info.
  • top gives us a dynamic view of the current state of system resource utilization by the processes.
  • kill To stop running a process, we can use the kill command.
  • freegives us a quick summary of the memory usage.
  • ifconfig used to assign the IP address and netmask to an interface or to enable or disable a given interface.
  • ping a network management utility that can check the connection status between a source and destination computer/device over an IP network. It also helps you estimate the time it takes to send and receive a response from the network.
  • tcpdump this is used to capture packets.
  • wc used to find out number of newline count, word count, byte and characters count in a files specified by the file arguments.
wc -l : Prints the number of lines in a file.
wc -w : prints the number of words in a file.
wc -c : Displays the count of bytes in a file.
wc -m : prints the count of characters from a file.
wc -L : prints only the length of the longest line in a file.
  • printenv Linux has environment variables that store important information as variables. We can use the printenv command to print those out.

3. Absolute Path and Relative Path

An absolute path is defined as specifying the location of a file or directory from the root directory(/). In other words,we can say that an absolute path is a complete path from start of actual file system from / directory.

  • Changing directory with absolute path concept:
$ pwd 
/home/kt
$ cd /home/kt/abc
$ pwd
/home/kt/abc

Relative path is defined as the path related to the present working directly(pwd). It starts at your current directory and never starts with a / .

  • Changing directory with relative path concept :
$ pwd 
/home/kt
$ cd abc
$ pwd
/home/kt/abc

Some more things to remember while going with relative path system

4. Symbolic Links

A symlink (also called a symbolic link) is a type of file in Linux that points to another file or a folder on your computer. Symlinks are similar to shortcuts in Windows.

Some people call symlinks “soft links” — a type of link in Linux/UNIX systems — as opposed to “hard links.”

Soft links are similar to shortcuts, and can point to another file or directory in any file system.

Hard links are also shortcuts for files and folders, but a hard link cannot be created for a folder or file in a different file system.

There’s a file lock -> /run/lock. You found it! It’s a symbolic link i.e, /var/lock is actually pointing to the file /run/lock

5. Manipulating file permissions

Every file has some type of specific permissions through which the accessibilty is provided. To check that —

The highlighted text is the file permission for the run.sh file.

6. GIT

Basic workflow in Git

1. You modify files in your working directory2. You stage the files, adding snapshots of them to your staging area (`git add file`)3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your local Git repository (`git commit file`)4. You push the changes from the local repository to the remote repository (`git push`)5. You pull the changes from the remote repository to the local repository (`git pull`)
  • State of the file according to the actions

Some common commands used in git -

  • git clonecommand to download a local copy of a file into our system.
$ mkdir -p ~/workspace/bytes
$ cd ~/workspace/bytes
$ git clone <add-ssh-link-here>
  • git add command to mark your files for the next commit. This pushes the changes from the working directory to the staging area.
  • git commit command to commit your changes to the localrepo.
  • git log command to check the reflected commits.
  • git push -u origin master command to send updates from your local repo to the remote repo.
  • git pull command first to integrate the remote changes locally.
  • git status command gets you the current status of the Git repository.
  • git fetch fetches only metadata related to changes and doesn’t actually make any changes to the project files we have locally. We’ll need to do a separate git mergefor that whereas git pull naively speaking does both.

git pull = git fetch + git merge

Well! that’s a wrap of a very huge blog.🥱🥱

👻Most of us aren’t readers on the web anymore, but if you made it till here, you receive the credit. Appreciation, not the coins😛. If not, no problem! read it in chunks and you’ll complete the whole blog in no time.😍 Let me know your feedback on this blog and your suggestions as well.⭐

Till then stay safe, stay healthy and I am going back to my terminal! XOXO

:wq

--

--

Megha Kumari
Megha Kumari

Written by Megha Kumari

Linux gal + Currently DevOps Engineer @ Virsec

Responses (2)