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.
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
sudo-With sudo command you can perform tasks with root or administrative previleges
cd - Linux command to change directory or navigate through directories
ls - The most frequently used command in Linux to list directories(ls -lrt used to get long listing of output)
pwd - To get present working directory using this command
useradd and usermod - Add new user or change existing users data
mkdir - Command used to create directories in Linux
mv - Move or rename files in Linux
cp - Similar usage as mv but for copying files in Linux
rm - Delete files or directories
touch - Create blank/empty files
ln - Create symbolic links (shortcuts) to other files
cat - Display file contents on the terminal
clear - Clear the terminal display
echo - Print any text that follows the command
less - Linux command to display paged outputs in the terminal
man - Access manual pages for all Linux commands
uname - Linux command to get basic information about the OS
whoami - Get the active username
tar - Command to extract and compress files in Linux
grep - Search for a string within an output
head - Return the specified number of lines from the top
tail - Return the specified number of lines from the bottom
diff - Find the difference between two files
cmp - Allows you to check if two files are identical
zip - Zip files in Linux
unzip - Unzip files in Linux
sort - Linux command to sort the content of a file
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.
passwd - Create or update passwords for existing users
ssh - Secure Shell command in Linux
service - Linux command to start and stop services
ps - Display active processes
kill and killall - Kill active processes by process ID or name
df - Display disk filesystem information
mount - Mount file systems in Linux
chmod - Command to change file permissions
chown - Command for granting ownership of files or folders
ifconfig - Display network interfaces and IP addresses
traceroute - Trace all the network hops to reach the destination
wget - Direct download files from the internet
ufw - Firewall command
find-The find command in UNIX is a command line utility for walking a file hierarchy.
apt, pacman, yum, rpm - Package managers in linux
vi -its an editor to add/edit content of a file or script
cal - View a command-line calendar
top - View active processes live with their system usage
- ping -Unix admin command utility used to test the network reachability
48. alias - Create custom shortcuts for your regularly used commands
- whereis - Locate the binary, source, and manual pages for a command
- 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 !!