Linux Cheat Sheet

A Software › Linux cheat sheet in English by shribee
18,305 views 3,113 downloads 28 Mar 2019 History
3.7 avg · 0 ratings

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
HISTCO­NTR­OL=­era­sedups
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.

Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.