-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinux comm.txt
More file actions
197 lines (119 loc) · 4.66 KB
/
linux comm.txt
File metadata and controls
197 lines (119 loc) · 4.66 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
ipconfig - ifconfig
nmcli d - to check network
nmtui - network settings
systemctl restart network
useradd "name" "directory path"
-h help
-C copy
-M
-s bin/nologin - login without password
chown "user" "dir path" -
chgrp "group name" "dir path" -
chmod r g+rwx "file path" -
su "username" - switch user
vi for vi editor; ESC "i" for insert;
ESC ":wq" for write and quit, use "!" to say important
find / -name filename
rm {file-name} - remove file
ssh root@ipaddress - to connect to another vm
hostnamectl set-hostname younameit - changing host name.
exec bash - to see that change
sestatus- selinux status
sudo tail -100 /var/log/ - to check logs.
sudo systemctl stop firewalld - stop the firewall.
useradd username default method for adding user
useradd -m username user with home directory
passwd username adding password to user
useradd username -p password single line creation
groupadd groupname default method for adding group
groupmod
groupdel groupname deleting group
gpasswd groupname it will prompt for passwd
usermod -aG groupname username adding user to group
userdel username deleting a user
grep groupname /etc/group to know users in that group
man useradd/groupadd/usermod/members more about them.
export PATH=/yourpath/bin:$PATH
printenv for checking environmental varaiables.
ps -ef | grep mongod to check running processes.
sudo kill -9 PID to kill that process.
sudo tail -f /var/log/mongodb/mongod.log - check logs
pwd to print the current path
-vvv for clear verbose
tree for flow chart of folders.
yum whatprovides pathofelement to find which package will provide that service.
yum provides pathofelement to find which package will provide that service.
semanage port -a -t mongod_port_t -p tcp 27017 to open 27017 tcp port
more /proc/partitions - to check size of drives
top -To check ram and cpu usage.
vi ~/.bashrc -To add envi variables for that user.
sync; echo 1 > /proc/sys/vm/drop_caches -To clear cache
echo 3 > /proc/sys/vm/drop_caches && swapoff -a && swapon -a
free -m To check the memory cache used
Logical Volume
#to check drives and physical volumes
more /proc/partitions or fdisk -l | grep /dev
pvdisplay (to check any physical volumes already exist)
#change with your drive names below.
pvcreate /dev/sda /dev/sdb /dev/sdc /dev/sdd
or
pvcreate /dev/sda[bcd..] if you have similar names.
#give drive name and change with your drive names
vgcreate sam-vg /dev/sda /dev/sdb /dev/sdc /dev/sdd
#calculate total space in GB, assign to logical volume
lvcreate -L 3490G -n sam-lv(lv_name) sam-vg(vg_name)
lvcreate --extents 100%FREE --name lv_name vg_name
lvcreate -i3(stripe_number) -I64(bitesize) -L4G(space_in_gb) -n striped_logical_volume striped_vol_group
#assigns ext4 filetype to lvm
mkfs.ext4 /dev/hk6/hk6-lvdisk
#mount lv to any folder you created or already exist
mount /dev/sam-vg/sam-lv(your_volume_path) /path_of_folder_to_mount_on
#to check the disk has been created
df -h
#to unmount the lv
umount /path_of_folder_you_mounted
#remove lv created
#repair ext file system
init 1 to take system down to runlevel 1
umount /dev/sdxx removes mount
fsck -t extx /dev/sdxx specify ext filesystem
fsck -y /dev/sdxx repair ext filesystem
fsck -N /dev/sda3 don't execute, just show what could be done.
mount /dev/sdxx /path mount it back
init 3 system runlevel 3.
Cassandra on Kubes:
kubectl run givename --image=urdockerimage --port=xxxx --replicas=num --labels=key=value
kubectl get services/nodes/pods
kubectl logs pod_name
kubectl describe pods pod_name
kubectl exec -it pod_name bash
kubectl port-forward pod_name 9042:9042
kubectl get deployment
kubectl delete deployments pod_name
Docker Commands:
list all docker commands
docker or docker container --help
See version of docker
docker version/--version/info
list all containers running
sudo docker ps
sudo docker ps -s with size
list docker images/containers:
docker image ls
docker container ls
list volumes and size
docker system df -v
To run a new instance
docker run --name instance_name -d cassandra:2.2.12 -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160
To run docker through an interactive shell
sudo docker run --name name-your-cassandra -it container /bin/bash
container shell access
docker exec -it your-cassandra bash
get IP of the container
docker inspect <InstanceID>
stop a container
sudo docker stop containerID/containerName
delete a container
sudo docker kill <instanceID/Name>
delete volume of a container
docker volume rm [OPTIONS] VOLUME [VOLUME...]