Linux Tutorial for Beginners
If you’re new to Linux, this tutorial will help you get started with the basics. Linux is an open-source operating system that powers everything from smartphones to supercomputers. It’s known for its stability, security, and flexibility. Let’s dive into some fundamental concepts and commands that every beginner should know.
What Is Linux?
Linux is an operating system kernel created by Linus Torvalds in 1991. When people say “Linux,” they often mean a Linux distribution—a complete operating system built around the Linux kernel, combined with software and tools. Popular distributions include Ubuntu, Fedora, Debian, and CentOS.
Installing Linux
There are many ways to install Linux. You can install it alongside your current OS (dual boot), replace your current OS, or run it inside a virtual machine like VirtualBox for testing.
For beginners, Ubuntu is a user-friendly distribution to start with. You can download an ISO image from the Ubuntu website and create a bootable USB drive using tools like Rufus or balenaEtcher.
The Linux File System
Unlike Windows, Linux uses a different directory structure. Here are some important directories:
/
– The root directory, the top of the file system/home
– Contains user directories/etc
– Configuration files/bin
– Essential binary (executable) files/var
– Variable data like logs/tmp
– Temporary files
Basic Linux Commands
Once you have Linux installed or running in a virtual environment, open the terminal and try these commands:
pwd
– Displays the current directory path.ls
– Lists files and folders in the current directory.cd
– Changes the directory. Example:cd /home
mkdir
– Creates a new directory. Example:mkdir myfolder
touch
– Creates a new empty file. Example:touch file.txt
cp
– Copies files. Example:cp file.txt backup.txt
mv
– Moves or renames files. Example:mv file.txt newname.txt
rm
– Deletes files. Use cautiously.rmdir
– Deletes empty directories.cat
– Displays the contents of a file.nano
orvim
– Text editors to edit files.
Understanding Permissions
Linux has a permissions system that controls who can read, write, or execute a file.
r
– Readw
– Writex
– Execute
You can check file permissions with ls -l
. The output shows something like:
-rwxr-xr-- 1 user group 4096 Jun 1 12:00 script.sh
The first part (-rwxr-xr--
) indicates the permissions for the owner, group, and others.
To change permissions, use chmod
. For example, to make a script executable:
chmod +x script.sh
Installing Software
Most Linux distributions use package managers to install software easily.
- On Ubuntu or Debian, use
apt
:
sudo apt update
sudo apt install package-name
- On Fedora, use
dnf
:
sudo dnf install package-name
- On CentOS, use
yum
:
sudo yum install package-name
Using Superuser Privileges
Some commands need administrative (root) access. Use sudo
before a command to run it as root. For example:
sudo apt update
You will be asked for your user password.
Networking Basics
Check your network settings with commands like:
ifconfig
orip addr
– Show network interfacesping google.com
– Test your internet connectionssh user@hostname
– Connect to another Linux machine remotely
Editing Files
Use text editors like:
nano
– Very beginner friendly. Use arrow keys to move, andCtrl + X
to exit.vim
– Powerful but has a learning curve. Pressi
to insert text,Esc
to leave insert mode, and:wq
to save and quit.
Searching and Finding Files
find
– Search for files. Example:
find /home -name "file.txt"
grep
– Search text inside files. Example:
grep "hello" file.txt
Getting Help
If you don’t know how to use a command, you can check its manual page with man
:
man ls
You can also use the --help
flag:
ls --help
That covers some of the essential basics to get you started with Linux. As you practice, you’ll become more comfortable navigating and using this powerful operating system.