-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathLinux_commands.txt
223 lines (165 loc) · 5.32 KB
/
Linux_commands.txt
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
Linux Commands:
----------------
Internal Commands
External Commands
Basic commands in Linux:
------------------------
sudo su narayanan - switch to current user
pwd - present working directory
ls - list files
mkdir Asia Africa Europe America - All the listed folders will be created
mkdir Asia/India/Mumbai - All the listed folders will be created inside one another
mkdir -p Asia/India/Mumbai - Command will create Asia as parent directory and rest as child directories
cd .. - Change to previous directory
Absolute Path and Relative Path
pushd
popd
mv source_path destination_path - Move source path to destination path
rm - removes files
rm -rf - Remove files and Directories
more file_name.txt - Shows all the content
less file_name.txt - Shows all the content inside like a file
ls -l
ls -a
ls -lt
ls -ltr
ls -ld
df -hP - Show how much disk is used
du -sh - Show how much disk is free
chsh
whatis - show whatis what?
man - Shows the manual of a command
date - Shows the date and time in UTC
history - history shows what commands I have used in the history
env - Shows environment variables
export - Export exports the variable
uname -r - Lists Linux Kernel Name and Version Number
dmesg
udevadm
lspci - find out information about the PCI busses and devices connected to the PCI subsystem
lsblk - Provides the Disk partition and size
lscpu - CPU architecture
lsmem --summary
free -m
lshw
tar -cf tar.tar file1 file2 file3
ping 192.168.1.10
cat >> /etc/hosts
hostname - hostname of the machine
curl
cat /etc/resolv.conf
nslookup www.google.com - DNS of the server
traceroute www.google.com- number of hops
netstat -an | grep 80 | grep -i LISTEN
netstat -a | more
users
useradd narayanan - Add a new user
usermod narayanan - Modifies the user
whoami - Shows the current user
userdel narayanan - Deletes the user
groupadd -g 1011 developer
groupdel developer
/etc/shadow
chmod 400 file.pem - Sets permission to file
chown ubuntu:ubuntu developer.txt - Change ownership
systemctl start docker
systemctl stop docker
systemctl restart docker
systemctl reload docker
systemctl enable docker
systemctl disable docker
cat etc/fstab - Shows the UUID
cat /etc/passwd - Shows the users and their encrypted password
cat /etc/shadow - Shows the users and the ID's
Linux Kernel:
-------------
- Memory Management
- Process Management
- Device Drivers
- System calls and security
Boot Process:
-------------
- BIOS POST
- Boot Loader (GRUB2)
- Kernel Initialization
- INIT Process (SYSTEMD)
Run Levels:
-----------
- Runlevel 5 - GUI
- Runlevel 3 - Command Line
runlevel 0 -> poweroff.target
runlevel 1 -> rescue.target
runlevel 2 -> multi-user.target
runlevel 3 -> multi-user.target
runlevel 4 -> multi-user.target
runlevel 5 -> graphical.target
runlevel 6 -> reboot.target
File Types in Linux
-------------------
Files
Directories
System Files
Sockets
Named Pipes
Hard Link
Symbolic Link or Symblink
File System Hierarchy:
----------------------
- /home
- /opt - Third party software
- /mnt - for mounting
- /tmp - For temporary data
- /media - For USB drive, external media are mounted in media
- /dev - mouse and Keyboard
- /bin - basic programs and binaries
- /etc - configuration Files
- /lib - shared Libraries
- /usr - user software
- /var - variables data, logs and cached data
Linux Package Management:
-------------------------
Yum Package Manager:
====================
- yum repolist
- yum provides scp
- yum remove
- yum update httpd
Debian Package Manager:
=======================
- dpkg -i vscode.deb
File Compression:
=================
- tar -cf tar.tar file1 file2 file3
- bzip2
- gzip
- xz
Uncompressing:
==============
- bunzip2
- gunzip
- unxz
Searching Files and Directories:
================================
- locate city.txt
- find /home/micheal -name city.txt
- grep 'sample.txt'
- grep -i capital city.txt
- grep -r 'third line' city.txt
- grep -w exam city.txt
IO Redirection:
===============
Standard Input
Standard Output
Standard Error
Linux Accounts:
===============
- cat /etc/passwd
- cat /etc/group
- username UID GID
- id micheal
- who
- cat /etc/sudoers
CronJobs:
---------
- crontab -e
- crontab -l