Linux Commands
Linux Commands
Associate Study
Material By
Deepak
1. Linux Introduction
Why Linux?
• OpenSource.
• Community support.
• Heavily customizable.
• Most Servers runs on Linux.
• DevOps most of the tools implements on Linux only.
• Automation
• Secure.
Architecture of Linux
Diffrent Linux distros
➔ Popular Desktop Linux OS
• Ubuntu Linux
• Linux Mint
• Arch Linux
• Fedora
• Debian
• OpenSuse
• Ubuntu Server
• Centos
It is a package management system. The name RPM variously refers to the .rpm file format, files in
this format, software packaged in such files, and the package manager itself. RPM was intended
primarily for Linux distributions; the file format is the baseline package format of the Linux
Standard Base. RPM was developed by Community & Red Hat.
NOTE: You will also encounter diffrent commands, packages and service names while using
both kinds of distros.
2. Basic Commands
➔ Open Terminal
➔ Create some more directories and list them with “ls” command.
➔ Create some empty files with “touch” command and list them.
➔ Reconfirm your location in your system.
What is a path?
A path is a unique location to a file or a folder in a file system of an OS. A path to a file is
directory(/). In other words we can say absolute path is a complete path from start of actual
/home/imran/linux-practices/
/var/ftp/pub
/etc/samba.smb.conf
/boot/grub/grub.conf
If you see all these paths started from / directory which is a root directory for
every Linux/Unix machines.
=> Enter.
➔ Read file with cat command.
VIM EDITOR
This is command mode editor for files. Other editors in Linux are emacs, gedit
vi editor is most popular
It has 3 modes:
1 Command Mode
2 Insert mode (edit mode)
3 extended command mode
Note: When you open the vim editor, it will be in the command mode by default.
Command Mode:
VY To copy a line
I •. :::., - --
Extended Mode: ( Colon Mode)
Extended Mode is used for save and quit or save without quit using "Esc" Key with":"
Esc+:20(n) To go to line no 20 or n
Is command options
Types of files in linux.
Symbolic links
Symbolic links are like desktop shortcuts we use in windows.
Create a soft link for /var/log directory in our current working directory.
4. Filter & IO redirectioncommand.
Grep
system
➔ Linux is case sensetive, Root is diffrent that root. Ignoring case in grep with -i option.
• head
• tail
• cut
• sed
I/O redirection
➔ Search for text “tech” replace it with “tools” and redirect output to a new file.
Find
5. Users & Groups.
USERS
Types of user
Group file
2. /etc/group
The file /etc/group stores group information. Each line in this file stores one group entry.
COMMANDS DESCRIPTION
whoami username
If a user has already full sudoers privilege, it can become a root user anytime.
Note: User imran was already a sudo user with full privilege.
➔ Adding user sam in sudoers list.
For CentOS
To install Tree
# curl https://rpmfind.net/linux/centos/7.9.2009/os/x86_64/Packages/tree-1.6.0-10.el7.x86_64.rpm -o tree-1.6.0-
10.el7.x86_64.rpm
To install httpd
Due to Dependencies its failing and it will be installed one we install all the dependencies. But what if we have
Hundreds of dependencies, And that can be solved easily by other package managers like YUM .
repos. d/ directory. It reads each YUM Repository configuration file to get the information required to
download and install new software, resolves software dependencies and installs the required RPM package
files. YUM Repository configuration files must: be located in /etc/yum.repos.d
# ls /etc/yum.repos.d/
# yum –help
# yum update
To install httpd
For Ubuntu
The sources. list file is a key factor in adding or upgrading applications to your Ubuntu installation. This is
also used by your system for system updates. The file is basically the roadmap for your system to know where
it may download programs for installation or upgrade.
# cat /etc/apt/sources.list
#apt update
To install apache2
Commands Description
dependencies
CentOS_8 Commands
DNF https://www.linuxtechi
.com/dnf-command-
commands
examples-rpm-
cheatsheet management-fedora-
linux/
Additional package
repository that
provides easy access
dnf install epel- to install packages
release for commonly used
software.
dnf history View History of dnf
https://access.redhat.
com/sites/default/file
YUM Commands s/attachments/rh_yum_c
Cheatsheet heatsheet_1214_jcs_pri
nt-1.pdf
Ubuntu20 Commands
apt https://itsfoss.com/ap
commands t-command-guide/
cheatsheet
14. SERVICES
Centos8
active or not
enabled or not
Ubuntu20
active or not
18. HARDWARE
19. STATISTICS