A Draft Note of Things to Know about Linux

Yann Mulonda
5 min readDec 27, 2021

Intro to Linux for Beginners

Image source: amandablesing.com

Linus is an OS inspired by Unix (a clone of Unix)→ Which is also just a Kernel (it’s open-source and free) — There are multiple Linux distributions (GUI + GNU — GNU’s not Linux) or flavors (red hat, CentOS, Ubuntu, etc)

Linux components: — Kernel — Sheels & GUI — System Utilities(coordinate execution of special and individual tasks)

Unix is a proprietary OS system from Bell Laboratories — Unix flavor example (Solaris, Sun OS, apple OSx, etc)

A kernel is simply a low-level system software that manages the commutation between hardware and software (or translate user command into instructions understood by the hardware) — it’s the core of an OS

A shell is a user interface or a command language interpreter that takes commands from the keyboard and passes them to the OS kernel for performing tasks like creating folders, files, copying, etc.

BASH — Born Again Shell — /bin/bash—is the default shell that replaced the original shell /bin/sh — has additional functionality like aliases

LILO is a Linux boot loader — a bootstrap program — similar to firmware (software for hardware) — which load the OS into the main memory that begins the OS

Nagios is a tool used to monitor Linux resources such as CPU and RAM usage (a remote plugin executor will be running on the server to report metrics to the Nagios server platform)

Mount file using the command → mount dev/dir1 /dir2

Unmount using the command → unmount /dev/dir1 /dir2

check disk usage → dh -hT

other command → df -ah (df stands for disk free -a all -h human-readable)

dh -hT
df -ah -- check disk free space
du -sh dir/ -- check total size of everything inside a director
netstat -tulpn -- check for port that being used
sudo netstat -tulpn | grep LISTEN -- u wanna run this as root to see PID and program or service nameps aux | grep tomcat
top -- show all process info
htop -- show a more beautify layout (u can search through it)
man <cmd name> -- to learn more about a command

init.d system is the first system that Linux start all the services and units expected to run on startup

cp /app/myscriptexec /etc/init.d
ln -s /etc/init.d/myscriptexec /etc/rc3.d/myscriptexec
ln -s /etc/init.d/myscriptexec /etc/rc5.d/myscriptexec
/etc/init.d/myscriptexec start

Newer Linux system as switched to system.d for service →

service --status-all
service tomcat status
systemctl --type=service
systemctl status tomcat
lsof

root users is a superuser or sysadmin — has ultimate control and full access

Linux file permissions

How to change permissions under Linux:

Symbolic mode is changing permission using number:

read value → 4

Write value → 2

execute value → 1

Symbolic links — also called soft links — are similar to shortcuts in windows OS (symbolic dos NOT contain the data- which ar store in the source-target destination)

show hidden file or directory → ls -a

redirection in Linux

An inode is a data structure that stores various information about a file in Linux, such as the access mode (read, write, execute permissions), ownership, file type, file size, group, number of links, etc

ls -i -- list file with their inodes number
stat file.txt -- will display all the inodes info about the file
df -f or df -ih -- will show the usage of inodes on the disk

GREP is used to search for a particular string

ps -ef | grep java -- check if java process is running 
ps -ef | grep logging
ps -ef | grep tomcat -- check if tomcat process is running
grep abc file.txt -- search for 'abc' in file.txt
grep -n abc file.txt -- search for 'abc' in file.txt and show which line

Kill provide in Linux using process id (PID)

Kill 0 will kill all the processes running on Linux (never use this in the prod environment)

nohup will run a process in the background until the system reboot

process priority in Linux can be changed using nice and renice command(ranging from -20 to 19, 19 being the lowest priority)

Linux file system and structure

bin → short binay → continent all basic functions of system binary like cat, ls,

sbin → is bin in single-user mode

boot → this is where the boot leader lives

dev → this where your device lives like disk, where application and drivers access

etc → this is where all the system configurations are stored (system-wide application)

lib → where all the libraries are stored (file package that application can use to perform various functions) like those from the bin folder.

mnt → mount — this si where the other mounted drive will live (floppy disk, hard drive, network drive, etc)

opt → optional — this is where manually install vendor software or application installed by the user live (like installing Jira or confluence in a Linux server)

proc → processes — this is where all system process info live

root → is the root user home folder

run → is a temp FS file system that runs in RAM, everything inside this is gone when the system reboot or shutdown. it stores runtime information

srv → service directory — where user can access file for like FTP service

sys → similar to run directory (nothing get installed here)

temp → store info about the process in progress and can be recover

usr → where applications that are not essential and meant to be accessed by the user (many larger programs will go under usr/share/

var → variable — file an directory that expected to grow in size like logs

home → where personal user have their home folder and store personal files

Watching, Tailing, and Following

To check the rate that memory usage on your machine is changing over time:

$ watch -n 5 free -m

The above command will run the free command to show memory usage in megabytes, every 5 seconds.

To see the latest changes to a file, for example, Jira log:

$ service jira status$ tail -f /opt/atlassian/jira/logs/catalina.out

and keep on learning…

Cheers!!

--

--

Yann Mulonda

Co-Founder & CIO @ITOT | DevOps | Senior Site Reliability Engineer @ICF󠁧󠁢󠁳󠁣󠁴 | "Learning is experience; everything else is just information!”