Skip to content

Commit dc5ec36

Browse files
authored
Merge pull request #344 from theputta/dev_putta
Dev putta
2 parents f652185 + 65ab842 commit dc5ec36

File tree

1 file changed

+39
-16
lines changed

1 file changed

+39
-16
lines changed

docs/books/admin_guide/03-commands.md

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ The `clear` command clears the contents of the terminal screen. In fact, to be m
270270

271271
In a terminal, the display will be permanently hidden, whereas in a graphical interface, a scrollbar will allow you to go back in the history of the virtual terminal.
272272

273-
!!! tip
273+
💡 **Tip:**
274274
<kbd>CTRL</kbd> + <kbd>L</kbd> will have the same effect as the `clear` command
275275

276276
### `echo` command
@@ -312,7 +312,7 @@ $ date -d 20210517 +%j
312312

313313
In this last example, the `-d` option displays a given date. The `+%j` option formats this date to show only the day of the year.
314314

315-
!!! Warning
315+
💡 **Warning:**
316316
The format of a date can change depending on the value of the language defined in the environment variable `$LANG`.
317317

318318
The date display can follow the following formats:
@@ -497,7 +497,7 @@ $ ls -lia /home
497497
| `25 oct. 08:10` | Last modified date. |
498498
| `rockstar` | The name of the file (or directory). |
499499

500-
!!! Note
500+
💡 **Note:**
501501
**Aliases** are frequently positioned in common distributions.
502502

503503
This is the case of the alias `ll`:
@@ -604,7 +604,7 @@ $ mkdir /home/rockstar/work
604604
The "rockstar" directory must exist to create the "work" directory.
605605
Otherwise, the `-p` option should be used. The `-p` option creates the parent directories if they do not exist.
606606

607-
!!! Danger
607+
💡 **Danger:**
608608
It is not recommended to use Linux command names as directory or file names.
609609

610610
### `touch` command
@@ -627,7 +627,7 @@ $ touch /home/rockstar/myfile
627627

628628
Date format: `[AAAA]MMJJhhmm[ss]`
629629

630-
!!! Tip
630+
💡 **Tip:**
631631
The `touch` command is primarily used to create an empty file, but it can be useful for incremental or differential backups for example. Indeed, the only effect of executing a `touch` on a file will be to force it to be saved during the next backup.
632632

633633
### `rmdir` command
@@ -644,7 +644,7 @@ $ rmdir /home/rockstar/work
644644
| ----------------------------------------------------------------------- | ----------- |
645645
| `-p` | Removes the parent directory or directories provided if they are empty. |
646646

647-
!!! Tip
647+
💡 **Tip:**
648648
To delete both a non-empty directory and its contents, use the `rm` command.
649649

650650
### `rm` command
@@ -655,7 +655,7 @@ The `rm` command deletes a file or directory.
655655
rm [-f] [-r] file [file] [...]
656656
```
657657

658-
!!! Danger
658+
💡 **Danger:**
659659
Any deletion of a file or directory is final.
660660

661661
| Options | Information |
@@ -664,7 +664,7 @@ rm [-f] [-r] file [file] [...]
664664
| `-i` | Requires confirmation of deletion. |
665665
| `-r` | Recursively deletes subdirectories. |
666666

667-
!!! Note
667+
💡 **Note:**
668668
The `rm` command itself does not ask for confirmation when deleting files. However, with a RedHat/Rocky distribution, `rm` does ask for confirmation of deletion because the `rm` command is an `alias` of the `rm -i` command. Don't be surprised if on another distribution, like Debian for example, you don't get a confirmation request.
669669

670670
Deleting a folder with the `rm` command, whether the folder is empty or not, will require the `-r` option to be added.
@@ -760,6 +760,7 @@ $ cp -r /home/rockstar /tmp
760760
| `-f` | Do not ask for confirmation if overwriting the destination file. |
761761
| `-p` | Keeps the owner, permissions and timestamp of the copied file. |
762762
| `-r` | Copies a directory with its files and subdirectories. |
763+
| `-s` | Creates a symbolik links rather than copying |
763764

764765
```bash
765766
cp file1 /repexist/file2
@@ -1017,6 +1018,27 @@ $ sort -nr dns-client.txt
10171018
5.1.150.146
10181019
```
10191020
1021+
* Sorting file by removing duplicates
1022+
1023+
The `sort` command knows how to remove the duplicates from the file output using `-u` as option.
1024+
1025+
Here is an example with the file `colours.txt` :
1026+
1027+
```
1028+
Red
1029+
Green
1030+
Blue
1031+
Red
1032+
Pink
1033+
```
1034+
```
1035+
$ sort -u colours.txt
1036+
Blue
1037+
Green
1038+
Pink
1039+
Red
1040+
```
1041+
10201042
* Sorting file by sizes
10211043
10221044
The `sort` command knows how to recognize file sizes, from commands like `ls` with the `-h` option.
@@ -1094,7 +1116,8 @@ $ find /tmp -name *.txt -exec rm -f {} \;
10941116
10951117
The previous command searches for all files in the `/tmp` directory named `*.txt` and deletes them.
10961118
1097-
!!! Tip "Understand the `-exec` option"
1119+
1120+
💡 **Tip:** "Understand the `-exec` option"
10981121
In the example above, the `find` command will construct a string representing the command to be executed.
10991122
11001123
If the `find` command finds three files named `log1.txt`, `log2.txt`, and `log3.txt`, then the `find` command will construct the string by replacing in the string `rm -f {} \;` the braces with one of the results of the search, and do this as many times as there are results.
@@ -1107,7 +1130,7 @@ The previous command searches for all files in the `/tmp` directory named `*.txt
11071130
11081131
The `;` character is a special shell character that must be protected by a `\` to prevent it from being interpreted too early by the `find` command (and not in the `-exec`).
11091132
1110-
!!! Tip
1133+
💡 **Tip:**
11111134
`$ find /tmp -name *.txt -delete` does the same thing.
11121135
11131136
### `whereis` command
@@ -1160,7 +1183,7 @@ The `grep` command returns the complete line containing the string you are looki
11601183
$ grep -w "^root" /etc/passwd
11611184
```
11621185
1163-
!!! Note
1186+
💡 **Note:**
11641187
This command is very powerful and it is highly recommended to consult its manual. It has many derivatives.
11651188
11661189
It is possible to search for a string in a file tree with the `-R` option.
@@ -1201,10 +1224,10 @@ $ find /home -name "test[123]*"
12011224
/home/rockstar/test362
12021225
```
12031226
1204-
!!! Note
1227+
💡 **Note:**
12051228
Always surround words containing meta-characters with `"` to prevent them from being replaced by the names of files that meet the criteria.
12061229
1207-
!!! Warning
1230+
💡 **Warning:**
12081231
Do not confuse shell meta-characters with regular expression meta-characters. The `grep` command uses regular expression meta-characters.
12091232
12101233
## Redirects and pipes
@@ -1233,7 +1256,7 @@ It is possible to redirect the input stream from another file with the character
12331256
$ ftp -in serverftp << ftp-commands.txt
12341257
```
12351258
1236-
!!! Note
1259+
💡 **Note:**
12371260
Only commands that require keyboard input will be able to handle input redirection.
12381261
12391262
Input redirection can also be used to simulate user interactivity. The command will read the input stream until it encounters the defined keyword after the input redirection.
@@ -1260,7 +1283,7 @@ STOP
12601283
12611284
The shell exits the `ftp` command when it receives a line containing only the keyword.
12621285
1263-
!!! Warning
1286+
💡 **Warning:**
12641287
The ending keyword, here `END` or `STOP`, must be the only word on the line and must be at the beginning of the line.
12651288
12661289
The standard input redirection is rarely used because most commands accept a filename as an argument.
@@ -1414,7 +1437,7 @@ For permanent use, they must be created in the :
14141437
* `.bashrc` file in the user's login directory;
14151438
* `/etc/profile.d/alias.sh` file for all users.
14161439
1417-
!!! Warning
1440+
💡 **Warning:**
14181441
Special care must be taken when using aliases which can be potentially dangerous! For example, an alias set up without the administrator's knowledge :
14191442
14201443
```bash

0 commit comments

Comments
 (0)