Show Menu
Cheatography

Linux Cheat Sheet by

Useful commands

lsb_re­lease -a
get current version of os
service <name of servic­e> start/­sto­p/r­est­art­/status
self explan­atory

Initial config­uration

sudo apt-get update
sudo apt-get install git
sudo apt install net-tools
sudo apt install vim

Setup ssh

sudo apt update
(server) update package repository
sudo apt install openss­h-s­erver
(server) install ssh
sudo systemctl status ssh
(server) check status of service
sudo ufw allow ssh
(server) enable firewall
sudo systemctl enable ssh
(server) start ssh upon boot
ssh-keygen
(client) create key pair
ssh-co­py-id userna­me@­rem­ote­_host
(linux) copy public key
ssh <user>@<ip>
mkdir -p /.ssh
sudo nano
/.ssh/­aut­hor­ize­d_keys
<copy content of .pub file>
(windows) copy public key
sudo chown -R <us­er>­:<u­ser> ~/.ssh­/au­tho­riz­ed_keys
set ownership of key file
chmod 700 /home/username/.ssh
chmod 600 ~/.ssh­/au­tho­riz­ed_keys
(server) set permis­sions
ssh <us­er>­@<i­p> -i <full path of private key>
(client) connect
open C:\Users\<username>\.ssh\config
add entry for ip address
(windows) add entry into ssh config

Setup xRDP

sudo apt-get install xfce4
sudo apt-get install xrdp
sudo systemctl enable xrdp
echo xfce4-­session >~/.xs­ession
sudo service xrdp restart
sudo passwd rdpuser

Setup redis

sudo apt install redis-­server
install
sudo nano /etc/r­edi­s/r­edi­s.conf
change to supervised systemd
sudo systemctl restart redis.s­ervice
sudo systemctl enable /lib/s­yst­emd­/sy­ste­m/r­edi­s-s­erv­er.s­ervice
 

History Operations

~/.bas­h_h­istory
contains history even after reboot
!v
run last command that starts with v
!$
last argument
!?etc
last command contains etc
history
show command history
cd .
change to home dir
!30
run command at line number 30 from history
ctrl-r
search commands, esc or enter to edit or run
HISTCONTROL=erasedups
erase duplicate commands from history
history -c + history -w
clear history
history -r
whenever you last wrote

Shutdown

shutdown
shutdown
reboot
reboot
poweroff
same as shutdown
halt
same as shutdown
init 0
same as shutdown
init 6
same as shutdown
shutdown -r +n "­war­nin­g"
reboot in n minutes, display warning
shutdown -r now
reboot now
shutdown -c
cancel a pending shutdown
shutdown -h
shutdown and then halt
shutdown hh:mm
shutdown at specified time
   
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Linux Command Line Cheat Sheet
          Ubuntu Unity Cheat Sheet
          Windows Terminal Cheat Sheet

          More Cheat Sheets by shribee

          Git Cheat Sheet
          Python Cheat Sheet