Useful Linux commands

Useful Linux commands


SSH tunneling and Remote SSH port forwarding

A usage case: To make a remote web interface (running on port 80) accessible locally to your browser on port 2000 :

#ssh -f user@server -L 2000:server:80 -N
Then, on your browser, just enter:

SSH Login with Public key setup

login as root

#ssh-keygen -t rsa -b 2048

#ssh-copy-id -i ~/.ssh/ root@

SCP – Resume copy if abruptly stopped

# scp vm02_disk2.img.qcow2 google@

The following command resume the above secure copy if abruptly stopped

# rsync –rsh=’ssh’ -av –progress –partial vm02_disk2.img.qcow2 google@


tar – replace file on tar archive

The following command replace vpn.cnf with a local copy in the archive openvpn.tar
# tar –delete –file=openvpn.tar vpn.cnf; tar –append –file=openvpn.tar vpn.cnf


list size of directories

The following command list the size of directories in the current position
# ls -l | grep ^d | awk ‘{print $9}’ | while read line; do du -hs $line; done


Generate a Random Password

# date | sha256sum

# openssl rand -base64 32

Would like to hire us for your project or do you need help with Linux?