Skip to content

Commit 2749a31

Browse files
author
Adnan Ahmed
authored
minor updates
1 parent dd2818f commit 2749a31

File tree

1 file changed

+1
-45
lines changed

1 file changed

+1
-45
lines changed

README.md

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
### a. `export`
2626
Displays all environment variables and if you want to get detail of specific variable then use `echo $VARIABLE_NAME`
27-
Syntax:
2827
```bash
2928
export
3029
```
@@ -43,7 +42,6 @@ $ echo $SHELL
4342

4443
### b. `whereis`
4544
Finds out where a specific binary is on your system.
46-
Syntax:
4745
```bash
4846
whereis name
4947
```
@@ -55,7 +53,6 @@ $ whereis php
5553

5654
### c. `which`
5755
Locate a program file in the user's path. This command will prints full path of the executable(s). It does this by searching the directories listed in the environment variable PATH.
58-
Syntax:
5956
```bash
6057
which program_name
6158
```
@@ -95,7 +92,6 @@ Clears content on window
9592

9693
### a. `ls`
9794
Lists your files. It has a lot of options like `-l` lists files in 'long format', which contains the exact size of the file, who owns the file and who has the right to look at it, and when it was last modified. `-a` lists all files, including hidden files. For more information on this command check this [link](https://ss64.com/bash/ls.html)
98-
Syntax:
9995
```bash
10096
ls option
10197
```
@@ -114,7 +110,6 @@ drwxr-xr-x 17 adnan staff 578 Mar 27 23:36 .git
114110

115111
### b. `touch`
116112
Creates or updates your file
117-
Syntax:
118113
```bash
119114
touch filename
120115
```
@@ -125,44 +120,38 @@ $ touch trick.md
125120

126121
### c. `cat`
127122
Places standard input into file. Means that it opens the file in terminal for you to edit
128-
Syntax:
129123
```bash
130124
cat > filename
131125
```
132126

133127
### d. `more`
134128
Shows the first part of a file (move with space and type q to quit)
135-
Syntax:
136129
```bash
137130
more filename
138131
```
139132

140133
### e. `head`
141134
Outputs the first 10 lines of file
142-
Syntax:
143135
```bash
144136
head filename
145137
```
146138

147139
### f. `tail`
148140
Outputs the last 10 lines of file. Use `-f` to output appended data as the file grows
149-
Syntax:
150141
```bash
151142
tail filename
152143
```
153144

154145

155146
### g. `mv`
156147
Moves a file from one location to other
157-
Syntax:
158148
```bash
159149
mv filename1 filename2
160150
```
161151
Where `filename1` is the source path to the file and `filename2` is the destination path to the file.
162152

163153
### h. `cp`
164154
Copies a file from one location to other
165-
Syntax:
166155
```bash
167156
cp filename1 filename2
168157
```
@@ -172,56 +161,48 @@ Where `filename1` is the source path to the file and `filename2` is the destinat
172161
Removes a file. But if you will apply this command on a directory directory, it will gives you an error
173162
`rm: directory: is a directory`
174163
So in order to remove directory you have to pass `-rf` to remove all the content of the directory recursively
175-
Syntax:
176164
```bash
177165
rm filename
178166
```
179167

180168
### j. `diff`
181169
Compares files, and shows where they differ
182-
Syntax:
183170
```bash
184171
diff filename1 filename2
185172
```
186173

187174
### k. `chmod`
188175
Lets you change the read, write, and execute permissions on your files
189-
Syntax:
190176
```bash
191177
chmod -options filename
192178
```
193179

194180
### l. `gzip`
195181
Compresses files
196-
Syntax:
197182
```bash
198183
gzip filename
199184
```
200185

201186
### m. `gunzip`
202187
Un-compresses files compressed by gzip
203-
Syntax:
204188
```bash
205189
gunzip filename
206190
```
207191

208192
### n. `gzcat`
209193
Lets you look at gzipped file without actually having to gunzip it
210-
Syntax:
211194
```bash
212195
gzcat filename
213196
```
214197

215198
### o. `lpr`
216199
Print the file
217-
Syntax:
218200
```bash
219201
lpr filename
220202
```
221203

222204
### p. `lpq`
223205
Check out the printer queue
224-
Syntax:
225206
```bash
226207
lpq
227208
```
@@ -235,7 +216,6 @@ active adnanad 59 demo 399360 bytes
235216

236217
### q. `lprm`
237218
Remove something from the printer queue
238-
Syntax:
239219
```bash
240220
lprm jobnumber
241221
```
@@ -266,7 +246,6 @@ lprm jobnumber
266246
### a. `awk`
267247
Awk is most usefull command for handling text files. It operates on entire file line by line. By default it uses whitespace to separate the fields. The most common syntax for awk command is
268248

269-
Syntax:
270249
```bash
271250
awk '/search_pattern/ { action_to_take_if_pattern_matches; }' file_to_parse
272251
```
@@ -295,7 +274,6 @@ For more detail on how to use `awk`, check following [link](https://www.cybercit
295274

296275
### b. `grep`
297276
Looks for text inside files. You can use grep to search for lines of text that match one or many regular expressions, and outputs only the matching lines.
298-
Syntax:
299277
```bash
300278
grep pattern filename
301279
```
@@ -314,7 +292,6 @@ And `-w` to search for words only. For more detail on `grep`, check following [l
314292

315293
### c. `wc`
316294
Tells you how many lines, words and characters there are in a file
317-
Syntax:
318295
```bash
319296
wc filename
320297
```
@@ -370,7 +347,6 @@ TODO
370347

371348
### a. `mkdir`
372349
Makes a new directory
373-
Syntax:
374350
```bash
375351
mkdir dirname
376352
```
@@ -387,7 +363,6 @@ cd dirname
387363

388364
### c. `pwd`
389365
Tells you in which directory you currently are
390-
Syntax:
391366
```bash
392367
pwd
393368
```
@@ -429,12 +404,10 @@ pwd
429404

430405
### a. `ssh`
431406
ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine.
432-
Syntax:
433407
```bash
434408
ssh user@host
435409
```
436410
This command also accepts an option `-p` that can to used to connect to specific port.
437-
Syntax:
438411
```bash
439412
ssh -p port user@host
440413
```
@@ -446,8 +419,7 @@ Return current logged in username
446419
Allows the current logged user to change his password
447420

448421
### d. `quota`
449-
Shows what your disk quota is
450-
Syntax:
422+
Shows what your disk quota is
451423
```bash
452424
quota -v
453425
```
@@ -466,21 +438,18 @@ Displays who is online
466438

467439
### i. `finger`
468440
Displays information about user
469-
Syntax:
470441
```bash
471442
finger username
472443
```
473444

474445
### j. `uname`
475446
Shows kernel information
476-
Syntax:
477447
```bash
478448
uname -a
479449
```
480450

481451
### k. `man`
482452
Shows the manual for specified command
483-
Syntax:
484453
```bash
485454
man command
486455
```
@@ -490,35 +459,30 @@ Shows disk usage
490459

491460
### m. `du`
492461
Shows the disk usage of the files and directories in filename (du -s give only a total)
493-
Syntax:
494462
```bash
495463
du filename
496464
```
497465

498466
### n. `last`
499467
Lists your last logins of specified user
500-
Syntax:
501468
```bash
502469
last yourUsername
503470
```
504471

505472
### o. `ps`
506473
Lists your processes
507-
Syntax:
508474
```bash
509475
ps -u yourusername
510476
```
511477

512478
### p. `kill`
513479
Kills (ends) the processes with the ID you gave
514-
Syntax:
515480
```bash
516481
kill PID
517482
```
518483

519484
### q. `killall`
520485
Kill all processes with the name
521-
Syntax:
522486
```bash
523487
killall processname
524488
```
@@ -534,28 +498,24 @@ Brings the most recent job in the foreground.
534498

535499
### u. `ping`
536500
Pings host and outputs results
537-
Syntax:
538501
```bash
539502
ping host
540503
```
541504

542505
### v. `whois`
543506
Gets whois information for domain
544-
Syntax:
545507
```bash
546508
whois domain
547509
```
548510

549511
### w. `dig`
550512
Gets DNS information for domain
551-
Syntax:
552513
```bash
553514
dig domain
554515
```
555516

556517
### x. `wget`
557518
Downloads file
558-
Syntax:
559519
```bash
560520
wget file
561521
```
@@ -634,7 +594,6 @@ ${#varname} # returns the length of the value of the variable as a character
634594
## 2.3. Functions
635595
As in almost any programming language, you can use functions to group pieces of code in a more logical way or practice the divine art of recursion. Declaring a function is just a matter of writing function my_func { my_code }. Calling a function is just like calling another program, you just write its name.
636596

637-
Syntax:
638597
```bash
639598
functname() {
640599
shell commands
@@ -661,7 +620,6 @@ When you will run above example the `hello` function will output "world!". The a
661620

662621
The conditional statement in bash is similar to other programming languages. Conditions have many form like the most basic form is `if` expression `then` statement where statement is only executed if expression is true.
663622

664-
Syntax:
665623
```bash
666624
if [expression]; then
667625
will execute only if expression is true
@@ -672,7 +630,6 @@ fi
672630
673631
Sometime if conditions becoming confusing so you can write the same condition using the `case statements`.
674632
675-
Syntax:
676633
```bash
677634
case expression in
678635
pattern1 )
@@ -772,7 +729,6 @@ cd hotellogs
772729
# 4. Debugging
773730
You can easily debug the bash script by passing different options to `bash` command. For example `-n` will not run commands and check for syntax errors only. `-v` echo commands before running them. `-x` echo commands after command-line processing.
774731
775-
Syntax:
776732
```bash
777733
bash -n scriptname
778734
bash -v scriptname

0 commit comments

Comments
 (0)