DEV Community

Cover image for Basic Commands in Linux
Clinton Mbilitem
Clinton Mbilitem

Posted on

Basic Commands in Linux

Alright, glad to have you all back with me. Today we will be taking a look into the basic commands of a Linux operating system.

LINUX

First of all what is Linux? Linux is a free, open-source operating system that works like Windows or macOS. It manages the computer’s hardware and software, and many servers, smartphones (like Android), and devices around the world use it.

LINUX BASIC COMMANDS

User & File Management

sudo su → Switch to the superuser (admin) account.
Think of it like logging in as the boss of the computer who can do anything.
Example: sudo su → now you’re the root user.

sudo

Working with Folders & Navigation

mkdir → Make a new folder.
Example: mkdir test → creates a folder named dir1.

ls → Show the files and folders in the current location.
Example: ls → lists everything in your current folder.

cd → Change to a different folder.
Example: cd dir1 → moves into the dir1 folder.

pwd → Print where you are (your current folder path).
Example: pwd → might show /home/user/test.

mkdir

pwd

Creating & Moving Files

touch → Create an empty file.
Example: touch newfile.txt → makes a new file called newfile.txt.

cp → Copy files or folders.
Example: cp newfile1.txt newfile2.txt → copies newfile1.txt to newfile2.txt.

mv → Move or rename files/folders.
Example: mv newfile.txt new.txt → renames newfile.txt to new.txt.

touch

Viewing & Editing Files

vim → Open a text editor in the terminal.
Example: vim newfile.txt → opens newfile.txt to edit. ( Vim is tricky for beginners.)

cat → Show the contents of a file.
Example: cat newfile.txt → displays what’s inside newfile.txt.

less → View a file one page at a time (useful for big files).
Example: less newfile.log → scroll through newfile.log.

cat

vim

now

Searching & Deleting

rm → Remove (delete) a file.
Example: rm newfile.txt → deletes newfile.txt.
(Careful! Deleted files don’t go to recycle bin.)

grep → Search for text inside files.
Example: grep "hello" newfile.txt → finds all lines with the word hello in newfile.txt.

grep

Thats all for now, hope we enjoyed our ride today, see you next time!

Top comments (0)