README.md aktualisiert
This commit is contained in:
parent
e8c2a1ce4a
commit
0e71a76daa
129
README.md
129
README.md
|
@ -1,6 +1,8 @@
|
|||
|
||||
This cheet cheet / general guide will explain what each command will do and when to use it
|
||||
This Cheet Cheet assumes you use a Debian based system like Ubuntu but can be also applied to other Posix systems like MacOS and in some degree to non Posix systems like Windows. There are also definitions for each word that is not well know
|
||||
This cheet cheet / general guide will explain what each command will do and when to use it.
|
||||
It's intended as a general guide/cheet cheet for linux beginners on the command line.
|
||||
|
||||
This Cheet Cheet assumes you use a Debian based system like Ubuntu but can be also applied to other Posix systems like MacOS and in some degree to non Posix systems like Windows. There are also definitions for each word that is not well know.
|
||||
|
||||
I would always recommend to watch those 2 Videos to get a core understanding of common Linux things:
|
||||
https://youtu.be/LKCVKw9CzFo
|
||||
|
@ -8,19 +10,20 @@ https://youtu.be/42iQKuQodW4
|
|||
|
||||
---
|
||||
To do:
|
||||
- [ ] Piping via |
|
||||
- [x] Piping via | , >, >>
|
||||
- [ ] Grep
|
||||
- [x] ls / ls -la
|
||||
- [ ] usermod
|
||||
- [x] cd
|
||||
- [ ] man
|
||||
- [x] cat
|
||||
- [ ] --help
|
||||
- [ ] ssh
|
||||
- [x] pwd
|
||||
- [ ] rm
|
||||
- [x] rm
|
||||
- [x] mkdir
|
||||
- [x] touch
|
||||
- [ ] nano/ vim
|
||||
- [x] nano/ vim
|
||||
- [x] cp
|
||||
- [x] mv
|
||||
- [ ] kill
|
||||
|
@ -30,9 +33,12 @@ To do:
|
|||
- [ ] info
|
||||
- [ ] history
|
||||
- [ ] clear
|
||||
- [ ] mount
|
||||
- [ ] ip a
|
||||
- [ ] permissions
|
||||
- [ ] external ip address throght things like ip.coolerwuffi.de or curl -4 icanhazip.com
|
||||
- [ ] curl
|
||||
- [ ] Bootloader, like grub or systemd-boot
|
||||
- [ ] wget
|
||||
- [ ] Common linux shortcuts
|
||||
- [x] apt
|
||||
|
@ -52,11 +58,11 @@ Repository short "repo" is in general a place to store data, most common are git
|
|||
Deb and Rpm files are softwarebundels that are used to install Software on their respective platforms. Debain based Distros use .deb files to install software while RHEL or SUSE based Distros use the .rpm format
|
||||
|
||||
#### Everything has an alternative
|
||||
What you need to remember on Linux systems is that almost everything has an alternative way/software to do the same or similar jobs. This fragmentation has some standarts and common software. Ex. The most common package manager to install software on Linux ist apt but there are also may alternatives out there like dnf, pacman, apk and so on. The most importened thing is to remember the core concepts. On the most common Distros most things are the same, GNU userspace, Systemd as a initsystem and so on
|
||||
What you need to remember on Linux systems is that almost everything has an alternative way/software to do the same or similar jobs. This fragmentation has some standards and common software. Ex. The most common package manager to install software on Linux ist apt but there are also may alternatives out there like dnf, pacman, apk and so on. The most importened thing is to remember the core concepts. On the most common Distros most things are the same, GNU userspace, Systemd as a initsystem and so on
|
||||
|
||||
#### What is a linux daemon?
|
||||
#### What is a Linux daemon?
|
||||
**A process which runs in the background and is not interactive**. They have no controlling terminal on their own from the user's perspective from the desktop. They continue to exist and operate regardless of any user being logged into the server if the computer is on( [See](https://help.interfaceware.com/v6/differences-between-processes-daemons-and-services)). On most Linux system you will use Systemd for that.
|
||||
'* Also known as Service on Windows
|
||||
'* On Windows there are Windows Services similar to Linux daemons
|
||||
|
||||
#### Use TAB were possible
|
||||
The Tab key is mostly forgotten today but on the command line it is essential for easy fast navigation use it every were possible
|
||||
|
@ -114,13 +120,13 @@ The most importend systemctl commands are `status`, `enable`, `disable`, `start`
|
|||
Under Linux and other other Unix like and other Systems you will use nearly the same commands to navigate your file tree and manage them. The most well known Unix like desktopsystems are Linux, Android, MacOS and FreeBSD many command. They are mostly follow the Posix Standard.
|
||||
|
||||
##### Core Concepts
|
||||
So to understand the most common things, I will explain them now rather than later. In Linux you don't have a C: or D: drive like in Windows instead you have the `/` aka root directory. This directory holds all files and folders of your system. The most imported root directorys are:
|
||||
So to understand the most common things, I will explain them now rather than later. In Linux you don't have a C: or D: drive like in Windows instead you have the `/` aka root directory. For more information about multiple drives see [mount](#mount) This directory holds all files and folders of your system. The most imported root directorys are:
|
||||
* `/etc` short for Editable Text Configuration
|
||||
* `/home` where the non root user files are located
|
||||
* `/dev` contains external devices like hard drives and other things
|
||||
* `/dev/urandom` contains a unlimited number of random data
|
||||
* `/dev/null` all data moved to or from there is empty
|
||||
* for more read see the #dd section
|
||||
* for more read see the [dd](#dd) section
|
||||
* `/root` is the home directory of the root user
|
||||
* `/tmp` is a temporarily directory that will clean itself after each reboot
|
||||
* `/usr` contains system wide non essential software and librarys
|
||||
|
@ -135,6 +141,8 @@ But there are also some relative path variables that you need to remember:
|
|||
* `.ssh/` a dot before a directory indicates to the system that it is a hidden directory
|
||||
* if you don't specify a directory path but insted only `Documents/test.txt` your system will try to use a relative directory with that name: `./Documents/test.txt`
|
||||
* This is really handy for fast navigation on the command line
|
||||
* you can use the `*` as a symbol to specify that every things is meant
|
||||
* if you want so select all files or directorys that start or end with `start` use `*start` or `start*`
|
||||
|
||||
##### Commands to Navigate your file tree
|
||||
* `ls` short for list is the most common command to list existing files and directorys that are inside of a given directory
|
||||
|
@ -151,30 +159,101 @@ But there are also some relative path variables that you need to remember:
|
|||
* `cd !!` to go back to the previous directory
|
||||
|
||||
##### Modifying content
|
||||
* `touch` will create a empty file
|
||||
* `touch example.txt`
|
||||
* `mkdir` will create a empty directory
|
||||
* `mkdir ~/`
|
||||
* using an text editor of choice ex. nano or vim
|
||||
##### `touch`
|
||||
`touch`will create a empty file
|
||||
* `touch example.txt`
|
||||
###### `mkdir`
|
||||
`mkdir` will create a empty directory
|
||||
* `mkdir ~/`
|
||||
|
||||
Edit files using an text editor of choice ex. [nano](#nano) or [vim](# Vi/Vim/Nvim)
|
||||
##### `rm`
|
||||
`rm` to remove files or/and directorys
|
||||
* use `rm -r` to remove directorys
|
||||
* **be EXTEMLY CAREFULL with `rm` it removes ALL FILES and they GONE no trash dir just gone**
|
||||
* **never ever run `rm -rf /`** it will stop your system form working and removes all other files
|
||||
* used like: `rm testfile.txt` or `rm -r ./testdir`
|
||||
###### `cat`
|
||||
`cat` will print out the contend of a given file
|
||||
* used like : `cat testfile.txt`
|
||||
|
||||
#### Piping, Redirecting and Shellscripting
|
||||
On the most Linux systems the default shell ist "bash" on some other it is "zsh". On MacOS is "zsh" the default shell. The post imported thing is that they are Poisx complaint.
|
||||
|
||||
##### Piping
|
||||
On the command line you can chain commands together like following example:
|
||||
```bash
|
||||
cat testfile.txt |grep test
|
||||
```
|
||||
In this example we are using [cat](#cat) to print out the contend of the testfile. That contend is piped via the pipe symbol `|` to [grep](#grep). Grep will search for a given string in our case test. So if a line in the testfile.txt has the string test in it grep will print out the lines with the given string in it
|
||||
|
||||
###### Redirecting
|
||||
There is also another symbol used on the command line with the "output redirection operator" `>` you can redirect the output to a file
|
||||
```bash
|
||||
apt list --installed > installedpackages.txt
|
||||
```
|
||||
Here we are listing the installed packages via [apt](#apt) and then redirecting the output to the "installedpackages.txt"
|
||||
|
||||
If we would repeat that command it will overwrite the existing file but if we want to append it to the file we can use the redirection symbol twiste `>>`
|
||||
```bash
|
||||
echo "hi, this is a test" >> installedpackages.txt
|
||||
```
|
||||
|
||||
###### Scripting
|
||||
If your want to combined commands you can write a shell script for that. You can use a graphical text editor like vscode or you could use a terminal text editor like [nano](#nano) or [vim](# Vi/Vim/Nvim)
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
apt list --installed > installedpackages.txt
|
||||
|
||||
# This will check via grepp if Firefox is in the installedpackages list
|
||||
if ! grep -q "firefox" installedpackages.txt; then
|
||||
echo "Firefox is not installed. Installing..."
|
||||
sudo apt install -y firefox
|
||||
else
|
||||
echo "Firefox is already installed :D"
|
||||
fi
|
||||
```
|
||||
``
|
||||
#### Nano
|
||||
|
||||
Nano is a simple editor nice for quick edits but hides a lot of it's features behind config files.
|
||||
To use nano run `nano testfile.txt` if the file already exists it will load up the file. If not nano will create a new file
|
||||
If you fished your edit press `ctrl + o` to save the file and then press `ctrl + x` to exit nano
|
||||
#### Vi/Vim/Nvim
|
||||
Vi, Vim and Nvim are all text editors that build upon another. I would always recommend to use at least vim, because of it's text highlighting. The biggest upgrade to Nvim in my opinion is the build in file explorer which is really handy. They are not really easy for beginners cause the mode editor model isn't the norm nowadays and you have to remember some shortcuts. The most important is `Esc` to go back into Normal mode, then press `:` and then `q!`. This will force quit vim without saving.
|
||||
|
||||
Those are all mode based editors. You have 3 distinct modes, Normal, Insert and Visual.
|
||||
* You can enter Normal mode via the `Esc` key it's the default mode
|
||||
* To enter Insert mode press the `I` key, know you can write/edit your files
|
||||
* press `Esc` to return to normal mode
|
||||
* To enter Visual mode press the `V` key, know you can mark your text and copy it to your clipboard with `Y`, with `P` you can past your clipboard content into the editor
|
||||
* press `Esc` to return to normal mode
|
||||
If your are done with your edit go back to normal mode, then press `:` and then `wq` to save and quit
|
||||
|
||||
some useful shortcuts:
|
||||
* Normal mode: press `U` to go back to the change before
|
||||
* Normal mode: press `cont + R ` to go forward to the newest change
|
||||
* Normal mode: press `/` then type in a string to search for given string thought the file
|
||||
|
||||
|
||||
|
||||
|
||||
#### ps/top/htop
|
||||
|
||||
WIP (Work in Progress)
|
||||
#### dd
|
||||
|
||||
WIP
|
||||
#### Neofetch/fastfetch
|
||||
|
||||
WIP
|
||||
#### Grep
|
||||
|
||||
WIP
|
||||
#### ssh
|
||||
|
||||
WIP
|
||||
#### scp
|
||||
|
||||
WIP
|
||||
#### ping
|
||||
|
||||
WIP
|
||||
#### mount
|
||||
WIP
|
||||
#### Nice to know software
|
||||
* lynx/links
|
||||
* browsh
|
||||
|
@ -191,11 +270,11 @@ In Case you want to install software for ex. Firefox
|
|||
sudo apt install firefox
|
||||
```
|
||||
|
||||
If you use this command you will elevate your privages with sudo to the root (admin) user and execute apt with thouse privilages to install firefox on your system
|
||||
If you use this command you will elevate your privileges with [sudo](#sudo) to the root (admin) user and execute [apt](#apt) with those privileges to install firefox on your system
|
||||
|
||||
---
|
||||
|
||||
```bash
|
||||
systemctl enable --now docker
|
||||
```
|
||||
With this command you would enable docker as a Systemdaemon persistently and now on the running system, so you dont have to enable docker and start it now manually.
|
||||
With this command you would enable docker as a [Systemdaemon](# What is a linux daemon) persistently and now on the running system, so you don't have to enable docker and start it now manually.
|
Loading…
Reference in New Issue