Skip to content

Instantly share code, notes, and snippets.

@peevees
Last active March 5, 2022 15:30
Show Gist options
  • Save peevees/348984097aa40af005df50e23ca3d2b2 to your computer and use it in GitHub Desktop.
Save peevees/348984097aa40af005df50e23ca3d2b2 to your computer and use it in GitHub Desktop.
interesting linux commands
1. Redo last command but as root

sudo !!

2. Open an editor to run a command

ctrl+x+e

3. Create a super fast ram disk

mkdir -p /mnt/ram mount -t tmpfs tmpfs /mnt/ram -o size=8192M

4. Don't add command to history (note the leading space)

ls -l

5. Fix a really long command that you messed up

fc

6. Tunnel with ssh (local port 3337 -> remote host's 127.0.0.1 on port 6379)

ssh -L 3337:127.0.0.1:6379 root@emkc.org -N

7. Quickly create folders

mkdir -p folder/{sub1,sub2}/{sub1,sub2,sub3}

8. Intercept stdout and log to file

cat file | tee -a log | cat > /dev/null

Run command in background

bgor end with command with & or ctrl+z if it is a running in foreground

to bring back latest command to foreground

fg

bring back specific job id

fg %1

list background jobs

jobs -l

Exit terminal but leave all processes running

disown -a && exit

disown specific job

disown %1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment