# Less known but useful bash Commands

# Less known but useful Commmands

# Redo last command but as root

```bash
sudo !!
```

## Open an Editor, write a bash command
#### (and execute in shell) 

```bash
ctrl+x+e
```

## Create superfast Ramdisk

```bash
mkdir -p /mnt/ramm
mount -t tmpfs tmpfs /mnt/ram -o size=8192M
```

## fix a really long command
#### (that you messed up)

``` bash
fc
```

## quickly create folders

```bash
mkdir -p folder/{sub1,sub2}/{sub1,sub2,sub3}
```

## exit terminal but leave all processes running

```bash
disown -a && exit
```

# fdupes

## delete duplicate files without conformation

```
fdupes -r /path/to/folder
```

## To manually confirm deletion of duplicated files

```
fdupes -r -d /path/to/folder
```

## To automatically delete all copies but the first of each duplicated file

#### (be warned, this actually deletes files, as requested)

```
fdupes -r -f . | grep -v '^$' | xargs rm -v
```

## I'd recommend to manually check files before deletion

#### 1. write duplicates to text-file

```
fdupes -rf . | grep -v '^$' > files 
```

#### 2. then manually check the files to delete and remove files that should not be deleted from file 3. remove all files that occour in the text-file with:

```
xargs -a files rm -v
```