0% found this document useful (0 votes)
125 views

Comprehensive Exploration of Linux Commands

This document provides instructions for various common Linux commands used for file management, directory navigation and manipulation, software installation and management, and server configuration. It covers basic commands like ls, pwd, mkdir, commands for viewing disk usage and network connectivity like df, free, ping, and also covers installing and managing services like Apache, Nginx, MariaDB/MySQL, and PHP on both Amazon Linux and Ubuntu systems.

Uploaded by

johnbohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Comprehensive Exploration of Linux Commands

This document provides instructions for various common Linux commands used for file management, directory navigation and manipulation, software installation and management, and server configuration. It covers basic commands like ls, pwd, mkdir, commands for viewing disk usage and network connectivity like df, free, ping, and also covers installing and managing services like Apache, Nginx, MariaDB/MySQL, and PHP on both Amazon Linux and Ubuntu systems.

Uploaded by

johnbohn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Linux command

1. ls- Show list of all files and directory(folders) inside current directory
2. pwd-Print working directory
3. mkdir- Creating directory (mkdir folder)
4. mkdir aa bb cc dd – for multiple folders
5. cd – Change directory (cd folder)
6. cd .. – one step back/one step up/ go to parent folders
7. cd – for home directory
8. clear- clear screen
9. mkdir –p one/two/three –create folder one inside two
10. ls two- we can check list of inside the that folder
11. (cd -) – Previous location like backspace button
12. ls –l = show list with long details
13. history= see the previous command
14. whoami- define which user
15. man = details of any command (man ls)
16. ls –a = see hidden any file
17. ls –al = see hidden file with details
18. rm filename= for delete file
19. rm –r foldername= for delete directory
20. rmdir foldername= for delete only empty directory
21. head file.txt = print first 10 lines of file
22. head –n file.txt= print first(any number) lines of file
23. tail file.txt= print last 10 lines of file
24. tail –n file.txt= print last(any number) lines of file
25. wc file.txt= number of line, number of words, file size in bites
26. uname = os name
27. df –h =hard disk usage information
28. free –m = for RAM space
29. du –h filename/foldername = file and folder space
30. lsblk= list of disk attached with partition
31. yum install softwarename= install software
32. ping IP/domainname= for check connectivity of server

33. sudo wget link= download file from the server


34. scp -i key.pem path image path ec2-user@publicIP:. (copy image from laptop to
server)
a. scp -i /download/linux.pem ./desktop/img.jpg ec2-user@publicIP:.
b. scp -i /download/linux.pem ./desktop/img.jpg ubuntu@publicIP:.
c. scp -i /download/linux.pem ./desktop/img.jpg ubuntu@publicIP:folder
d. scp -i /download/linux.pem ./desktop/img.jpg ubuntu@publicIP:/home/ec2-
user/folder/srk
35. scp -i key.pem path ec2-user@publicIP:./folder/img.jpg c:users/Le-/Desktop (copy
image from server to laptop)
36. which – which command allows users to search the list of paths
37. whatis - use of software

Create file
1. touch
- Create empty file
- Can’t read/write/modify

touch filename
- touch myfile.txt
- touch –m filename (time modify)
2. cat
- Create file
- Read access
- Write access
- Cannot modify

- Cat > filename.txt (Create new file or overwrite in exiting file )


- Cat >> filename.txt (for append file)
- Cat filename.txt (for read)
- For save ctrl+c and enter
3. Nano
- Create file
- Read access
- Write access
- Modify file

- Nano filename
- For save- ctl+c and y

4. Vi/vim
- Create file
- Read access
- Write access
- Modify file
- i/a/c = insert
- Esc :wq! For save
- Esc :q! for not save changes

- Vi filename

- vim filename

Chmod= change permission


Chmod –r – remove the read permission for all user
Chmod + r – add the read permission for all user
Chmod u + r= read permission only for user

Chmod u – r = remove read permission only for user


Chmod g + r= read permission only for group
Chmod o + r = read permission only for other

chmod- change moderater rwx rwx rwx


r-4
w-2
x-1

Rwx=7
Chmod 754 filename.txt (for change file permission)
Chmod -r 754 myfolder (for change directory permission)
—------------

Cp command – copy file and folders

cp source destination

cp myfile.txt myfolder/myfile.txt

cp myfile.txt myfolder

cp myfile.txt myfolder/

cp -r yourfolder/home/ec2-user/

cp -r myfolder yourfile.txt

Mv command - move file and folder

mv source destination

mv myfile.txt myfolder

mv myfile.txt myfolder/

mv myfile.txt myfolder/myfile.txt

mv myfile.txt myfolder/yourfile.txt

ownership

chown root file.txt- change ownership of file

chown root:root file.txt- change ownership user and group of file

sudo useradd name - for create user

sudo passwd name- for set psw for user

su name- switch user

Apache in amazon linux


sudo yum install httpd -y
sudo yum remove httpd -y
sudo service httpd start
sudo service httpd status
sudo service httpd stop
sudo service httpd restart
sudo systemctl enable httpd.service (for automate the httpd service)
sudo systemctl disable httpd.service (for disable the automation of httpd service)
default path= cd /var/www/html

sudo systemctl list-unit-files --type=service (for check services install in server)


yum list installed ( service & software list)
or
amazon-linux extras list

sudo yum remove httpd

Nginx in amazon linux


sudo dnf install nginx -y (AMI 2023)
sudo amazon-linux-extras install nginx1 -y (AMI 2)

sudo service nginx start


sudo service nginx status
sudo service nginx stop
sudo service nginx restart
sudo service nginx reload

amazon-linux-extras list

default path= cd /usr/share/nginx/html

Apache in ubuntu

sudo apt-get install apache2


sudo service apache2 start
sudo service apache2 stop
sudo service apache2 restart
sudo service apache2 reload
sudo service apache2 status

default path= cd /var/www/html

Nginx in ubuntu
sudo apt-get install nginx
sudo service nginx start

sudo service nginx status


sudo service nginx stop
sudo service nginx restart
sudo service nginx reload

default path= cd /var/www/html

MariaDB/Mysql in amazon linux


sudo yum -y upgrade
or

sudo yum update -y


sudo yum install mariadb105-server
or
sudo yum install mariadb-server -y
sudo service mariadb start

sudo service mariadb status


sudo service mariadb stop
sudo service mariadb restart
sudo service mariadb reload
sudo systemctl enable mariadb.service
sudo yum remove mariadb105
PHP in amazon-linux
sudo amazon-linux-extras install php8.1 -y

or
sudo yum install php
sudo service php-fpm start
sudo service php-fpm status
sudo service php-fpm stop

sudo service php-fpm restart


sudo service php-fpm reload
sudo systemctl enable php-fpm.service
Sudo yum remove php-fpm

You might also like