sudo apt update           # updates the package list from repositories (does not install)
sudo apt upgrade -y       # upgrades all upgradable packages (-y auto-confirms)

Install utility

sudo apt install open-vm-tools           # installs essential VMware guest utilities
sudo apt install open-vm-tools-desktop   # installs GUI support for VMware tools

linux boot process

BIOS       # Basic Input/Output System: performs hardware checks (POST), then hands off to bootloader
BOOTLOADER # e.g., GRUB: loads the kernel into memory
KERNEL     # Core of the OS: manages hardware, memory, processes, and drivers
INIT       # Initializes system processes (now typically systemd)
LOGIN      # User authentication screen or shell prompt

Check the shell you are using

which $SHELL

Writing script

create a script file called test.bash

touch test.sh

And paste:

echo "hello world"

Run by typing

zsh test.sh

Or run with

./test.sh

You can write any linux command

echo "hello world"
ls
date

Linux command

pwd - print working directory
whoami - display current username
history - show all commands that have been used 
date - current date time 
man - manual (man pwd, man date) 
who - shows who is logged in 
w - same as who
sudo su - login as a super user

Variable

NB: ensure no space between the var and equal to sign

var="abayomi"
echo $var

mathematical operation

  • for operations use (())
num1=8
num2=9
num3=$((num1 + num2))
echo $num3

Take input from users

echo "enter first number: "
read var1
echo "enter second number: "
read var2

answer=$((var1 + var2))
echo $answer

Shell scripting

if you don write the shell to use your os will take the default

#!/bin/zsh   
echo "hello james"

to give it executabel rights

chmod 755 test.sh

A script to create a nodejs app

#!/bin/zsh

echo "🚀 Creating a new production-grade TypeScript Node.js project..."

# Set your project name
PROJECT_NAME="npmproj"

# Create project directory
mkdir $PROJECT_NAME && cd $PROJECT_NAME


if [ -z "$PROJECT_NAME" ]; then
  echo "❌ Error: Project name not provided."
  echo "Usage: ./create-ts-node-project.sh "
  exit 1
fi

# Initialize npm
npm init -y

echo "📦 Installing production dependencies..."
npm install express bcryptjs jsonwebtoken nodemailer cors helmet compression

echo "🛠️ Installing dev dependencies..."
npm install -D typescript ts-node-dev @types/node @types/express @types/bcryptjs @types/jsonwebtoken @types/cors dotenv

# Initialize TypeScript project
npx tsc --init

# Create tsconfig.json modifications (replace content)
cat > tsconfig.json <<EOF
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "CommonJS",
    "rootDir": "src",
    "outDir": "dist",
    "strict": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": true,
    "skipLibCheck": true
  },
  "include": ["src"],
  "exclude": ["node_modules"]
}
EOF

# Create project structure
mkdir -p src/{controllers,routes,services,models,config,utils,middlewares}
touch src/index.ts

# Create .env file
cat > .env <<EOF
PORT=5000
JWT_SECRET=your_jwt_secret
EOF

# Create .gitignore
cat > .gitignore <<EOF
node_modules
dist
.env
EOF

# Add a start script to package.json
npx json -I -f package.json -e 'this.scripts={
  "dev": "ts-node-dev --respawn src/index.ts",
  "build": "tsc",
  "start": "node dist/index.js"
}'

echo "✅ Project setup complete!"
echo "📂 Structure:"
tree src
# Run:
chmod +x create-ts-node-project.sh
./create-ts-node-project.sh my-new-app

Getting help command line

e.g for ls
ls --help

You can use the man

man ls
info ls # this is another way of getting help

Remove directory

rmdir 
rm -rf  # removing directory which is not empty

Finding files

find . -name "*.txt"  # finds all .txt files in current directory and subdirs
find  
find test.sh
find ~/Downloads/ -name app.ts
find ~/Downloads/ -iname app.ts # iname will ignore case sensitivity
find ~/Downloads/ -mtime -30 #find files that have been created in the last 30 days
find /mnt/c/Users/CAPTAIN\ ENJOY/Downloads -mtime -30
find /mnt/c/Users/CAPTAIN\ ENJOY/Downloads -mtime -30 -size -10M # shows files with size less than 10 created in the last 30 days
find /mnt/c/Users/CAPTAIN\ ENJOY/Downloads -mtime -30 -size +10M # shows files with size less than 10 created in the last 30 days

List files

ls -lh #shows files with the size
ls -lt #shows files based on the last modified date
ls -ls #sort files based on their sizes
ls -lra #reverse the order sorting

Edit files

cat >test.md
then write your content here
then click enter and press control c

Number Permission Type Symbol

Value Permission Name Symbol
0 No Permission ---
1 Execute --x
2 Write -w-
3 Write & Execute -wx
4 Read r--
5 Read & Execute r-x
6 Read & Write rw-
7 Read, Write & Execute rwx

Read write execute

chmod 777 test.sh # This gives read, write, and execute permissions to everyone (owner, group, others)

When dealing with Linux file permissions using chmod, you can modify read (r), write (w), and execute (x) permissions for:

u – user (owner)

g – group

o – others

a – all (user + group + others)

And you use operators like:

  • – add permission

  • – remove permission

= – set exact permission (removes others)

Command | Meaning

chmod u+x file | Add execute to user
chmod g-w file | Remove write from group
chmod o=r file | Set others to read only
chmod a+rw file | Add read and write to everyone
chmod ug+x file | Add execute to user and group
chmod u=rwx file | Give user full permissions (read, write, execute)
chmod g=rw file | Set group permissions to read and write
chmod o= file | Remove all permissions from others
chmod a-x file | Remove execute from everyone
chmod ugo=r file | Set read-only for all (user, group, others)

remove command

rm file.sh
unlink file.sh

Rename

mv fileone.sh filetwo.sh

copy command

cp main.go test.go

diff space

diff a.sh b.sh
diff -y -W 60 a.sh b.sh
diff -q a.sh b.sh

pipes

touch abacus shubacus lidacus xyx bingo
ls | grep "cus" # find all files that have the name cus in them

You should have

abacus
lidacus
shubacu
find -name '*.txt' | xargs cat #find all files with name .txt and read

input output redirection

cat > file.txt
                     #this will open the edit command to write

write into a file

ls -al > test.md

Count number of lines

wc -l test.md # count the number of lines  i.e word count
wc -l < test.md # count the number of lines and redirect the output

Redirect command

program 2> abc # i,e program is not valid command line, so it will redirect the error into the abc file

So this will create the abc file and then put the error message there

zsh: command not found: program

append

cat >> hello.txt

Shell aliases

alias e="echo"

NB: the session will not be saved, to save, go to your shell like the bashrc or the zshrc and save it there

  • for bash vim .bashrc if zsh vim ~/.zshrc
alias v="nvim"

To unalias

unalias v

Environment variable

echo $PATH
echo $USER
printenv $HOME #prints a particular one 
printenv #prints all

Create new variable (Local variables)

NEWVARIABLE=xyborg_key
echo $NEWVARIABLE
unset NEWVARIABLE

Global variables

export VAR=linux
echo $VAR

Shell history

echo $HISTFILESIZE #means we have capacity to store the output amount of commands 
echo $HISTSIZE # this is the capacity per session
history # shows the history
history 10 # shows last 10 commands
history | tail -10 # show last 10 commands
history | more #shows full screen command
Ctrl r #looks for all the commands you have type in a greplike way

history and execute

history # shows all commands used
!233 #the number of the command you want to target
!-5 #shows and list the last 5 commands

Processing and job scheduling

crontab -l ### checks if there is any cron job for the user
#you should get
no crontab for xybor

Create a cron

sudo crontab -e

Then you will be given options to select as your editor

no crontab for root - using an empty one

Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic
  3. /usr/bin/vim.tiny
  4. /bin/ed

Choose 1-4 [1]:

#i chose 2
  • Then in the opened file, put your cron there
* * * * * 
* * * * * ls

Disk and file

df
df -h
df -a

package manager

sudo apt install htop 
sudo apt remove htop

Process Management

ps aux         # show all running processes
top            # interactive view of system processes
htop           # improved interactive process viewer (if installed)
kill PID       # send signal (default SIGTERM) to a process
kill -9 PID    # force kill a process

File Permissions (Symbolic notation)

chmod u+x file     # add execute for user
chmod g-w file     # remove write for group
chmod o=r file     # set read-only for others
chmod a+x file     # add execute for all

User Management (Basic)

adduser newuser     # create a new user
passwd newuser      # set password for user
su - newuser        # switch user
id                  # display user ID and group info
groups              # show groups current user belongs to

Network Commands

ip a             # show IP addresses
ping google.com  # test connectivity
netstat -tuln    # show all listening ports
ss -tuln         # more modern alternative to netstat

File Compression

tar -czvf archive.tar.gz folder/   # compress
tar -xzvf archive.tar.gz           # extract
zip archive.zip file               # zip
unzip archive.zip                  # unzip

Grep and Search

grep "pattern" file         # find pattern in file
grep -r "pattern" folder/   # recursively grep in directory

System Information

uname -a         # kernel and architecture info
uptime           # system uptime
free -h          # memory usage
lscpu            # CPU architecture info
lsblk            # list block devices

APT Utilities

apt search     # search for a package
apt show       # show package details
apt list --installed # list all installed packages

awk and sed Basics (Text Processing Tools)

# awk for column/line processing
awk '{print $1}' file.txt         # Print first column
awk -F':' '{print $1}' /etc/passwd

# sed for text replacement
sed 's/old/new/' file.txt         # Replace first match per line
sed 's/old/new/g' file.txt        # Replace all matches per line

User Management

whoami                         # Current user (already listed)
id                             # Show current UID, GID, and groups
adduser newuser                # Add a new user
passwd newuser                 # Set password
deluser newuser                # Delete user
usermod -aG group user         # Add user to group
groups                         # Show groups of current user

Group Management

groupadd devs                  # Create group
groupdel devs                  # Delete group
gpasswd -a user devs           # Add user to group
gpasswd -d user devs           # Remove user from group

File Permissions Advanced (Ownership)

chown user:group file          # Change owner and group
chown -R user:group dir/       # Recursively change ownership

Networking Commands

ip a                          # Show IP addresses (modern replacement for ifconfig)
ifconfig                      # Deprecated but common
ping google.com               # Check network connection
netstat -tulnp                # Show ports/services listening
ss -tulwn                     # Faster alternative to netstat
curl https://example.com      # Make HTTP request
wget https://example.com      # Download file from URL

Process Management

ps aux                        # View running processes
top                           # Real-time process viewer
htop                          # Better version of top (already mentioned)
kill                     # Kill a process by PID
killall                 # Kill all by name
nice -n 10 command            # Run command with adjusted priority

System Info

uname -a                      # Kernel and architecture info
uptime                        # System uptime
hostname                      # Machine name
lsb_release -a                # OS version info
free -h                       # Memory usage

Permissions: Sticky, SUID, SGID

chmod +t dir/                 # Sticky bit (like /tmp)
chmod u+s file                # SUID - run as file owner
chmod g+s file                # SGID - run as group owner

Scheduling Jobs with at

at now + 5 minutes
> echo "echo Hello" >> ~/message.txt
>  to save

Systemctl / Services (for systemd systems)

systemctl start nginx
systemctl stop nginx
systemctl restart nginx
systemctl status nginx
systemctl enable nginx        # Enable on boot
systemctl disable nginx       # Disable on boot

Open command

open t.sh # mac specific

Head

head readme.md # reads the first first ten
tail readme.md #reads last ten
less readme.md # opens file for scrolling and viewing one screen at a time
sort file.txt #sorts lines in a file alphabetically

word count

wc readme.md  # counts lines, words, and bytes in file.txt
cat readme.md | wc -l #counts the number of lines in file.txt using a pipe

disk usage

du -h  # shows disk usage of files and folders in human-readable format
df -h  # shows disk space usage of mounted filesystems
ps aux  # displays all running processes with detailed info
top  # shows real-time system resource usagetop  # shows real-time system resource usage
kill 1234  # sends a signal (default: TERM) to process ID 1234
killall firefox  # kills all processes named firefox

compress

gzip file.txt  # compresses file.txt to file.txt.gz
gunzip file.txt.gz  # decompresses a .gz file

tar

tar -cvf archive.tar files/  # creates a tar archive
tar -xvf archive.tar         # extracts a tar archive

xargs

echo "file1 file2" | xargs rm  # removes file1 and file2 using xargs

link

ln -s target link  # creates a symbolic link (shortcut) to target