Mastering the Basics: Essential Linux Commands

In the realm of operating systems, Linux has solidified its position as a powerful and versatile choice for both casual users and professionals alike. With its open-source nature and countless distributions, Linux offers a wide range of capabilities that can be harnessed through a variety of commands. Whether you’re a newcomer or looking to reinforce your skills, understanding some fundamental Linux commands is an essential step towards navigating the system with confidence.

date – To Print Current date and time
cal – To print current month Calender

    cal -3 - print 3 months (previous,current,next) calender
    cal -y - print current year calender
    cal -y 2025 - print 2025 year calender

history – To print terminal commands history

    history -c - To clear terminal commands history.

clear – clear terminal window/screen
pwd – present working directory
ls – list contents of s directory

    ls -l - long list (permissions, user, group, date & time)
    ls -la - to show hidden files.
    ls -ld - to check directory details.
    ls -ldZ - to check directory context.

ls+Double Tab – To show all possibilities to execute a command
lscpu – To show details about CPU
lshw – To show system Hardware Details
help – to see help menu of a command

    ex: ls --help

man – display manual pages of a command

    ex: man ls

whoami – Show currently logged in user
whatis – display one line description of a command

    ex: whatis ls

whereis – to check location of a command and its man pages
lsblk – to display partition information
pwd – to check present working directory
cd – change working directory

    cd <path> - to go a directory of given path
    cd .. - to go the parent directory
    cd ../../../ - to go 3 directories back
    cd - - to go to the previous directory
    cd - to go to the users profile/home-dir

echo – to print a line of text in terminal

    echo "line of text" - print in terminal
    echo "line of text" > filename - create new file cat with
    echo "line of text" >> filename - add line of text to echo file

cat – print data of a text file in terminal

    cat echo - print in terminal
    cat echo > cat - create new file cat with echo file text
    cat echo >> cat - add echo file text to cat file

touch – to create a bank file

    touch filename

cp – to copy a file from one dir to another dir.

    cp
    cp echo /root

mv – to move a file or dir. to a new dir.

    mv
    mv test mvtest - to rename a file or dir.

mkdir – To create new directory

    Ex: mkdir Songs
    mkdir –p - To create parent directory
    Ex: mkdir -p Songs/MP3/Punjabi

rmdir – To remove a blank directory

    rmdir <directory-path>

rm – To delete a file or directory with data

    rm <file-path> - To delete a file
    rm -r <dir-path> - To delete a directory
    rm -rf <file-path/dir-path> - Delete file/dir and never prompt for yes/no

Tree – To see contents of a directory in Tree format.

    Tree <directory-path>

Head – To print starting 10 lines of a text file

    Head <File-path>
    Head -n <no.of lines> - to print starting given no. of lines from a text    files

Tail – To print last 10 lines of a text file

    Tail <File-path>
    Tail -n <no.of lines> - to print last given no. of lines from a text files

grep = to print a text or pattern from a text file

    syntax: grep "" file-path
    grep "pattern" filename
    -c = print no. of matches
    grep -c "pattern" filename
    -i = ignore-case
    grep -c "pattern" filename
    -n = line number
    grep -n "pattern" filename
    -v = print lines without match
    grep -v "pattern" filename

alias – to create a shortcut of a command.

    syntax: alias =
    alias c=clear
    alias l=ls

sort – to sort data of a text file and print in terminal.

    syntax: sort <options> filename
    sort: sort data alphabetically.
    sort filename
    sort -r: sort data alphabeticall in reverse string.
    sort -r filename
    sort -n: sort data numerically.
    sort -n filename/path
    sort -f: sort data in case sensitive string (alphabetically but Capital first then small letters)

less – divide a long file into readable bits.

    Syntax: less
    show only one page of a file.)
    Down arrow key - show next line
    enter - show next line
    space - go to end of file
    After end of file press "q" to exit

more – divide a long file into readable bits.

    Syntax: more <file-path>
    (show only one page of a file.)
    enter - show next line
    space - go to end of file

|(pipe) – to use two or more commands at the same time.

    use output of one command as input to
    other command
    syntax: command1 | command 2 | command 3

top – to check running process details

    to kill a process “ press k”
    then type the PID(process ID) of process to kill
    hit enter twice

kill – to kill a process

   kill <process-id>

df – to check file system information and free disk space

    df -T - to show type of file system
    df -h - to show in human readable form(K,M,G)

Mastering these basic Linux commands is your passport to navigating the Linux operating system efficiently. Whether you’re a developer, sysadmin, or simply a curious user, a solid foundation in these commands will empower you to explore the full potential of Linux and accomplish a wide range of tasks from the command line. As you become more comfortable, you can delve into more advanced commands and techniques, unlocking even greater possibilities within this versatile operating system.

Download PDF of these commands by clicking below

error: Content is protected !!