Repository navigation
Expand file tree
/
Copy pathnotes.txt
More file actions
213 lines (166 loc) Β· 5.09 KB
/
Copy pathnotes.txt
File metadata and controls
213 lines (166 loc) Β· 5.09 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# π Linux Learning Notes
π₯ Day 1: Linux Overview
π― Goal
Understand Linux fundamentals: components, architecture, and how the OS works.
π₯ What is Linux?
Linux is an open-source operating system that manages hardware and software resources.
Acts as a bridge between user and machine.
βοΈ Key Components
Kernel β Core of Linux, manages CPU, memory, storage, devices.
Example: Connecting a USB β kernel detects it & loads driver
Bootloader β Loads kernel into memory at startup.
Example: GRUB menu β choose Linux / Windows / recovery
Shell β Command-line interface to interact with the kernel.
Example:
$ ls # list directory contents
Other Components:
- Init System: starts services after boot (systemd, initd)
- File System: hierarchical storage (/, ext4, Btrfs)
- User Space: apps & libraries outside kernel (Firefox, glibc)
- Desktop Environment: GUI like GNOME, KDE, XFCE
- Daemons: background services (sshd, logging)
π How Components Work Together
Bootloader β Kernel β Init System β User Environment
Users interact via shell or desktop GUI. Applications communicate with kernel for hardware access.
---
π₯ Day 2: File & Directory Management β Basic
π― Goal
Learn basic Linux file/directory commands and hidden file handling.
π Directory Navigation
- pwd β Show current directory
Example:
$ pwd
/home/varun/linux-practice
- ls β List files
- ls -a β Include hidden files
Example:
$ ls -a
. .. .env logs src backup
- cd <dir> β Change directory
Example:
$ cd logs
$ pwd
/home/varun/linux-practice/logs
- mkdir <dir> β Create directory
Example:
$ mkdir test-dir
$ ls
logs src backup test-dir
π Creating Files & Directories
- touch <file> β Create empty file
Example:
$ touch example.txt
$ ls
example.txt
- mkdir <dir1> <dir2> β Create multiple directories
Example:
$ mkdir dir1 dir2
$ ls
dir1 dir2 example.txt
- tree β Show structure
Example:
$ tree -a
myproject/
βββ .env
βββ logs/
βββ src/
βββ backup/
π Copy, Move, Rename, Delete
- cp <source> <destination> β Copy file
- mv <source> <destination> β Move/rename
- rm <file> β Delete file
- rm -r <dir> β Delete directory recursively
Example:
$ cp logs/audit.log backup/audit-backup.log
$ mv logs/users.log logs/user-configuration.log
$ rm -r src/index.html
π Hidden Files
- Files starting with `.` are hidden
- Show hidden files: ls -a / tree -a
- Ignore in Git: add to .gitignore
Example:
.env
.gitignore
π Searching
- find -name "*.log" β Find files by name
- find -type f β All files
- find -type d β All directories
Example:
$ find -name "*.log"
logs/audit.log
logs/user-configuration.log
β‘ Quick Tips
- Use Tab for auto-completion
- Confirm file exists before rm
- Stop a running command with Ctrl + C
---
π₯ Day 3: Advanced File & Directory Management (Project Simulation)
π― Goal
Practice advanced operations: bulk handling, searching, logging, archiving, and cleanup.
π 1. Setup Project Structure
Example:
cd ~/linux-practice
mkdir -p myproject/{src,config,logs,backups,deploy}
touch myproject/src/app.js myproject/src/utils.js
touch myproject/config/{nginx.conf,db.conf}
touch myproject/logs/{access.log,error.log}
β
Verify:
$ tree myproject
myproject
βββ backups
βββ config
β βββ db.conf
β βββ nginx.conf
βββ deploy
βββ logs
β βββ access.log
β βββ error.log
βββ src
βββ app.js
βββ utils.js
π 2. Bulk File Operations
Create multiple files:
$ touch myproject/src/file{1..5}.js
Copy all JS files to backups:
$ cp myproject/src/*.js myproject/backups/
Move them back:
$ mv myproject/backups/file*.js myproject/src/
β
Verify:
$ ls myproject/src
$ ls myproject/backups
π 3. Advanced Find & Copy
Copy all .conf files to deploy:
$ find myproject/config -name "*.conf" -exec cp {} myproject/deploy/ \;
Copy only .js files from src to deploy:
$ find myproject/src -name "*.js" -exec cp {} myproject/deploy/ \;
β
Verify:
$ ls myproject/deploy
π 4. Add Content & Logging
Write to config:
$ echo "server { listen 80; root /var/www/html; }" > myproject/config/nginx.conf
Append timestamp to logs:
$ echo "Error at $(date)" >> myproject/logs/error.log
$ echo "Access at $(date)" >> myproject/logs/access.log
Check logs:
$ cat myproject/logs/error.log
$ cat myproject/logs/access.log
π¦ 5. Archiving & Compression
Create tarball of src:
$ tar -cvf myproject/backups/src-backup.tar myproject/src
Compress logs:
$ gzip myproject/logs/error.log
β
Verify:
$ ls -lh myproject/logs # error.log.gz
π§Ή 6. Selective Cleanup
Delete all .js files in deploy:
$ find myproject/deploy -name "*.js" -delete
Remove extracted backup folder:
$ rm -r myproject/backups/src-backup
π 7. Reflection & Visualization
See project tree:
$ tree -a myproject
Check file types & sizes:
$ ls -lhR myproject
Search by time (modified last 1 min):
$ find myproject -mmin -1
β
End of Day 3 Notes