Basic Linucx Commands
#####################
Whoami
date
cal
pwd
cd
cd..
clear
uname
who -b
uptime
ll or ls -l
tar -xvf mydata.tar
cat FN
cat > FM
cat >> FN
cat -n FN
cat -b FN
touch f1.txt f2.txt..
touch {1..10}
touch {a..z}
mkdir dr1 dr2 dr3 dr4..
mkdir -p dir3/images1
cat file1 file2
mv file1 file2
cp file1 file2
cp -r dir1 dir2
rm -rf
#################
File permissions:
#################
i. Owner
ii. Group
iii. Others
Permission modes are three types
1. read (r=4)
ii. write (w=2)
iii. execute (x=1)
- rwx rwx rwx
- 7 7 7
chown NewUser FILE
chown 1001 filename
chown :NewGroup FILE
pipe (|) :
ls -l | head
head -n 25 vasant.txt
tail -n 25 vasant.txt
locate apache
locate -c apache
sudo find /home -name vv.txt
find /home -type f -empty
find /home -type d -empty
grep vasanth f1.txt
####
SED
#####
sed 's/vasanth/anji/' f1.txt
sed -i 's/vasanth/anji/' f1.txt
###########
Vi (Visual Editor)
############
###############
User management
###############
# Switch to root user
$ sudo su
Create User
# Create user
$ sudo useradd <user name>
# Verify user account details
$ id <user name>
# List all users in linux
$ cat /etc/passwd
# Delete user
$ sudo userdel <user name>
# Display all groups
$ cat /etc/group
# Create a group
$ sudo groupadd <groupname>
# Add user to a group
$ sudo usermod -aG <group-name> <username>
# Remove user from the group
$ sudo gpasswd -d <username> <group name>
# Delete group
$ sudo groupdel <group name>
#######
Command
#######
$ ifconfig : it is used to print IP address of our machine
$ wget : it is used to download a file based on URl
Ex: wegt https://dlcdn.apache.org/maven/maven-3/3.9.5/binaries/apache-maven-3.9.5-
bin.zip
$ curl : it is used to send a request to URL
$ ping : it is used to check N/ connectivity
Ex: ping www.youtube.com
$df -h
135.254.163.32
##############
Package Manager
###############
ROM Based Linux Distribution: Amazon Linux, Red Hat Linux, Cent OS etc …
Package manager : yum, rpm, dnf
DEB Based Linux Distribution : Ubuntu Linux, Debian Linux etc….
Package Manager : apt
sudo apt install git
#############################################
How to deploy static website in Linux Machine
#############################################
--- To run web application, we need webserver
Note: httpd we can use as a webserver (It is apache webserver)
$ sudo yum update
$ sudo yum install httpd
$ sudo service httpd start
Note: Enable HTTPD protocol with 80 port in security group (inbound rules) of our
EC2 instance
After 80 port in security group we can access our website using EC2 instance
public IP.
To change web page content, we can use below command
$ cd /var/www/html
$ sudo vi index.html (Write the content in index.html file and save it)
We can remove httpd server from out machine
$ sudo yum remove httpd