My Linux Cheat Sheet


# check folder size
du -h --max-depth=1
# list files in directory starts with z
ls z*
# list files starts with z and
# second character must be c or d
ls z[cd]*
# search for a keyword within all the files
# in the directory and all its subdirectory
grep -rnw . -e 'pattern'
# substring 'pot' from 'hippopotamus'
echo 'hippopotamus'|cut -c6-8
# file fruits.txt has 5lines, command to print line 2 to 4
# pear
# apple
# banana
# orange
# strawberry
sed -n -e '2,4p' fruits.txt


# vimrc config
cd ~
echo 'set tabstop=2'>>.vimrc
echo 'set shiftwidth=2'>>.vimrc
echo 'filetype indent on'>>.vimrc
echo 'set hlsearch'>>.vimrc
# vim editor
shift + v = select line
ctrl + v = select char by char
# after selection
shift + i = insert char
shift + u = convert selection to uppercase
u = convert selection to lowercase


Install Virtualbox guest additions. Tested working in Linux Mint 20 Ulyana. Ran properly for a while for Elementary OS 5.1.5 Hera, then crash. Did not manage to get it working with Ubuntu Mate 20.04, maybe I missed something.

sudo apt update
sudo apt upgrade -y
sudo apt install virtualbox-guest-x11 -y
sudo adduser $USER vboxsf


# start new session
# start new session with a name
tmux new -s session_name
# list all tmux sessions
tmux ls
# attach to last used session
tmux a
# attach to a named session
tmux a -t session_name
# kill a tmux session
tmux kill-session -t session_name
# run script in a new tmux session and detach it
tmux new -s session_name -d '~/'


#run VNC server at display 1 after reboot using ubuntu user
@reboot su ubuntu -c 'vncserver :1'



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin FOO

Kevin FOO


A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.