Introduction to Linux Shell and Majorly used commands in linux for newbies

Introduction to Linux Shell and Majorly used commands in linux for newbies

Linux Shell

The shell can be defined as a command interpreter within an operating system like Linux/GNU or Unix. It is a program that runs other programs. The shell facilitates every user of the computer as an interface to the Unix/GNU Linux system. Hence, the user can execute different tools/utilities or commands with a few input data.

What is Shell in Linux? - Top Tech Notes

Introduction

A bash script is a file containing a sequence of commands that are executed by the bash program line by line. It allows you to perform a series of actions, such as navigating to a specific directory, creating a folder, and launching a process using the command line.

Types of Shell

  • Bourne shell (sh)

  • Korn shell (ksh)

  • Bourne Again shell (bash)

  • POSIX shell (sh)

We majorly use BASH scripting

Why do we need shell scripting?

  • Shell is a program that acts like a mediator between the kernel and the user.

  • Shell scripting is used to automate repetitive tasks. For example- restarting servers or applying patch on to any servers.

  • Shell scripts are also used to monitor systems regularly.

  • Shell scripts are used to get routine backups by admins.

Users in Linux

Super User:

  • This account is also known as the root account. It has previlege to do all the tasks that a root user can perform. We use sudo to switch to root user account or super user account.

Normal User:

The general users of the system are assigned in this account.

How to Create a New User in Linux

useradd Command

The general syntax for the useradd command is as follows:

useradd [OPTIONS] USERNAME

Only root or users with sudo privileges can use the useradd command to create new user accounts.

When invoked, useradd creates a new user account according to the options specified on the command line and the default values set in the /etc/default/useradd file.

When executed without any option, useradd creates a new user account using the default settings specified in the /etc/default/useradd file.

System User:

This is the type of account that is created only for a specific purpose or software.

Major Commands used in Linux

  1. sudo-With sudo command you can perform tasks with root or administrative previleges

  2. cd - Linux command to change directory or navigate through directories

  3. ls - The most frequently used command in Linux to list directories(ls -lrt used to get long listing of output)

  4. pwd - To get present working directory using this command

  5. useradd and usermod - Add new user or change existing users data

  6. mkdir - Command used to create directories in Linux

  7. mv - Move or rename files in Linux

  8. cp - Similar usage as mv but for copying files in Linux

  9. rm - Delete files or directories

  10. touch - Create blank/empty files

  11. ln - Create symbolic links (shortcuts) to other files

  12. cat - Display file contents on the terminal

  13. clear - Clear the terminal display

  14. echo - Print any text that follows the command

  15. less - Linux command to display paged outputs in the terminal

  16. man - Access manual pages for all Linux commands

  17. uname - Linux command to get basic information about the OS

  18. whoami - Get the active username

  19. tar - Command to extract and compress files in Linux

  20. grep - Search for a string within an output

  21. head - Return the specified number of lines from the top

  22. tail - Return the specified number of lines from the bottom

  23. diff - Find the difference between two files

  24. cmp - Allows you to check if two files are identical

  25. zip - Zip files in Linux

  26. unzip - Unzip files in Linux

  27. sort - Linux command to sort the content of a file

  28. telnet - command to connect to a port on a remote server to verify if the path from our computer to that server is open over that port.

  29. passwd - Create or update passwords for existing users

  30. ssh - Secure Shell command in Linux

  31. service - Linux command to start and stop services

  32. ps - Display active processes

  33. kill and killall - Kill active processes by process ID or name

  34. df - Display disk filesystem information

  35. mount - Mount file systems in Linux

  36. chmod - Command to change file permissions

  37. chown - Command for granting ownership of files or folders

  38. ifconfig - Display network interfaces and IP addresses

  39. traceroute - Trace all the network hops to reach the destination

  40. wget - Direct download files from the internet

  41. ufw - Firewall command

  42. find-The find command in UNIX is a command line utility for walking a file hierarchy.

  43. apt, pacman, yum, rpm - Package managers in linux

  44. vi -its an editor to add/edit content of a file or script

  45. cal - View a command-line calendar

  46. top - View active processes live with their system usage

    1. ping -Unix admin command utility used to test the network reachability
  1. 48. alias - Create custom shortcuts for your regularly used commands

    1. whereis - Locate the binary, source, and manual pages for a command

  1. whatis - Find what a command is used for

Conclusion:

I hope this article has given you brief overview about basic commands used in linux. Stay connected for more articles. Happy Learning !!