Simple Guide for Beginners to Use Linux Command Line

Table of contents

/Linux Directory :

  1. root : Main root user home

  2. bin (Binaries) : Contain essential system binaries required for basic system operation.

    Ex . ls, cp, mv, cat, echo, sudo.

  3. sbin (system binaries) : Stores essential binaries for system Administration.

    Ex . fdisk, ifconfig, reboot, shutdown.

  4. etc (configuration file) : Contain system wide configuration files and scripts.

    Ex . /etc/passwd (user account)

    /etc/fstab (disk mount points)

  5. var (variable data) : Stores log files, database and dynamically changing data.

    Ex . /var/log (system logs)

    /var/www (web server files)

  6. usr ( user system resource) : Contains user installed programs, libraries and documation.

    Ex. /usr/bin/ (Non-essential user binaries)

    /usr/sbin/ (Non-essential system binaries)

  7. home (user home directories) : Each user has a separate home directory.

    /home/username

  8. opt (optional software) : Used for installing third party software manually.

    Ex . /opt/google/ (for google chrome)

  9. dev (device file) : Contains device files.

    Ex . /dev/sda (for hard drives)

  10. proc (process information) : A virtual filesystem that provide process and system information.

  11. sys (Kernel and hardware info) : Contains system related information, similar to /proc.

  12. media (removable media mount points) : Auto-mount location for USB drivers CDs, etc.

  13. boot (boot loader files) : Stores boot-related files, including the Linux kernel and GRUB.

  14. lib (libraries) : Shared libraries required by /bin and /sbin binaries.

  15. tmp (temporary files) : Stores temporary files, usually deleted on reboot.

  16. run (runtime data) : Stores runtime data

    EX . process IDs, sockets

$ : for Normal User

# : For Root User

Easy Linux Command Guide for New Users :

The most frequently used command in Linux to List directories

ls

Linux command to navigate through directories

cd (directory name)

Linux command for close the current directory

cd ..

Command used to create directories in Linux

mkdir (directory name)

Move or rename files in Linux

mv (file name) (give path)

Similar usage as mv but for copying files in Linux

cp (file name) (give path)

Delete files or directories

rm (files or directories)

Create blank/empty files

touch (files name)

Clear the terminal display

clear

Display file content on the terminal

cat > (file name)

Print any text that follows the command

echo "Write a text"

Linux command to display paged outputs in the terminal

cat /(file name)|less

Access manual pages for all Linux commands

man (command name)

For long listing

ls -l

For remove empty directory

rmdir (directory name)

How to delete folder directory is not empty

rm -rf (directory name)

Remove all directory

rmdir*

Display the user logged in to the system

who

Display the name currently logged user

whoami

Currently running processes

ps

How to terminate processes manually

kill (processes id)

To check process id

top

Create symbolic links (shortcuts) to other files.

ln

To create a link to another file

types : soft and hard link

Hard link : Is a mirror copy of an original file with the exact same contents. if you edit the contents of the original file, those change will be reflected in the hard link. If you delete the original file though, the hard link will still work and you can view and edit it as you would a normal copy of the original file.

How to create Hard link :

ln (file name) (hard link name for save)

Soft link : It points to the path of another file. If the original file is deleted, the soft link become broken.

How to create a Soft link :

ln -s (file name) (soft link name for save)

To display a file’s contents page by page

cat (give path)|less
ESC:q   (for exit)

Spacebar for see data page by page

enter key for see data line by line

To see information about the system kernel

uname 
uname -a

File zip and unzip command :

zip (file name)
unzip (file name)

Service command : is used to manage system services.

systemctl status (service name)     for the check the status
systemctl start (service name)      for start the service
systemctl stop (service name)       for stop the service
systemctl restart (service name)    for restart the service 
systemctl enable (service name)     for enable the service

Head and Tail command

head (file name)         for see first top ten line 
tail (file name)         for see bottom ten line

Sort command : Can be used to sort lines in ascending or descending order

sort (file name)

Grep command : Is a powerful and versatile text search tool in Linux and unix based operating system.

(any command with output) > |grep " text"

Tar command : In Linux is used to create and extract archived files. We can extract multiple different archive file.

tar -cvf  (archive name).tar  filename 
tar -xvf filename

Export command : The export command in Linux and unix based operating system is used to set environment variable.

 export (variable name) = value

How to install service ?

For Ubuntu

sudo apt-get update -y  or sudoapt-get install (service name)

For CentOS

sudo yum install yum -y or Sudo yum update -y or sudo yum install (service name) -y

How to add new hard Disk ?

  • First add a new hard disk.(physically)

  • First switch off the machine.

  • Go and select Hard disk. Select Add. select Next. Select SCSI. Select Next.

  • Create a new virtual disk Select Next.

  • Store Virtual disk as a single file.

  • Select Disk size Select Next.

  • Start the machine.

    After that , Go to terminal. Super login user.

      fdisk -l
    

    You will see

       Device Boot      Start         End      Blocks   Id  System
      /dev/sda1   *        2048     2099199     1048576   83  Linux
      /dev/sda2         2099200    41943039    19921920   8e  Linux LVM
    

    Partition the Disk

      sudo fdisk /dev/sdb
    
    • Press n → New partition

    • Press p → Primary

    • Press 1 → Partition number

    • Press Enter to accept default values

    • Press w to save changes

Format the Partition

sudo mkfs.ext4 /dev/sdb1

Create a Mount Point

sudo mkdir /mnt/newdisk      (create a newfolder)
sudo mount /dev/sdb1 /mnt/newdisk    (to mount folder)

conclusion :

In conclusion, understanding and utilizing the Linux command line is an essential skill for beginners and experienced users alike. This guide provides a foundational overview of the Linux directory structure and essential commands, enabling users to navigate, manage files, and perform system administration tasks effectively. By mastering these basics, users can enhance their productivity and gain greater control over their Linux systems. As you continue to explore and practice, you'll discover the full potential and flexibility that Linux offers, empowering you to tackle more complex tasks and customize your computing environment to suit your needs.

0
Subscribe to my newsletter

Read articles from Tambadkar Rohit Yashwant directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tambadkar Rohit Yashwant
Tambadkar Rohit Yashwant

Learning DevOps Engineer passionate about cloud computing, containerization, and automation. Currently exploring Docker, AWS, and CI/CD pipelines to build scalable and efficient workflows. Documenting my learning journey in blog. stay tuned with me for learning.