Adds more commands into basic_cmd.md

This commit is contained in:
vl4dd 2021-04-08 04:30:33 -04:00
parent 05c6c94851
commit e3ee05e3d6
1 changed files with 141 additions and 70 deletions

View File

@ -22,15 +22,15 @@ If you see all these paths started from / directory which is a root directory fo
Relative path is defined as path related to the present working directory(pwd). Suppose I am located in /var/log and I want to change directory to /var/log/kernel. I can use relative path concept to change directory to kernel Relative path is defined as path related to the present working directory(pwd). Suppose I am located in /var/log and I want to change directory to /var/log/kernel. I can use relative path concept to change directory to kernel
changing directory to /var/log/kernel by using relative path concept. changing directory to /var/log/kernel by using relative path concept.
```bash
> $ pwd/var/logcd kernel $ pwd/var/logcd kernel
```
Note: If you observe there is no / before kernel which indicates itâs a relative directory to present working directory. Note: If you observe there is no / before kernel which indicates itâs a relative directory to present working directory.
Changing directory to /var/log/kernel using absolute path concept. Changing directory to /var/log/kernel using absolute path concept.
```bash
> $ cd /var/log/kernel $ cd /var/log/kernel
```
Note: We can use an absolute path from any location where as if you want to use relative path we should be present in a directory where we are going to specify relative to that present working directory. Note: We can use an absolute path from any location where as if you want to use relative path we should be present in a directory where we are going to specify relative to that present working directory.
Examples of relative path and absolute path for the same operation. Examples of relative path and absolute path for the same operation.
@ -38,14 +38,18 @@ Examples of relative path and absolute path for the same operation.
# Basic Linux Command # Basic Linux Command
## help ## help
- Man: an interface to the on-line reference manuals
> $ man ls ### Man: an interface to the on-line reference manuals
```bash
$ man ls
```
## Wildcard ## Wildcard
* Show all picture (multiple char) ### \* Show all picture (multiple char)
```bash
> $ ls pic* > $ ls pic*
? show only picture between 50 and 59 (only one char) ### **?** show only picture between 50 and 59 (only one char)
> $ ls pic5?.jpg > $ ls pic5?.jpg
@ -78,56 +82,80 @@ back to previous folder
-p to create parent directory if needed -p to create parent directory if needed
- Rmdir: Remove directory ### Rmdir: Remove directory
```bash
$ rmdir filename
> rmdir filename $ rm -rf filename
```
> rm -rf filename
Delete all of the files in the diectory including all subdirectories and tier contents Delete all of the files in the diectory including all subdirectories and tier contents
> $ rm -r \* .\* ```bash
$ rm -r \* .\*
```
Remove all files with the .doc extension recursively in the current working directory. Remove all files with the .doc extension recursively in the current working directory.
> $ rm \*\*/\*.doc ```bash
$ rm \*\*/\*.doc
```
### Mv: Move directory (can be used to rename a file)
```bash
$ mv file /opt/movedfile
```
- Mv: Move directory (can be used to rename a file) ### Cp: Copy file or directory
> mv file /opt/movedfile ```bash
$ cp file /opt/newcopiedfile
```
- Cp: Copy file or directory ### Touch: change file timestamps but it can also create files
> $ cp file /opt/newcopiedfile ```bash
$ touch nomdefichier.md
- Touch: change file timestamps but it can also create files $ touch pic{00..99}.jpeg # does not work
> $ touch nomdefichier.md ```
> $ touch pic{00..99}.jpeg # does not work
- Which: Searching the PATH for executable files matching the names of the arguments
> $ which ls
- File: file — determine file type
> $ file myfile
### Which: Searching the PATH for executable files matching the names of the arguments
```bash
$ which ls
```
### File: file — determine file type
```bash
$ file myfile
```
## file viewer ## file viewer
- More: file perusal filter for crt viewing
> $ more filename ### More: file perusal filter for crt viewing
```bash
$ more filename
```
### Less: opposite of more but Less is more ;)
```bash
$ less filename
```
### Cat: concatenate files and print on the standard output
```bash
$ cat filename
```
### tail : output the last part of files
- Less: opposite of more but Less is more ;) ```bash
$ tail -n 5 Workspace/SysAdminTraining/LinuxSysAdminsDoc/Linux/basic_cmd.md
- dhclient > get ip
- gnome networkmanager
- wpa_supplicant > encryption @ wifi
> $ less filename ![htop](./img/htop.png)
```
- Cat: concatenate files and print on the standard output
> $ cat filename
Args -n define the number of line needed
## Users ## Users
adduser, addgroup - add a user or group to the system adduser, addgroup - add a user or group to the system
> sudo adduser steve
```bash ```bash
r4v3n@d3bi4n:~/Workspace/test$ sudo adduser steve $ sudo adduser steve
[sudo] password for r4v3n: [sudo] password for r4v3n:
Sorry, try again. Sorry, try again.
[sudo] password for r4v3n: [sudo] password for r4v3n:
@ -258,15 +286,54 @@ marie steve
## Sysadmin tools ## Sysadmin tools
- How to create a symbolic link in Linux ### & vs &&
```bash
$ apt update && upgrade
# && launch both instance one after the other
$ sleep 10 & htop
& launch in background the sleep 10 process and open htop
```
### exit status
```bash
$ ls thisnotexist
ls: cannot access 'thisnotexist': No such file or directory
$ echo $?
2
$ ls
Desktop Documents Downloads Music Pictures Public Templates Videos Workspace
$ echo $?
0
r4v3n@d3bi4n:~$
```
### Display Environement variables
```bash
$ env
SHELL=/bin/bash
XDG_CURRENT_DESKTOP=GNOME
...
```
### Get users password hases:
```bash
$ cat /etc/shadow | grep bash
# get hashes
$ sudo cat /etc/shadow | cut -d ":" -f2
# get name
$ sudo cat /etc/shadow | cut -d ":" -f1
```
### How to create a symbolic link in Linux
To create a symbolic link to target file from link name, To create a symbolic link to target file from link name,
you can use the ln command with -s option like this: you can use the ln command with -s option like this:
```bash
> ln -s target_file link_name $ ln -s target_file link_name
```
### alias:
```bash
$ alias ll="ls -l"
```
The -s option is important here. It determines that the link is soft link. If you dont use it, it will create a hard link. Ill explain the difference between soft links and hard links in a different article. The -s option is important here. It determines that the link is soft link. If you dont use it, it will create a hard link. Ill explain the difference between soft links and hard links in a different article.
- Htop: Interactive processes viewer ### Htop: Interactive processes viewer
> $ htop > $ htop
- Changer default shell - Changer default shell
@ -312,7 +379,7 @@ $ realpath example.txt
- Wget: The non-interactive network downloader - Wget: The non-interactive network downloader
``` ```bash
$ wget www.tandemlaw.be $ wget www.tandemlaw.be
``` ```
- search url inside index.html - search url inside index.html
@ -325,10 +392,10 @@ $ cat index.html | grep -o "https.*" |cut -d "\"" -f1 |sort | uniq
- Nano: Nano's ANOther editor, an enhanced free Pico clone - Nano: Nano's ANOther editor, an enhanced free Pico clone
(simple text editor for noobies) (simple text editor for noobies)
> $ nano ```bash
$ nano
> $ nano filename $ nano filename
```
- VIM: vim - Vi IMproved, a programmer's text editor (PGM) - VIM: vim - Vi IMproved, a programmer's text editor (PGM)
> $ vim > $ vim
@ -336,42 +403,46 @@ $ cat index.html | grep -o "https.*" |cut -d "\"" -f1 |sort | uniq
> $ vim filename > $ vim filename
# APT # APT
> $ apt install ```bash
> $ apt remove $ apt install
> $ apt autoremove $ apt remove
> $ apt update $ apt autoremove
$ apt update
```
## Display & Destop Manager ## Display & Destop Manager
* Architecture: * Architecture:
> BIOS -> GRUB -> Display Manager -> Desktop Environement ```bash
BIOS -> GRUB -> Display Manager -> Desktop Environement
```
* Install Desktop Environement (GUI) * Install Desktop Environement (GUI)
```bash
> $ tasksel $ tasksel
> $ apt install gnome $ apt install gnome
> $ apt remove gnome $ apt remove gnome
```
* Reconfigurer le display manager * Reconfigurer le display manager
> $ sudo dpkg-reconfigure gdm3 ```bash
$ sudo dpkg-reconfigure gdm3
```
* Installer le display manager * Installer le display manager
> $ sudo apt install lightdm ```bash
$ sudo apt install lightdm
> $ sudo apt install gdm3
$ sudo apt install gdm3
```
* remove Desktop environement * remove Desktop environement
```bash
> $ sudo apt remove lightdm $ sudo apt remove lightdm
```
# Services # Services
- HTOP - HTOP
- dhclient > get ip - dhclient > get ip
- gnome networkmanager - gnome networkmanager
- wpa_supplicant > encryption @ wifi - wpa_supplicant > encryption @ wifi
# note : add HTOP picture (use f5)
![htop](./img/htop.png) ![htop](./img/htop.png)