Professional Documents
Culture Documents
Ubuntu Server CLI Pro Tips 2020-04
Ubuntu Server CLI Pro Tips 2020-04
Get the IP address of all interfaces Search for packages List files Create directories recursively
networkctl status apt search <string> ls mkdir -p <directory1>/<directory2>
snap find <string>
Display all IP addresses of the host List files with permissions and dates Delete a directory recursively
List available updates ls -al rm -r <directory>
hostname -I
apt list --upgradable
Enable/disable interface Apply all available updates Common file operations Quick file search
ip link set <interface> up create empty: touch <filename> locate <q>
sudo apt update && sudo apt upgrade
ip link set <interface> down create with content: echo "<content>" > <filename>
Install from the Ubuntu archive: append content: echo "<content>" >> <filename> Search string in file
Manage firewall rules sudo apt install <package> display a text file: cat <file> grep <string> <filename>
enable firewall: sudo ufw enable copy: cp <file> <target filename>
Install from the snap store: move/rename: mv <file> <target directory/filename> Search string recursively in
list rules: sudo ufw status sudo snap install <package> directory
delete: rm <file>
allow port: sudo ufw allow <port> grep -Iris <string> <directory>
deny port: sudo ufw deny <port> Which package provides this file? Create a directory
sudo apt install apt-file mkdir <directory>
Connect remotely through SSH sudo apt-file update
ssh <user>@<host IP> apt-file <filename or command>
Find files modified in the last n minutes Pack a directory into an archive Install MicroK8s and list available add-ons Or another distro
find <directory> -mmin -<n> -type f
zip: zip -r <target> <source dir> sudo snap install microk8s --classic lxc launch images:centos/8/amd64
eg. find . -mmin -5 -type f tar.gz: tar cvzf <target>.tar.gz <source dir> microk8s.status --wait-ready <container name>
Show only the nth column Unpack an archive Enable a MicroK8s add-on Get a shell inside a LXD container
col<n> “<separator>” <filename> zip: unzip <zip file> microk8s.enable <service> lxc exec <name> -- /bin/bash
eg. col2 “,” foo.csv tar.gz: tar xf <tar.gz file>
View MicroK8s nodes and running services Push a file to a LXD container
Display file paginated Copy file to remote server microk8s.kubectl get nodes
lxc file push <filename>
less <filename> scp <filename> <user@server>:<destination> microk8s.kubectl get services <container name>/<path>
eg. scp config.yaml admin@192.0.0.0:/config
Display first n lines More MicroK8s help at microk8s.io/docs Pull a file from a LXD container
head -n <n> <filename> Copy directory recursively lxc file pull <destination>
from remote server Launch a LXD container <container name>/<file path>
Display last n lines scp -r <user@server>:<source> <destination> lxd init
tail -n <n> <filename> eg. scp -r admin@192.0.0.0:/config /tmp lxc launch ubuntu:18.04 <container name> More LXD help at linuxcontainers.org/lxd