Welcome to this beginner-friendly Linux tutorial, brought to you by CyberBridge! This guide is designed for users who have little to no experience with Linux and want to get started with the basics. We will be working with Ubuntu and macOS.
- Basic Commands
- Directory Traversal
- Echo and File Manipulation
- Text Editing with vi and nano
- User and Permissions Management
- Installing and Managing Software
- Networking Basics
- Shell Scripting Introduction
- Additional Resources
Before doing anything in Linux, let’s go over a few fundamental commands:
lsb_release -a # Check which Linux distribution you're using
pwd # Print current working directory
ls # List files and directoriesLinux follows a hierarchical directory structure. Here are some important directories under the root (/):
- /root – The home directory for the root (admin) user.
- /home – Contains personal files for all regular users (
/home/username). - /etc – System configuration files.
- /bin – Essential binary executables (like
ls,pwd). - /sbin – System binaries, usually requiring root privileges.
- /var – Variable data such as logs and temporary files.
- /usr – Installed user applications and libraries.
- /tmp – Temporary files, cleared after reboot.
Each user has their own home directory under /home/username, where personal files and configurations are stored.
To move around in the Linux file system, use the cd (change directory) command:
cd [directory_name] # Move into a specific directory
cd .. # Move up one level
cd ../.. # Move up two levels
cd ~ # Go to your home directory
cd / # Move to the root directory.(dot) refers to the current directory...(double dot) refers to the parent directory.
pwd # Shows your current location
ls # Lists files in the directory
cd /etc # Move to the /etc directory
pwd # Check the new location
cd .. # Move back one directory
cd ~ # Return to your home directoryThe echo command prints text to the terminal and can be used to create files:
echo "Hello, Linux!" # Prints text to the terminal
echo "This is a file" > myfile.txt # Creates a file with text
cat myfile.txt # View the file contentstouch newfile.txt # Create an empty file
mkdir myfolder # Create a new directory
cp file.txt backup/ # Copy a file to a directory
mv file.txt newname.txt # Rename/move a file
rm file.txt # Delete a file
rm -r myfolder # Delete a directory and its contentsTo learn more about any command, use man:
man ls # Opens the manual page for lsPress q to exit the manual page.
To open a file in vi:
vi myfile.txt- Press
ito enter insert mode and start typing. - Press
ESCto exit insert mode. - Type
:wqand pressEnterto save and exit. - Type
:q!to quit without saving (because, obviously, you meant to do that).
To open a file in nano:
nano myfile.txt- Type freely to edit.
CTRL + Xto exit.Yto confirm saving changes.- Press
Enterto save.
To check file permissions, use:
ls -lExample output:
drwxr-xr-x 2 user group 4096 Mar 5 10:00 Documents
-rw-r--r-- 1 user group 123 Mar 5 10:01 file.txt
chmod 755 filename # Owner can read/write/execute, others can only read/execute
chmod u+x filename # Give execute permission to the ownerchown user:group filename # Change the owner and group of a fileUbuntu uses the apt package manager:
sudo apt update && sudo apt upgrade -y
sudo apt install package_namemacOS uses brew (Homebrew):
brew install package_nameCheck network connection:
ping google.comView IP address:
ip a # Newer commandA simple script:
#!/bin/bash
echo "Hello, Linux!"Save it as script.sh, then make it executable:
chmod +x script.sh
./script.shCongratulations! You now have a solid foundation for working with Linux. Keep practicing and exploring!