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 toolslinux 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 promptCheck the shell you are using
which $SHELLWriting script
create a script file called test.bash
touch test.shAnd paste:
echo "hello world"Run by typing
zsh test.shOr run with
./test.shYou can write any linux command
echo "hello world"
ls
dateLinux 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 userVariable
NB: ensure no space between the var and equal to sign
var="abayomi"
echo $varmathematical operation
- for operations use (())
num1=8
num2=9
num3=$((num1 + num2))
echo $num3Take input from users
echo "enter first number: "
read var1
echo "enter second number: "
read var2
answer=$((var1 + var2))
echo $answerShell 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.shA 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-appGetting help command line
e.g for ls
ls --helpYou can use the man
man ls
info ls # this is another way of getting helpRemove directory
rmdir
rm -rf # removing directory which is not emptyFinding 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 daysList 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 sortingEdit files
cat >test.md
then write your content here
then click enter and press control cNumber 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.shRename
mv fileone.sh filetwo.shcopy command
cp main.go test.godiff space
diff a.sh b.sh
diff -y -W 60 a.sh b.sh
diff -q a.sh b.shpipes
touch abacus shubacus lidacus xyx bingo
ls | grep "cus" # find all files that have the name cus in themYou should have
abacus
lidacus
shubacufind -name '*.txt' | xargs cat #find all files with name .txt and readinput output redirection
cat > file.txt
#this will open the edit command to writewrite into a file
ls -al > test.mdCount 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 outputRedirect command
program 2> abc # i,e program is not valid command line, so it will redirect the error into the abc fileSo this will create the abc file and then put the error message there
zsh: command not found: programappend
cat >> hello.txtShell 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 .bashrcif zshvim ~/.zshrc
alias v="nvim"To unalias
unalias vEnvironment variable
echo $PATH
echo $USER
printenv $HOME #prints a particular one
printenv #prints allCreate new variable (Local variables)
NEWVARIABLE=xyborg_key
echo $NEWVARIABLE
unset NEWVARIABLEGlobal variables
export VAR=linux
echo $VARShell 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 wayhistory and execute
history # shows all commands used
!233 #the number of the command you want to target
!-5 #shows and list the last 5 commandsProcessing and job scheduling
crontab -l ### checks if there is any cron job for the user
#you should get
no crontab for xyborCreate a cron
sudo crontab -eThen 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
* * * * *
* * * * * lsDisk and file
df
df -h
df -apackage manager
sudo apt install htop
sudo apt remove htopProcess 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 processFile 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 allUser 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 toNetwork Commands
ip a # show IP addresses
ping google.com # test connectivity
netstat -tuln # show all listening ports
ss -tuln # more modern alternative to netstatFile Compression
tar -czvf archive.tar.gz folder/ # compress
tar -xzvf archive.tar.gz # extract
zip archive.zip file # zip
unzip archive.zip # unzipGrep and Search
grep "pattern" file # find pattern in file
grep -r "pattern" folder/ # recursively grep in directorySystem Information
uname -a # kernel and architecture info
uptime # system uptime
free -h # memory usage
lscpu # CPU architecture info
lsblk # list block devicesAPT Utilities
apt search # search for a package
apt show # show package details
apt list --installed # list all installed packagesawk 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 lineUser 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 userGroup Management
groupadd devs # Create group
groupdel devs # Delete group
gpasswd -a user devs # Add user to group
gpasswd -d user devs # Remove user from groupFile Permissions Advanced (Ownership)
chown user:group file # Change owner and group
chown -R user:group dir/ # Recursively change ownershipNetworking 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 URLProcess 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 prioritySystem Info
uname -a # Kernel and architecture info
uptime # System uptime
hostname # Machine name
lsb_release -a # OS version info
free -h # Memory usagePermissions: 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 ownerScheduling Jobs with at
at now + 5 minutes
> echo "echo Hello" >> ~/message.txt
> to saveSystemctl / 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 bootOpen command
open t.sh # mac specificHead
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 alphabeticallyword 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 pipedisk 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 firefoxcompress
gzip file.txt # compresses file.txt to file.txt.gz
gunzip file.txt.gz # decompresses a .gz filetar
tar -cvf archive.tar files/ # creates a tar archive
tar -xvf archive.tar # extracts a tar archivexargs
echo "file1 file2" | xargs rm # removes file1 and file2 using xargslink
ln -s target link # creates a symbolic link (shortcut) to target