Skip to content

Latest commit

 

History

History
115 lines (84 loc) · 2.72 KB

File metadata and controls

115 lines (84 loc) · 2.72 KB

Linux Shell Snippets

Nano: Mark all

  1. Place the cursor at the beginning of the file
  2. Ctr + 6 to set a mark
  3. Alt + Shift + T (or try Alt + T) to cut to the end of the file
  4. If Alt + T doesn't work, try Ctrl + K
  5. To just copy the file content do Ctrl + U to uncut the text again

SSH

Connect with path to keyfile

ssh -i /drive/path/file user@server

Create new SSH key

ssh-keygen -o
ssh-keygen -m PEM -t rsa -b 4096

Upload new SSH key to remote server

On the local machine run:

ssh-copy-id -f -i ~/.ssh/mykey user@host_or_ip

Remote files for SSH configuration

## Allow connection with Password to insert new SSH key on remote:
sudo nano /etc/ssh/sshd_config
## Change `PasswordAuthentication no` to `PasswordAuthentication yes`
## CTRL + X (exit) --> y (yes) --> Enter (save)

## Restart SSH services:
sudo service ssh restart
sudo service sshd restart

## Here upload the new SSH key from the local machine.
## After the new SSH key is inserted on the remote machine,
## disable password authentification again:
sudo nano /etc/ssh/sshd_config
## Change `PasswordAuthentication yes` to `PasswordAuthentication no`
## CTRL + X (exit) --> y (yes) --> Enter (save)

## Restart SSH services:
sudo service ssh restart
sudo service sshd restart

exit

Create text-tree of folder structure

## Folders only:
tree -d /path/to/folder/

## Folders and files:
tree /path/to/folder/

## Flags (source: https://linux.die.net/man/1/tree):
## -d     directories only
## -L #   Recursion depth (replace `#` with a number)
## -C     Add color to the output

Install tree for git-bash using Windows

--> https://dev.to/flyingduck92/add-tree-to-git-bash-on-windows-10-1eb1

Show disc usage

du -sh
## Remember "DOOSH" --> du -sh

ncdu

Find largest files or folders

sudo apt-get install ncdu
ncdu

Source: https://wiki.ubuntuusers.de/Festplattenbelegung/

Mount SMB folders

## Preparation:
sudo apt-get install cifs-utils