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
changing directory to /var/log/kernel by using relative path concept.
> $ pwd/var/logcd kernel
```bash
$ pwd/var/logcd kernel
```
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.
> $ cd /var/log/kernel
```bash
$ 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.
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
## 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
* Show all picture (multiple char)
### \* Show all picture (multiple char)
```bash
> $ 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
@ -78,56 +82,80 @@ back to previous folder
-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
> $ rm -r \* .\*
```bash
$ rm -r \* .\*
```
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)
> mv file /opt/movedfile
### Cp: Copy file or directory
```bash
$ cp file /opt/newcopiedfile
```
- Cp: Copy file or directory
> $ cp file /opt/newcopiedfile
### Touch: change file timestamps but it can also create files
```bash
$ touch nomdefichier.md
- Touch: change file timestamps but it can also create files
> $ touch nomdefichier.md
> $ touch pic{00..99}.jpeg # does not work
$ 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
- 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
- Cat: concatenate files and print on the standard output
> $ cat filename
![htop](./img/htop.png)
```
Args -n define the number of line needed
## Users
adduser, addgroup - add a user or group to the system
> sudo adduser steve
```bash
r4v3n@d3bi4n:~/Workspace/test$ sudo adduser steve
$ sudo adduser steve
[sudo] password for r4v3n:
Sorry, try again.
[sudo] password for r4v3n:
@ -258,15 +286,54 @@ marie steve
## 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,
you can use the ln command with -s option like this:
> ln -s target_file link_name
```bash
$ 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.
- Htop: Interactive processes viewer
### Htop: Interactive processes viewer
> $ htop
- Changer default shell
@ -312,7 +379,7 @@ $ realpath example.txt
- Wget: The non-interactive network downloader
```
```bash
$ wget www.tandemlaw.be
```
- 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
(simple text editor for noobies)
> $ nano
> $ nano filename
```bash
$ nano
$ nano filename
```
- VIM: vim - Vi IMproved, a programmer's text editor (PGM)
> $ vim
@ -336,42 +403,46 @@ $ cat index.html | grep -o "https.*" |cut -d "\"" -f1 |sort | uniq
> $ vim filename
# APT
> $ apt install
> $ apt remove
> $ apt autoremove
> $ apt update
```bash
$ apt install
$ apt remove
$ apt autoremove
$ apt update
```
## Display & Destop Manager
* Architecture:
> BIOS -> GRUB -> Display Manager -> Desktop Environement
```bash
BIOS -> GRUB -> Display Manager -> Desktop Environement
```
* Install Desktop Environement (GUI)
> $ tasksel
> $ apt install gnome
> $ apt remove gnome
```bash
$ tasksel
$ apt install gnome
$ apt remove gnome
```
* Reconfigurer le display manager
> $ sudo dpkg-reconfigure gdm3
```bash
$ sudo dpkg-reconfigure gdm3
```
* Installer le display manager
> $ sudo apt install lightdm
> $ sudo apt install gdm3
```bash
$ sudo apt install lightdm
$ sudo apt install gdm3
```
* remove Desktop environement
> $ sudo apt remove lightdm
```bash
$ sudo apt remove lightdm
```
# Services
- HTOP
- dhclient > get ip
- gnome networkmanager
- wpa_supplicant > encryption @ wifi
# note : add HTOP picture (use f5)
![htop](./img/htop.png)