-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsysAdmin-Linux
105 lines (65 loc) · 3.87 KB
/
sysAdmin-Linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#A good admin support both Windows and Linux user simulatenously. Even though it sound like the task is assigned for "IT-support".
1. Setting up vagrant
sudo dnf install vagrant
mkdir vagrant
cd vagrant
vagrant box add ubuntu/focal64 //You can choose another distribution similarly
vagrant up //Vagarnt sucks for some reason.
2. Setting up Ngnix in Redhat based distros
sudo dnf install ngnix
sudo mkdir /etc/nginx/sites-available //In debain based distro, we have this folder by default
sudo mkdri /etc/nginx/sites-enabled //" " " " " " "
sudo nano /etc/nginx/nginx.conf //Edit the http block and the line below:
include /etc/nginx/sites-enabled/*;
[Note: all files will be inside "sites-available" and we've to create symlink inside sites enabled]
3. Setup Docker // Don't use Docker when Podman exist.
sudo dnf install moby-engine //weird
sudo docker login //optional
sudo docker pull <distro>:<version> //Will install distro. ex: sudo docker pull ubuntu:20.04
sudo docker run -it <distro> //Will run the distro. ex: sudo docker run -it ubuntu
exit //Will close container.
sudo docker attach <container_id> //Will link two or more terminal running same docker
[Note: Docker image uses the same kernel which host OS has. Distros which run inside docker container doesn't have its own kernel.]
[Note: Since docker requires root permission to do things, rather use Podman which is compatible to almost all Docker command.]
4. Keep a log of command you type
script //will start recording commands
exit //will stop recording commands
[Start-Transcript and Stop-Transcript is command-line tools that can be used in Windows.]
5. Make a SSH connection to a computer if you have login credentials
ssh <username>@<ip> -p <> //example: ssh ubuntu@13.126.30.126 -p 22
[For more: curl cht.sh/ssh]
6. Setup MySQL
sudo dnf install community-mysql-common //"common" will install all necessary packages
sudo systemctl start mysqld //Optional
mysql_secure_installation //Setup root password, previleges, etc.
create user 'pranav'@'localhost' identified by 'bhattarai' //will create mysql user named "pranav" with password named "bhattarai"
mysql -u <username> -p //Try to avoid using "sudo" in any mysql command
[MariaDB is a great fork of MySQL which provides all advance features. So learn MariaDB instead, or even better learn PostgreSQL.]
7. Head, Tail & Tailf command to see logs
head -4 /path/to/log // to see 4 log entries from the beginning
tail -5 /path/to/log // to see 5 log entries form the ending
tailf /path/to/log // to see realtime change in log
[For more: curl cht.sh/<command>]
`````````````````````````````````
8. Indentifying network loss/drop
mtr google.com //mtr is an opensource utility tool which merges the functionality of 'traceroute' & 'ping'.
[For more: curl cht.sh/mtr]
``````````````````````````````````
9. Watch the command
watch ls //See realtime change in new files/folder being created since "watch" will refresh at every 2 sec.
[Watch will work with almost any other command. Just type 'watch' before the command.]
```````````````````````````````````````````````````````````````````````````````````````````````````````````````````````
10. Set up date and time through command:
sudo date -s "<year>-<month>-<day> hour:min:sec" ex: sudo date -s 2023-04-02 01:40:00
[ you can use "timedatectl" command to see local time, Universal time, time zone, etc.]
11. See harddisk health / status using smartctl
sudo smartctl -i /dev/sda // to see if harddisk has SMART capability
sudo smartctl -d ata -H /dev/sda // to run overall health ckeckup
[learn more... : sudo smartctl -x /dev/sda ]
12. Add or Remove services from Firewall policy
sudo firewall-cmd -add-service=<service_name>
sudo firewall-cmd reload
sudo firewall-cmd -remove-service=<service_name>
sudo firewall-cmd --reload
[Learned something while trying to enable "tftp" service.]
13.