first commit
This commit is contained in:
commit
e8c2a1ce4a
|
@ -0,0 +1,201 @@
|
|||
|
||||
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
|
||||
|
||||
I would always recommend to watch those 2 Videos to get a core understanding of common Linux things:
|
||||
https://youtu.be/LKCVKw9CzFo
|
||||
https://youtu.be/42iQKuQodW4
|
||||
|
||||
---
|
||||
To do:
|
||||
- [ ] Piping via |
|
||||
- [ ] Grep
|
||||
- [x] ls / ls -la
|
||||
- [ ] usermod
|
||||
- [x] cd
|
||||
- [ ] man
|
||||
- [ ] --help
|
||||
- [ ] ssh
|
||||
- [x] pwd
|
||||
- [ ] rm
|
||||
- [x] mkdir
|
||||
- [x] touch
|
||||
- [ ] nano/ vim
|
||||
- [x] cp
|
||||
- [x] mv
|
||||
- [ ] kill
|
||||
- [ ] htop /top
|
||||
- [ ] ping
|
||||
- [ ] scp
|
||||
- [ ] info
|
||||
- [ ] history
|
||||
- [ ] clear
|
||||
- [ ] ip a
|
||||
- [ ] external ip address throght things like ip.coolerwuffi.de or curl -4 icanhazip.com
|
||||
- [ ] curl
|
||||
- [ ] wget
|
||||
- [ ] Common linux shortcuts
|
||||
- [x] apt
|
||||
- [x] systemctl/systemd
|
||||
- [x] sudo
|
||||
|
||||
---
|
||||
|
||||
# Definitions
|
||||
#### Distro/ Distribution
|
||||
A so called "Distro" short for Distribution could be intepreded as a sort of flavor/Versions of Linux. Popular Server Linux Distros are Debain, Ubuntu, RHEL (Redhat Enterprise Linux) and Alpine Linux
|
||||
|
||||
#### Repo/ Repository
|
||||
Repository short "repo" is in general a place to store data, most common are git repositorys for code or package repositorys for Software
|
||||
|
||||
#### What is a .deb/.rpm?
|
||||
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 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
|
||||
|
||||
#### 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
|
||||
|
||||
---
|
||||
# Common Linux Tools explained
|
||||
#### Sudo
|
||||
Sudo is a program to execute a command as another user in most cases the root user. The root user is the admin of every Linux out there. So if we want to run a command with elevated privages we will use `sudo`. Common command that require given privalages are:
|
||||
* `systemctl enable/disable/start/stop`
|
||||
* `apt install/remove/update/upgrade`
|
||||
#### Apt
|
||||
Apt is a so called package manager. Those are used to install Software or Libarys form Package repo. Those are hosted by your Linux Distro maintainers but you can also install third party software via .deb files. Apt has many arguements the most common are `search`, `install`, `update`, `upgrade`, `remove`, `list` and `show`.
|
||||
Here is a list which does what:
|
||||
* `search` searches throught the package index for the given string
|
||||
* `apt search firefox` this would give you results of packages that have either firefox in their name or description
|
||||
* `install` installs the software that is in the repo or local
|
||||
* `apt install firefox` will install firefox from the repository
|
||||
* `apt install ./firefox.deb` This will install the local firefox file onto your system
|
||||
* `update` will update your repository index.
|
||||
* So that if there is a new version of a software on the repo your host knows what is the newest version of given software
|
||||
* use `apt update`
|
||||
* `upgrade` Updates your installed software *including your system software*
|
||||
* This will upgrade all the installed software to the newest version of given software, it's recommended to restart your host after an upgrade
|
||||
* use `apt upgrade`
|
||||
* `remove` will remove/uninstalls software from your system
|
||||
* very easy to use
|
||||
* `apt remove <installed_software_here>`
|
||||
* `list` list out the available software on your repo
|
||||
* mostly used in combination with grep and the `--installed` option to list the local installed packages
|
||||
* `apt list --installed |grep firefox` This would list out the installed packages and uses grep to search for packages that have "firefox" in their name
|
||||
* `show` shows you information about the package
|
||||
* shows information about the package, things like dependencys upsteams Webpage, maintainer, version and so on
|
||||
* `apt show firefox`
|
||||
|
||||
#### Systemd/Systemctl
|
||||
Systemd is that so called init system that runs daemons or sockets on a given system while systemctl is the software interface to control Systemd.
|
||||
Systemd is for the user a way to run software consitenly in the background on a given host. Common things that run like that are web, printing and virtualization.
|
||||
The most importend systemctl commands are `status`, `enable`, `disable`, `start`, `stop`, `restart` and `reload`. With those you can contol the systemdaemons.
|
||||
**status**: Displays the status of a service
|
||||
+ Example: `systemctl status docker`.
|
||||
* **enable**: Enables a service so that it is automatically started at system startup
|
||||
+ Example: `systemctl enable docker`
|
||||
* **disable**: Disables a service so that it is no longer started automatically at system startup
|
||||
+ Example: `systemctl disable docker`
|
||||
* **start**: Starts a service
|
||||
+ Example: `systemctl start docker`
|
||||
* **stop**: Stops a service
|
||||
+ Example: `systemctl stop docker`
|
||||
* **restart**: Restarts a service
|
||||
+ Example: `systemctl restart docker`
|
||||
* **reload**: Reloads the configuration of a service
|
||||
+ Example: `systemctl reload docker`.
|
||||
|
||||
#### File navigation & management
|
||||
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:
|
||||
* `/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
|
||||
* `/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
|
||||
* `/sbin` contains system essential software
|
||||
* `/bin` contains your software binarys
|
||||
|
||||
But there are also some relative path variables that you need to remember:
|
||||
* `~/` This wave character is representative for the home dir of the current user
|
||||
* in case of the root user `/root/`
|
||||
* `./` A single dot indicates the current working directory
|
||||
* `../` Two dots represent the parent directory of the current working directory
|
||||
* `.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
|
||||
|
||||
##### 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
|
||||
* `ls -a` will show you all directorys/files including hidden ones
|
||||
* `ls -l` will show the contend in a list format
|
||||
* `ls` arguments can be combined
|
||||
* like `ls -la` to show all contents of a file in a list format
|
||||
* in Windows you would use traditionally the `dir` command for that
|
||||
* `pwd` will print out the current working directory
|
||||
* `cd` to "change the directory"
|
||||
* if you run `cd` without a directory it will go to the home dir of your user like `cd ~/`
|
||||
* can be used with relative paths (usually way faster)
|
||||
* like`cd ./.ssh` or `cd ~/.ssh` instead of ` cd /home/testuser/.ssh`
|
||||
* `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
|
||||
|
||||
#### Nano
|
||||
|
||||
#### Vi/Vim/Nvim
|
||||
|
||||
#### ps/top/htop
|
||||
|
||||
#### dd
|
||||
|
||||
#### Neofetch/fastfetch
|
||||
|
||||
#### Grep
|
||||
|
||||
#### ssh
|
||||
|
||||
#### scp
|
||||
|
||||
#### ping
|
||||
|
||||
#### Nice to know software
|
||||
* lynx/links
|
||||
* browsh
|
||||
* wireguard
|
||||
* nmap
|
||||
* rsync
|
||||
* gnu shreed
|
||||
* Networkmanager/ systemd-network / Netplan
|
||||
* nm-tui
|
||||
---
|
||||
# In Action
|
||||
In Case you want to install software for ex. Firefox
|
||||
```bash
|
||||
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
|
||||
|
||||
---
|
||||
|
||||
```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.
|
Loading…
Reference in New Issue