Useful Linux Commands

Here are some useful linux commands for the terminal that are not as widely known or used. Many of them can also be used on MacOs as well.

redo the last command but as root

sudo !!

open an editor to run a command (probably a long one)

ctrl + x + e

Fix or change a really long command that you last ran with a text editor


create a super-fast disk for IO dependent tasks to run on it

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

don’t add the command to the history

(add one space in front of the command)

ls -lhistory # check the history

create a tunnel with SSH to port that is not open to the public (local port 8080 -> remote host’s on port 6070)

ssh -L 8080: -N

Log output but don’t show it on the console

cat somefile | tee -a log.txt | cat > /dev/null

Exit terminal but leave all processes running

disown -a && exit

Clear your terminal without “clear” command

ctrl + l  # L

Paste the arguments of the previous command

alt + -

Completely clean and clear your terminal


Get CPU info quickly

cat /proc/cpuinfo

Get memory info quickly

cat /proc/meminfo

Recursively find a text in a directory that have a lot of files in it

grep -rn /etc/ -e text_to_find

Find files bigger than 100 MB

find -type f -size +100MB -exec ls -lah {} \;

Create a web server in the current directory to serve files from it

python -m SimpleHTTPServer

Find your public IP


Get a tree view of folders only three levels deep

tree -L 3

Get a tree view of processes


Use the last command’s arguments